What is the meaning of Alert query(A, 10s, now)?

I want to define an alert for a specific graph.

E.g.

Condition
When last() of query (A,10s, now) is above 100

A -> is the Metric A
10s -> ??? Measured for the last 10 seconds ?
now -> ??? until now ?

The official Grafana documentation did not explain this point.

I configured a Alert Rule and I expect that the alert is triggered because the value exceeds.

But the firing keeps on false.

yes, the query(A, 10s, now) , means execute query A with time range from: 10s ago, to: now.

When you test the rule you can see the response from your metric query, in your case it returns no series. Try expanding the time range from 10s to 1m, maybe that will help.

I have expanded the time range to 5 minutes.

Then beside Metric A, I have created the same Metric B.
Metric A uses Template Variables and Metric B does not use Template Variables.

Then I have also created a second Alert Rule, that works for Metric B.

Here the result when I test for Metric A:

There is no data.

Now I test for Metric B:

Sorry, new users can only put 2 images in a post.

There are several data points.
Even if all points are above 100. The Alert is no fired - keeps on false.

Now I test AGAIN for Metric B:

You cannot use template variables in alerting queries, there is a big red alert notice in your first screenshot that informs you about this :slight_smile:

1 Like

Yes, okay
But did you seen that the second Alert rule DOES NOT use a Template Variables in the Metric ?
And nevertheless it did not trigger the alert ?

Yes, and as you can see in your screenshot of the Test Rule results your query returns only null values.

Here is the corresponding chart and Metric B:

As you can see, there is of course real data that paints the chart.

So the result of the TEST Alert button does not correspond to the
result coming from the same Metric seen as chart. A bug ?

Yes bu [quote=“skirsten, post:8, topic:858”]
So the result of the TEST Alert button does not correspond to the
result coming from the same Metric seen as chart. A bug ?
[/quote]

Not likely. It probably just a matter of your query and the time range. Looks like you have no data for the last 2 minutes. Try increasing time range.

Your query is missing a group time time, this is very import to have otherwise if you zoom out your query can return millions of data points and hang the browser .

At now I don’t have so much source data points, I have started the data collection 2 days before.
And the browser did not hang.

I have tried a lot of combination, but there are always NULL datapoints in the TEST Alert button.


AND ALERT

OR by count()

AND ALERT


The firing says true, but the alert is nevertheless not triggered.
Again : A Bug ?

1 Like

OR by mean()

There are no datapoints !

When I check in the influxdb log, I see this query :

SELECT mean(value) FROM mydb."4weeks".BASIC_STATS WHERE cluster = 'fra-prod-cluster-01' AND node = 'fra-prod-cluster-01-2' AND counter_name = 'Total_Ops_s' AND time > 1494396957926ms AND time < 1494411357926ms GROUP BY time(5m)

When I paste this query in the influx command line:
*ERR: unsupported mean iterator type: influxql.stringInterruptIterator

May be this is the reason why I don’t get data points ?

I’ve found the reason.
The datatype was set to STRING, as I changed the type to INTEGER , the influxdb aggregate functions are working and then the alerting was also working.

Hi Skirsten, where did you change the datatype please?

–edit–

Resolved, I needed to change my data type when writing to InfluxDB (gathering data with EasySNMP)

Then the do the last() values should be above 100 for 10s backwards from now to trigger the alert?

is possible if the condition time is higher than evaluate time?