Skip to content

feat: Added support for Monitoring & Alerting#64

Merged
bednar merged 3 commits intomasterfrom
monitoring-alerting
Oct 8, 2019
Merged

feat: Added support for Monitoring & Alerting#64
bednar merged 3 commits intomasterfrom
monitoring-alerting

Conversation

@bednar
Copy link
Copy Markdown
Contributor

@bednar bednar commented Oct 8, 2019

Closes #59

Monitoring & Alerting

The example below show how to create a check for monitoring a stock price. A Slack notification is created if the price is lesser than 35.

Create Threshold Check

The Check set status to Critical if the current value for a stock measurement is lesser than 35.

Organization org = ...;
String query = "from(bucket: \"my-bucket\") "
        + "|> range(start: v.timeRangeStart, stop: v.timeRangeStop)  "
        + "|> filter(fn: (r) => r._measurement == \"stock\")  "
        + "|> filter(fn: (r) => r.company == \"zyz\")  "
        + "|> aggregateWindow(every: 5s, fn: mean)  "
        + "|> yield(name: \"mean\")";
LesserThreshold threshold = new LesserThreshold();
threshold.setLevel(CheckStatusLevel.CRIT);
threshold.setValue(35F);
String message = "The Stock price for XYZ is on: ${ r._level } level!";
influxDBClient
    .getChecksApi()
    .createThresholdCheck("XYZ Stock value", query, "current", "5s", message, threshold, org.getId());
Create Slack Notification endpoint
String url = "https://hooks.slack.com/services/x/y/z";   
SlackNotificationEndpoint endpoint = influxDBClient
    .getNotificationEndpointsApi()
    .createSlackEndpoint("Slack Endpoint", url, org.getId());
Create Notification Rule
influxDBClient
    .getNotificationRulesApi()
    .createSlackRule("Critical status to Slack", "10s", "${ r._message }", RuleStatusLevel.CRIT, endpoint, org.getId());
  • CHANGELOG.md updated
  • Rebased/mergeable
  • Tests pass
  • Sign CLA (if not already signed)

@bednar bednar added the enhancement New feature or request label Oct 8, 2019
@bednar bednar added this to the 1.1.0 milestone Oct 8, 2019
@bednar bednar merged commit b89c5e8 into master Oct 8, 2019
@bednar bednar deleted the monitoring-alerting branch October 8, 2019 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for Monitoring & Alerting

1 participant