Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

feat: influxdb support #456

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
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-influxdb/src/main/java/com/netflix/kayenta/canary/providers/metrics/InfluxdbCanaryMetricSetQueryConfig.java}
*/
export default interface InfluxDBCanaryMetricSetQueryConfig extends CanaryMetricSetQueryConfig {
customInlineTemplate: string;
}
41 changes: 41 additions & 0 deletions packages/client/src/metricSources/InfluxDB/InfluxDBMetricModal.tsx
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 { 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<InfluxDBCanaryMetricSetQueryConfig> {
validateCanaryMetricConfig(existingMetric: CanaryMetricConfig, type: string): ValidationResultsWrapper {
return validateCanaryMetricConfig(existingMetric, type, true);
}

getQueryInitialState(): InfluxDBCanaryMetricSetQueryConfig {
return {
type: INFLUXDB_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="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"
/>
</div>
);
}
}
23 changes: 23 additions & 0 deletions packages/client/src/metricSources/InfluxDB/index.ts
Original file line number Diff line number Diff line change
@@ -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<InfluxDBCanaryMetricSetQueryConfig> = {
type: INFLUXDB_SERVICE_TYPE,
createMetricsModal: modalFactory,
canaryMetricSetQueryConfigSchema: schema
};

export default InfluxDB;
4 changes: 3 additions & 1 deletion packages/client/src/metricSources/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
/**
Expand All @@ -14,7 +15,8 @@ const enabledMetricSources: MetricSourceIntegration<CanaryMetricSetQueryConfig>[
NewRelic,
SignalFx,
Prometheus,
Datadog
Datadog,
InfluxDB
];

/**
Expand Down