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

consolidateBy(sum) does not work correctly (Direct DB Connection) #603

Closed
2 tasks
kompa3 opened this issue Jul 26, 2018 · 0 comments · Fixed by #604
Closed
2 tasks

consolidateBy(sum) does not work correctly (Direct DB Connection) #603

kompa3 opened this issue Jul 26, 2018 · 0 comments · Fixed by #604

Comments

@kompa3
Copy link
Contributor

kompa3 commented Jul 26, 2018

I'm submitting a ...

  • [ X ] Bug report
  • Feature requestdd
  • Question / Support request

For bug report please include this information:

Software Versions

Grafana Zabbix Grafana-Zabbix Plugin
4.6.2 3.4.3 3.9.0

What did you do?

The function consolidateBy(sum) should calculate sum over the data points returned from Zabbix database to Grafana. It works well when querying from history tables (time range being less than the Range setting in plugin settings) but calculates invalid values when querying from trends (from longer time ranges).

image

The produced SQL query can be debugged in network traffic:

SELECT itemid AS metric, clock DIV 7200 * 7200 AS time_sec, SUM(value_avg) AS value FROM trends_uint WHERE itemid IN (282744, 282835) AND clock > 1531999580 AND clock < 1532604380 GROUP BY clock DIV 7200 * 7200, metric ORDER BY time_sec ASC

The query shows that Zabbix plugin actually sums up the average values from trends_uint table, meaning that it sums up one-hour averages instead of summing up the actual data inside those one-hour trend periods.

Zabbix trend tables do have the capability to get the sum of actual data inside the one-hour period. Zabbix stores the number of datapoints inside the one-hour trend period into num field and the average value in value_avg field, meaning that the sum of values inside the one-hour trend period can be acquired by num*value_avg.

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

Successfully merging a pull request may close this issue.

2 participants