This repository has been archived by the owner on Jun 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for datadog as a metric source (#152)
- Loading branch information
Showing
5 changed files
with
77 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
packages/client/src/metricSources/Datadog/DatadogCanaryMetricSetQueryConfig.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { CanaryMetricSetQueryConfig } from '../../domain/Kayenta'; | ||
|
||
/** | ||
* {@see: https://github.com/spinnaker/kayenta/blob/master/kayenta-datadog/src/main/java/com/netflix/kayenta/canary/providers/metrics/DatadogCanaryMetricSetQueryConfig.java} | ||
*/ | ||
export default interface DatadogCanaryMetricSetQueryConfig extends CanaryMetricSetQueryConfig { | ||
customInlineTemplate: string | ||
} |
41 changes: 41 additions & 0 deletions
41
packages/client/src/metricSources/Datadog/DatadogMetricModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import * as React from 'react'; | ||
import { AbstractMetricModal } from '../../components/config/AbstractMetricModal'; | ||
import { DATADOG_SERVICE_TYPE } from './index'; | ||
import { InlineTextGroup } from '../../layout/InlineTextGroup'; | ||
import { validateCanaryMetricConfig } from '../../validation/configValidators'; | ||
import { CanaryMetricConfig } from '../../domain/Kayenta'; | ||
import { ValidationResultsWrapper } from '../../domain/Referee'; | ||
import DatadogCanaryMetricSetQueryConfig from './DatadogCanaryMetricSetQueryConfig'; | ||
|
||
export default class DatadogMetricModal extends AbstractMetricModal<DatadogCanaryMetricSetQueryConfig> { | ||
validateCanaryMetricConfig(existingMetric: CanaryMetricConfig, type: string): ValidationResultsWrapper { | ||
return validateCanaryMetricConfig(existingMetric, type, true); | ||
} | ||
|
||
getQueryInitialState(): DatadogCanaryMetricSetQueryConfig { | ||
return { | ||
type: DATADOG_SERVICE_TYPE, | ||
customInlineTemplate: '', | ||
}; | ||
} | ||
|
||
getMetricSourceSpecificJsx(): JSX.Element { | ||
return ( | ||
<div> | ||
<InlineTextGroup | ||
onBlur={() => { | ||
this.touch('customInlineTemplate'); | ||
}} | ||
touched={this.state.touched.customInlineTemplate} | ||
error={this.state.errors['query.customInlineTemplate']} | ||
id="customInlineTemplate" | ||
label="Datadog Query" | ||
value={this.state.metric.query.customInlineTemplate} | ||
onChange={e => this.updateQueryObject('customInlineTemplate', e.target.value)} | ||
placeHolderText="sum:requests.error{${scope}}.as_count() / sum:requests.total{${scope}}.as_count()" | ||
subText="Custom datadog query; use ${scope} as a placeholder for your tags." | ||
/> | ||
</div> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import * as React from 'react'; | ||
import { MetricSourceIntegration } from '../MetricSourceIntegration'; | ||
import { MetricModalProps } from '../../components/config/AbstractMetricModal'; | ||
import DatadogMetricModal from './DatadogMetricModal'; | ||
import DatadogCanaryMetricSetQueryConfig from './DatadogCanaryMetricSetQueryConfig'; | ||
import { string } from 'yup'; | ||
|
||
export const DATADOG_SERVICE_TYPE: string = 'datadog'; | ||
|
||
const schema = { | ||
customInlineTemplate: string() | ||
.trim() | ||
.required() | ||
}; | ||
|
||
const modalFactory = (props: MetricModalProps) => React.createElement(DatadogMetricModal, props); | ||
|
||
const Datadog: MetricSourceIntegration<DatadogCanaryMetricSetQueryConfig> = { | ||
type: DATADOG_SERVICE_TYPE, | ||
createMetricsModal: modalFactory, | ||
canaryMetricSetQueryConfigSchema: schema | ||
}; | ||
|
||
export default Datadog; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters