Telegraf Inbound Plugin doesn't reset stats


Dispite the unbound.conf file set to

Unbound Statistics
statistics-interval: 0
extended-statistics: yes
statistics-cumulative: no

the plug doesn’t respect the non cumulative set and therefore, doesn’t work well with influx. How can I solve it ?

You can use the non_negative_derivative function in InfluxQL to convert a non-resetting counter to a rate.


Thanks, I tried and it solves it partially.

I don’t know, but I think that Telegraf unbound plugin should use stats and not stats_noreset. What is the expected behavior ?

Generally we prefer non-resetting counters. While the raw data of the resetting counters (aka rates) are easier to look at directly, they are often more complicated to collect, a bit less precise, don’t handle service outages as well, and introduce a time unit to the counts which can make aggregation trickier.

I see, so would you give me a help on how to get the total number of queries within one hour ?

I think this will give you what you want:

select non_negative_difference(last(total_num_queries)) as total_num_queries from unbound where time > now() - 6h group by time(1h)


I’m still struggling with the fact it is cumulative. After a restart of the unbound, its counter return to zero. So a query like this
SELECT last(“total_num_queries”) FROM “unbound” WHERE timeFilter GROUP BY time(__interval)
and the interval is last 1 hr it gives me No data as result.
First, why no data ? There is data, but the last is smaller than the first, is that why ?
Second, if I ask for last 24 h instead of 1h, it provide me a figure, but it doesn’t seem correct because it doesn’t increase.
I’m now looking for a counter of the amount of queries since last reset.

I’m not sure why you don’t get data there, the query doesn’t use non_negative_difference so it shouldn’t matter what the first value is. I’m not much of a query expert though so maybe someone reading will let us know.

With both types of counters resets are an issue, and with cumulative counters you will also will run into wrap-around resets. This is usually less of an issue when looking at smaller time intervals.

With the query I provided we only get one point per hour, I think we can minimize the reset time effect if we look at finer time interval differences and then sum the results. This assumes that Telegraf is running the unbound plugin more than once an hour.

select sum(*) as total_num_queries_per_hour from (select non_negative_difference(last(total_num_queries))  from unbound where time > now() - 5d group by time(1m)) group by time(1h)