Table with multiple queries result on same row

  • What Grafana version and what operating system are you using?
    grafana-server --version
    Version 9.5.20
    Debian 12
  • What are you trying to achieve?
    image

The result on the picture for all of my interfaces

ifOperStatus{job=“sw1”} query and ifLastChange{job=“sw1”} query values to be on same line for but in two different columns for all of the interfaces

  • How are you trying to achieve it?
    Using combination of transforms but i do not know which ones

  • What happened?

  • What did you expect to happen?

  • Can you copy/paste the configuration(s) that you are having problems with?

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.

  • Did you follow any online instructions? If so, what is the URL?
    many different sources but nothing useful

How my metrics and values looks like in prometheus
ifLastChange{ifAlias=“”,ifDescr=“GigabitEthernet1/0/19”,ifIndex=“19”,ifName=“gi1/0/19”,sysName=“”} 2.53988188e+08

ifOperStatus{ifAlias=“”,ifDescr=“GigabitEthernet1/0/19”,ifIndex=“19”,ifName=“gi1/0/19”,sysName=“”} 2

Hi,

I think you could use following sequence of transformations (in order):

  1. Reduce
    This transformation will cause all of your result series to flat into single table (even from multiple queries). Note that default calculation is set to Max - if you’re using query of type instant calculation won’t change anything but if not - choose your calculation wisely (you’d probably be interested in Last or something like that). I also like to toggle Labels to fields.

  2. (Optional) Organize fields by name
    Reduce transformation might leave some mess you don’t want to display (like ifIndex, ifDescr, sysName). With this transformation you can toggle visibility of those fields.

  3. Grouping to Matrix
    Here, you can, as the name suggest, group the values into column / row matrix. For column, you’ll want to use __name__ of your metric, for row - ifName (name of your interface, if I read that correctly), for cell value - the value calculated from Reduce (transformation in step 1). With a bit of luck (on my side :smile:), you’d get what you want.

Perhaps, you might also want to use Fields Override with Value Mappings to change the value of ifOperStatus to more descriptive name (in your screen, there are up and down statuses).

Screen of my configuration below:

(don’t mind le label - treat it like your ifName label - I don’t have your metrics, I just used some prometheus function to change the name of my metrics). Also, if you don’t like the le\__name__ title of the most left column, you can use another organize fields transformation to change it.

Hope that helps!


Those are my queryies


And this is what is happening after i use some of your guidance



See how oper status and last change are on a same column also their values too.
First im seeing operstatus than iflastchange.

Notice that everything else is duplicating, because is not murged

This is how it should looks like ( if you want i can make better picture later )


When i am using those filters it starts to looks good, but the problem persists

On the metric side i have same information (switch ports 48) 2 times so basically i have 96 lines and 48 of them are for query A with values from query A and the other 48 are from query B with values from query B

I think you forgot about Grouping to Matrix which does the magic of creating columns from the names of the metric :smile: without it, it won’t work :smile:


Oh am :smiley: This is the result
Name of the rows and columns are the name of the ports and only shows values from one of the queryes the ( b one i guess ) :smiley:
How to make table to be with 3 columns only having name of the interfaces at left and values from the query a and b at the right side

Any help please

Right now you have both Column and Row set to the Metric field. Those two need to differ. Can you please remove Series to rows transformation, and use all three of the transformations: Reduce, Organize Fields, and Group to Matrix (they all need to be applied at the same time in the order provided)? In Group to Matrix transformation pick ifName as column and __name__ as row (or reverse that meaning ifName in row and __name__ as column). That should do the trick.


Am now this is the end result :smiley:

On the left side where are the name of interfaces, everything looks good!
But now every value has its won column ^^

You need to obtain the labels from your metric by toggling Labels to fields
image
Then you’ll have many more fields to choose from in Grouping to matrix. Column should be one of those fields (now you told Grafana to create a column out of Max field, so that’s why every value has its own column)