Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise alert on same measurement but different tags #1194

Open
AlexGrs opened this issue Feb 13, 2017 · 0 comments
Open

Raise alert on same measurement but different tags #1194

AlexGrs opened this issue Feb 13, 2017 · 0 comments

Comments

@AlexGrs
Copy link

AlexGrs commented Feb 13, 2017

Description
I have a measurement which looks like this:

name: test
tags: status = (ok | nok)
field: number (int)

I need to raise an alert when the failure rate nok / (ok+nok) is > Z%
.

I first tried with batch using the following syntax:

var influx_query = 'SELECT count(number) AS count from "test"."autogen"."test"'
status=\'failed\''
var total_failed_query = 'SELECT count(number) AS failed_count from "test"."autogen"."test" WHERE status=\'failed\''

var total = batch
  |query(influx_query)
    .period(5m)
    .every(1m)
    .fill('none')

var failed = batch
  |query(total_failed_query)
    .period(period)
    .every(every)
    .fill(0)

failed
  |join(total)
    .as('failed','success')
    .tolerance(5m)
    .fill(0)
 |eval(lambda: "failed.failed_count" / "total.count")
   .as('failure_rate')
|alert()
  .id('kapacitor_test')
  .warn(...)

The thing is, when the query 2 is executed, it happens there are no point with status at failed . Due to this influxdb issue, fill(0) returns no points causing the join() to never be evaluated.

As a result, if I was in warning mode and all new point have status at success I will never go back in normal level because the join() will not be triggered.

Do you have any recommendations to solve this kind of problem ? Is it possible to perform it in one query using groupBy ? (I tried also but failed as there is still no point for the failed tag).

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants