GoshPosh / grafana-meta-queries

Grafana plugin for calculating time period metrics like week over week, month over month and year over year etc.
Apache License 2.0
283 stars 71 forks source link

Metaqueries works incorrect with metrics from Zabbix datasource #92

Closed SergeyRim closed 4 years ago

SergeyRim commented 4 years ago

Hello. I have a Grafana v6.6.1 with Zabbix plugin.

For example I have added 2 metrics from zabbix datasource: "Number of packets received on interface Network adapter 1" for 2 different hosts (metric A and metric B). Then I added an arithmetic metaqueries metric. The behaivor is: No matter if I put A['Number of packets received on interface Network adapter 1'] or B['Number of packets received on interface Network adapter 1'] to the expression, it always show me a A['Number of packets received on interface Network adapter 1'] value. Screenshot_2

If I change an expression to A['Number of packets received on interface Network adapter 1']+B['Number of packets received on interface Network adapter 1'], it will calculate B+B. Screenshot_3

I have verified with a different metrics and expressions, and always metaqueries metric shows an incorrect result ( and sometime just shows an empty value without any errors displayed).

Gauravshah commented 4 years ago

@SergeyRim I think the best way would be to debug via doing a console.log(A) in the expression box to verify what is showing up there. I am unsure if grafana or zabbix is shifting A vs B

vicioussn commented 4 years ago

Same issue for me

Gauravshah commented 4 years ago

@vicioussn did you try debugging?

apoorva-marisomaradhya commented 4 years ago

@Gauravshah Hey, does this plugin work with grafana v6.7 and above? I am trying to get this work with v6.7.1 and MetaQuery plugin doesn't endup showing any data.

Gauravshah commented 4 years ago

@apoorva-marisomaradhya can you open a separate issue we can discuss there. also do paste a screenshot of your dashboard config

SergeyRim commented 4 years ago

Sorry for late response. My issue is very easy to reproduce. Screenshot_4

I will investigate more and back with a results soon.

SergeyRim commented 4 years ago

Debugging shows that calculation is correct, but the graph looks very ugly. So the issue is in the graph itself? Screenshot_5

Gauravshah commented 4 years ago

so we are one step forward now. You can convert your graph to table . That will help understand data better. Looks to me that there is a null on either A or B and non-null on the other side hence the sum is throwing as NAN. Once you confirm it via table you can write some javascript safety check. (A['number_of....'].isNaN()? 0 : A['number_of....'] something like that should take care of exceptions in data

SergeyRim commented 4 years ago

I have converted graph to table and now can see the issue. Data for A and B has different timestamps. So how to use MetaQueries in this case? Screenshot_6

Gauravshah commented 4 years ago

you might want to set some granularity on your A source so that it is grouped by the same time as the other one. I do not know how otherwise can Metaqueries do the summation.

SergeyRim commented 4 years ago

This is how zabbix collects data. The previous screenshot was from esxi stats collected by zabbix, here is a snmp stats collected from router by zabbix. The main problem is the same - different timestamps. I'm really not sure that I can influence on this. Screenshot_7

Gauravshah commented 4 years ago

@SergeyRim I am not sure how to do that on zabbix, but unless we get the time granularity to be similar across columns there is no way metaqueries will be able to apply any operation

Gauravshah commented 4 years ago

closing this one as its not related to metaqueries