From 3a671d407289f0c40656d496e2f5f773d4b5554b Mon Sep 17 00:00:00 2001 From: IvanessChristleChiong Date: Mon, 11 Jul 2022 12:09:12 -0500 Subject: [PATCH 1/4] feat: influxdb support --- README.md | 11 ++--- .../InfluxDBCanaryMetricSetQueryConfig.ts | 8 ++++ .../InfluxDB/InfluxDBMetricModal.tsx | 41 +++++++++++++++++++ .../src/metricSources/InfluxDB/index.ts | 23 +++++++++++ packages/client/src/metricSources/index.tsx | 10 +++-- 5 files changed, 84 insertions(+), 9 deletions(-) create mode 100644 packages/client/src/metricSources/InfluxDB/InfluxDBCanaryMetricSetQueryConfig.ts create mode 100644 packages/client/src/metricSources/InfluxDB/InfluxDBMetricModal.tsx create mode 100644 packages/client/src/metricSources/InfluxDB/index.ts diff --git a/README.md b/README.md index b61f6c83..df2f587b 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). @@ -80,11 +81,11 @@ As stated in the [main description](#referee) Referee has an express backend tha To configure how Referee talks to Kayenta you can set the following environment variable. If you do nothing Referee defaults to talking to Kayenta on http://localhost:8090, the default when running Kayenta locally. -Env Var | Default | Description ---------|---------|------------- -*KAYENTA_BASE_URL* | `http://localhost:8090` | The base URL for where Kayenta is is serving traffic -*KAYENTA_BASE_PATH* | NULL | If present this will be appended to the base URL when reverse proxying Kayenta requests, useful if want to local dev against a deployed Kayenta that is behind a reverse proxy. -*DISABLE_KAYENTA_SSL_VERIFICATION* | `false` | [A hook for self signed cert issues](https://www.npmjs.com/package/express-http-proxy#q-how-to-ignore-self-signed-certificates-) +| Env Var | Default | Description | +| ---------------------------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| *KAYENTA_BASE_URL* | `http://localhost:8090` | The base URL for where Kayenta is is serving traffic | +| *KAYENTA_BASE_PATH* | NULL | If present this will be appended to the base URL when reverse proxying Kayenta requests, useful if want to local dev against a deployed Kayenta that is behind a reverse proxy. | +| *DISABLE_KAYENTA_SSL_VERIFICATION* | `false` | [A hook for self signed cert issues](https://www.npmjs.com/package/express-http-proxy#q-how-to-ignore-self-signed-certificates-) | ### bootstrap the project 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..45148d39 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 ]; /** @@ -23,9 +25,9 @@ const enabledMetricSources: MetricSourceIntegration[ // prettier-ignore export const metricSourceIntegrations: () => KvMap> = () => { return enabledMetricSources.reduce((result, metricsSource) => { - result[metricsSource.type] = metricsSource; - return result; - }, + result[metricsSource.type] = metricsSource; + return result; + }, {} as KvMap> ); }; From 0e53d4118d1c51946cbbda1ac423eb1023f44c65 Mon Sep 17 00:00:00 2001 From: IvanessChristleChiong Date: Mon, 11 Jul 2022 12:20:32 -0500 Subject: [PATCH 2/4] revert changes to readme --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index df2f587b..9a29ff23 100644 --- a/README.md +++ b/README.md @@ -81,11 +81,11 @@ As stated in the [main description](#referee) Referee has an express backend tha To configure how Referee talks to Kayenta you can set the following environment variable. If you do nothing Referee defaults to talking to Kayenta on http://localhost:8090, the default when running Kayenta locally. -| Env Var | Default | Description | -| ---------------------------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| *KAYENTA_BASE_URL* | `http://localhost:8090` | The base URL for where Kayenta is is serving traffic | -| *KAYENTA_BASE_PATH* | NULL | If present this will be appended to the base URL when reverse proxying Kayenta requests, useful if want to local dev against a deployed Kayenta that is behind a reverse proxy. | -| *DISABLE_KAYENTA_SSL_VERIFICATION* | `false` | [A hook for self signed cert issues](https://www.npmjs.com/package/express-http-proxy#q-how-to-ignore-self-signed-certificates-) | +Env Var | Default | Description +--------|---------|------------- +*KAYENTA_BASE_URL* | `http://localhost:8090` | The base URL for where Kayenta is is serving traffic +*KAYENTA_BASE_PATH* | NULL | If present this will be appended to the base URL when reverse proxying Kayenta requests, useful if want to local dev against a deployed Kayenta that is behind a reverse proxy. +*DISABLE_KAYENTA_SSL_VERIFICATION* | `false` | [A hook for self signed cert issues](https://www.npmjs.com/package/express-http-proxy#q-how-to-ignore-self-signed-certificates-) | ### bootstrap the project From 62432f3a13b0bf43d89453c80e671bd06c2285e6 Mon Sep 17 00:00:00 2001 From: IvanessChristleChiong Date: Mon, 11 Jul 2022 23:04:53 -0500 Subject: [PATCH 3/4] revert unnecessary changes --- README.md | 10 +++++----- packages/client/src/metricSources/index.tsx | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 9a29ff23..f1108e4c 100644 --- a/README.md +++ b/README.md @@ -81,11 +81,11 @@ As stated in the [main description](#referee) Referee has an express backend tha To configure how Referee talks to Kayenta you can set the following environment variable. If you do nothing Referee defaults to talking to Kayenta on http://localhost:8090, the default when running Kayenta locally. -Env Var | Default | Description ---------|---------|------------- -*KAYENTA_BASE_URL* | `http://localhost:8090` | The base URL for where Kayenta is is serving traffic -*KAYENTA_BASE_PATH* | NULL | If present this will be appended to the base URL when reverse proxying Kayenta requests, useful if want to local dev against a deployed Kayenta that is behind a reverse proxy. -*DISABLE_KAYENTA_SSL_VERIFICATION* | `false` | [A hook for self signed cert issues](https://www.npmjs.com/package/express-http-proxy#q-how-to-ignore-self-signed-certificates-) | +| Env Var | Default | Description | +| ---------------------------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| *KAYENTA_BASE_URL* | `http://localhost:8090` | The base URL for where Kayenta is is serving traffic | +| *KAYENTA_BASE_PATH* | NULL | If present this will be appended to the base URL when reverse proxying Kayenta requests, useful if want to local dev against a deployed Kayenta that is behind a reverse proxy. | +| *DISABLE_KAYENTA_SSL_VERIFICATION* | `false` | [A hook for self signed cert issues](https://www.npmjs.com/package/express-http-proxy#q-how-to-ignore-self-signed-certificates-) ### bootstrap the project diff --git a/packages/client/src/metricSources/index.tsx b/packages/client/src/metricSources/index.tsx index 45148d39..e543f055 100644 --- a/packages/client/src/metricSources/index.tsx +++ b/packages/client/src/metricSources/index.tsx @@ -25,9 +25,9 @@ const enabledMetricSources: MetricSourceIntegration[ // prettier-ignore export const metricSourceIntegrations: () => KvMap> = () => { return enabledMetricSources.reduce((result, metricsSource) => { - result[metricsSource.type] = metricsSource; - return result; - }, + result[metricsSource.type] = metricsSource; + return result; + }, {} as KvMap> ); }; From d3e7861825c512791ff736b3f0194f5c0af2c24c Mon Sep 17 00:00:00 2001 From: IvanessChristleChiong Date: Mon, 11 Jul 2022 23:06:15 -0500 Subject: [PATCH 4/4] revert unnecessary changes to readme --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f1108e4c..d2354eb6 100644 --- a/README.md +++ b/README.md @@ -81,11 +81,11 @@ As stated in the [main description](#referee) Referee has an express backend tha To configure how Referee talks to Kayenta you can set the following environment variable. If you do nothing Referee defaults to talking to Kayenta on http://localhost:8090, the default when running Kayenta locally. -| Env Var | Default | Description | -| ---------------------------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| *KAYENTA_BASE_URL* | `http://localhost:8090` | The base URL for where Kayenta is is serving traffic | -| *KAYENTA_BASE_PATH* | NULL | If present this will be appended to the base URL when reverse proxying Kayenta requests, useful if want to local dev against a deployed Kayenta that is behind a reverse proxy. | -| *DISABLE_KAYENTA_SSL_VERIFICATION* | `false` | [A hook for self signed cert issues](https://www.npmjs.com/package/express-http-proxy#q-how-to-ignore-self-signed-certificates-) +Env Var | Default | Description +--------|---------|------------- +*KAYENTA_BASE_URL* | `http://localhost:8090` | The base URL for where Kayenta is is serving traffic +*KAYENTA_BASE_PATH* | NULL | If present this will be appended to the base URL when reverse proxying Kayenta requests, useful if want to local dev against a deployed Kayenta that is behind a reverse proxy. +*DISABLE_KAYENTA_SSL_VERIFICATION* | `false` | [A hook for self signed cert issues](https://www.npmjs.com/package/express-http-proxy#q-how-to-ignore-self-signed-certificates-) ### bootstrap the project