diff --git a/README.md b/README.md index b61f6c83..d2354eb6 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,7 @@ Referee currently supports - Prometheus - SignalFx - Datadog +- InfluxDB To add a new integration you must implement the [MetricSourceIntegration](/packages/client/src/metricSources/MetricSourceIntegration.ts) interface and then add it to the [enabled metric sources](/packages/client/src/metricSources/index.tsx). diff --git a/packages/client/src/metricSources/InfluxDB/InfluxDBCanaryMetricSetQueryConfig.ts b/packages/client/src/metricSources/InfluxDB/InfluxDBCanaryMetricSetQueryConfig.ts new file mode 100644 index 00000000..5217a3ca --- /dev/null +++ b/packages/client/src/metricSources/InfluxDB/InfluxDBCanaryMetricSetQueryConfig.ts @@ -0,0 +1,8 @@ +import { CanaryMetricSetQueryConfig } from '../../domain/Kayenta'; + +/** + * {@see: https://github.com/spinnaker/kayenta/blob/master/kayenta-influxdb/src/main/java/com/netflix/kayenta/canary/providers/metrics/InfluxdbCanaryMetricSetQueryConfig.java} + */ +export default interface InfluxDBCanaryMetricSetQueryConfig extends CanaryMetricSetQueryConfig { + customInlineTemplate: string; +} diff --git a/packages/client/src/metricSources/InfluxDB/InfluxDBMetricModal.tsx b/packages/client/src/metricSources/InfluxDB/InfluxDBMetricModal.tsx new file mode 100644 index 00000000..690ca65c --- /dev/null +++ b/packages/client/src/metricSources/InfluxDB/InfluxDBMetricModal.tsx @@ -0,0 +1,41 @@ +import * as React from 'react'; +import { AbstractMetricModal } from '../../components/config/AbstractMetricModal'; +import { INFLUXDB_SERVICE_TYPE } from '../InfluxDB/index'; +import { InlineTextGroup } from '../../layout/InlineTextGroup'; +import { validateCanaryMetricConfig } from '../../validation/configValidators'; +import { CanaryMetricConfig } from '../../domain/Kayenta'; +import { ValidationResultsWrapper } from '../../domain/Referee'; +import InfluxDBCanaryMetricSetQueryConfig from '../InfluxDB/InfluxDBCanaryMetricSetQueryConfig'; + +export default class InfluxDBMetricModal extends AbstractMetricModal { + validateCanaryMetricConfig(existingMetric: CanaryMetricConfig, type: string): ValidationResultsWrapper { + return validateCanaryMetricConfig(existingMetric, type, true); + } + + getQueryInitialState(): InfluxDBCanaryMetricSetQueryConfig { + return { + type: INFLUXDB_SERVICE_TYPE, + customInlineTemplate: '' + }; + } + + getMetricSourceSpecificJsx(): JSX.Element { + return ( +
+ { + this.touch('customInlineTemplate'); + }} + touched={this.state.touched.customInlineTemplate} + error={this.state.errors['query.customInlineTemplate']} + id="customInlineTemplate" + label="InfluxDB Query" + value={this.state.metric.query.customInlineTemplate} + onChange={e => this.updateQueryObject('customInlineTemplate', e.target.value)} + placeHolderText="SELECT field FROM measurement" + subText="Custom InfluxDB query" + /> +
+ ); + } +} diff --git a/packages/client/src/metricSources/InfluxDB/index.ts b/packages/client/src/metricSources/InfluxDB/index.ts new file mode 100644 index 00000000..efc16344 --- /dev/null +++ b/packages/client/src/metricSources/InfluxDB/index.ts @@ -0,0 +1,23 @@ +import * as React from 'react'; +import { MetricSourceIntegration } from '../MetricSourceIntegration'; +import { MetricModalProps } from '../../components/config/AbstractMetricModal'; +import InfluxDBMetricModal from './InfluxDBMetricModal'; +import InfluxDBCanaryMetricSetQueryConfig from './InfluxDBCanaryMetricSetQueryConfig'; +import { string } from 'yup'; + +export const INFLUXDB_SERVICE_TYPE: string = 'influxdb'; + +const schema = { + customInlineTemplate: string() + .trim() +}; + +const modalFactory = (props: MetricModalProps) => React.createElement(InfluxDBMetricModal, props); + +const InfluxDB: MetricSourceIntegration = { + type: INFLUXDB_SERVICE_TYPE, + createMetricsModal: modalFactory, + canaryMetricSetQueryConfigSchema: schema +}; + +export default InfluxDB; diff --git a/packages/client/src/metricSources/index.tsx b/packages/client/src/metricSources/index.tsx index 83dda469..e543f055 100644 --- a/packages/client/src/metricSources/index.tsx +++ b/packages/client/src/metricSources/index.tsx @@ -4,6 +4,7 @@ import NewRelic from './NewRelic'; import SignalFx from './SignalFx'; import Prometheus from './Prometheus'; import Datadog from './Datadog'; +import InfluxDB from './InfluxDB'; const MIN_TO_MS_CONVERSION: number = 60000; /** @@ -14,7 +15,8 @@ const enabledMetricSources: MetricSourceIntegration[ NewRelic, SignalFx, Prometheus, - Datadog + Datadog, + InfluxDB ]; /**