Incorrect Count from different queries after merge

Hello,

I’m running Grafana 8.4.7 with a Prometheus Database and cannot find a way to have count values of different queries in the same table dashboard.

I have three queries reporting ports status from switches :

  1. Reserved ports (admin status DOWN - value = 0 & label ‘description’ isnt empty)
  2. Active ports (admin status UP - value = 1)
  3. Total ports (Number of ports, regardless of status)

As long as I’m not merging, data from the three queries will be counted as expected, while on merged counters are incorrect

It seems to be caused by the fact that after a merge, the array is filled with ‘undefined value’ for every ports regardless of the query and is then counted

Is there a way to ignore those ‘undefined’ values from being counted, or any other method to have count from different queries in the same table ?

BR

In that last screenshot I’m seeing six transformations. Is it possible to inspect your raw data so others can try ad mock this up?

Can you use the Grafana Inspector panel to share your data?

Hello Matt,

Thank you for taking a look into this issue :slight_smile:

You’ll find below the data from the Data-Inspector, filtered on a single node to avoid too much data and description anonymised.

Total

Time	__name__	descr	fabric	interface	job	nodeid	podid	portT	Value #Total_Ports
2022-06-28 11:02:36.823	aci_interface_admin_state	xxxxxxxxxxxx	Fabric	eth1/7	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state	xxxxxxxxxxxx	Fabric	eth1/8	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state	xxxxxxxxxxxx	Fabric	eth1/24	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state	xxxxxxxxxxxx	Fabric	eth1/25	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state	xxxxxxxxxxxx	Fabric	eth1/26	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state	xxxxxxxxxxxx	Fabric	eth1/20	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state	xxxxxxxxxxxx	Fabric	eth1/21	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state	xxxxxxxxxxxx	Fabric	eth1/22	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state	xxxxxxxxxxxx	Fabric	eth1/23	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state	xxxxxxxxxxxx	Fabric	eth1/2	ACI-1h	101	1	leaf	1
2022-06-28 11:02:36.823	aci_interface_admin_state	xxxxxxxxxxxx	Fabric	eth1/53	ACI-1h	101	1	fab	1
2022-06-28 11:02:36.823	aci_interface_admin_state	xxxxxxxxxxxx	Fabric	eth1/54	ACI-1h	101	1	fab	1
2022-06-28 11:02:36.823	aci_interface_admin_state	xxxxxxxxxxxx	Fabric	eth1/3	ACI-1h	101	1	leaf	1
2022-06-28 11:02:36.823	aci_interface_admin_state	xxxxxxxxxxxx	Fabric	eth1/1	ACI-1h	101	1	leaf	1
2022-06-28 11:02:36.823	aci_interface_admin_state	xxxxxxxxxxxx	Fabric	eth1/51	ACI-1h	101	1	leaf	1
2022-06-28 11:02:36.823	aci_interface_admin_state	xxxxxxxxxxxx	Fabric	eth1/52	ACI-1h	101	1	leaf	1
2022-06-28 11:02:36.823	aci_interface_admin_state		Fabric	eth1/10	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state		Fabric	eth1/11	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state		Fabric	eth1/12	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state		Fabric	eth1/13	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state		Fabric	eth1/14	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state		Fabric	eth1/15	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state		Fabric	eth1/16	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state		Fabric	eth1/17	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state		Fabric	eth1/18	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state		Fabric	eth1/19	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state		Fabric	eth1/27	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state		Fabric	eth1/28	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state		Fabric	eth1/29	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state		Fabric	eth1/30	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state		Fabric	eth1/31	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state		Fabric	eth1/32	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state		Fabric	eth1/33	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state		Fabric	eth1/34	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state		Fabric	eth1/35	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state		Fabric	eth1/36	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state		Fabric	eth1/37	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state		Fabric	eth1/38	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state		Fabric	eth1/39	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state		Fabric	eth1/4	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state		Fabric	eth1/40	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state		Fabric	eth1/41	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state		Fabric	eth1/42	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state		Fabric	eth1/43	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state		Fabric	eth1/44	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state		Fabric	eth1/45	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state		Fabric	eth1/46	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state		Fabric	eth1/47	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state		Fabric	eth1/48	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state		Fabric	eth1/49	ACI-1h	101	1	fab	0
2022-06-28 11:02:36.823	aci_interface_admin_state		Fabric	eth1/5	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state		Fabric	eth1/50	ACI-1h	101	1	fab	0
2022-06-28 11:02:36.823	aci_interface_admin_state		Fabric	eth1/6	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state		Fabric	eth1/9	ACI-1h	101	1	leaf	0

Active

Time	__name__	descr	fabric	interface	job	nodeid	podid	portT	Value #Active_Ports
2022-06-28 11:02:36.823	aci_interface_admin_state	xxxxxxxxxxxx	Fabric	eth1/2	ACI-1h	101	1	leaf	1
2022-06-28 11:02:36.823	aci_interface_admin_state	xxxxxxxxxxxx	Fabric	eth1/53	ACI-1h	101	1	fab	1
2022-06-28 11:02:36.823	aci_interface_admin_state	xxxxxxxxxxxx	Fabric	eth1/54	ACI-1h	101	1	fab	1
2022-06-28 11:02:36.823	aci_interface_admin_state	xxxxxxxxxxxx	Fabric	eth1/3	ACI-1h	101	1	leaf	1
2022-06-28 11:02:36.823	aci_interface_admin_state	xxxxxxxxxxxx	Fabric	eth1/1	ACI-1h	101	1	leaf	1
2022-06-28 11:02:36.823	aci_interface_admin_state	xxxxxxxxxxxx	Fabric	eth1/51	ACI-1h	101	1	leaf	1
2022-06-28 11:02:36.823	aci_interface_admin_state	xxxxxxxxxxxx	Fabric	eth1/52	ACI-1h	101	1	leaf	1


Reserved

Time	__name__	descr	fabric	interface	job	nodeid	podid	portT	Value #Reserved_Ports
2022-06-28 11:02:36.823	aci_interface_admin_state	xxxxxxxxxxxx	Fabric	eth1/7	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state	xxxxxxxxxxxx	Fabric	eth1/8	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state	xxxxxxxxxxxx	Fabric	eth1/24	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state	xxxxxxxxxxxx	Fabric	eth1/25	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state	xxxxxxxxxxxx	Fabric	eth1/26	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state	xxxxxxxxxxxx	Fabric	eth1/20	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state	xxxxxxxxxxxx	Fabric	eth1/21	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state	xxxxxxxxxxxx	Fabric	eth1/22	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state	xxxxxxxxxxxx	Fabric	eth1/23	ACI-1h	101	1	leaf	0
2022-06-28 11:02:36.823	aci_interface_admin_state	xxxxxxxxxxxx	Fabric	eth1/2	ACI-1h	101	1	leaf	1
2022-06-28 11:02:36.823	aci_interface_admin_state	xxxxxxxxxxxx	Fabric	eth1/53	ACI-1h	101	1	fab	1
2022-06-28 11:02:36.823	aci_interface_admin_state	xxxxxxxxxxxx	Fabric	eth1/54	ACI-1h	101	1	fab	1
2022-06-28 11:02:36.823	aci_interface_admin_state	xxxxxxxxxxxx	Fabric	eth1/3	ACI-1h	101	1	leaf	1
2022-06-28 11:02:36.823	aci_interface_admin_state	xxxxxxxxxxxx	Fabric	eth1/1	ACI-1h	101	1	leaf	1
2022-06-28 11:02:36.823	aci_interface_admin_state	xxxxxxxxxxxx	Fabric	eth1/51	ACI-1h	101	1	leaf	1
2022-06-28 11:02:36.823	aci_interface_admin_state	xxxxxxxxxxxx	Fabric	eth1/52	ACI-1h	101	1	leaf	1

I’ve find a way to have the expected values in a single table by using ‘outer join’ transformation on ‘fabric’ label instead of ‘merge’ transformation, but I have to filter out a bunch of fields.
There might be a better way to do it !

BR

1 Like