InfluxDB Alias by other Column value

Hi,

using Icinga2, InfluxDB, Grafana setup. We are monitoring some Dell switches using SNMP and the output is stored in InfluxDB. Because one switch can have more fans, I want be able to display all fans in one graph. Right now I am playing with status only.

The problem. The data structure in DB looks like this:

time			hostname		metric					service	value
----			--------		------					-------	-----
1542725873000000000	dell-powerconnect-2824	iso.3.6.1.4.1.89.83.1.1.1.3.67109249	fan 1	1

Value is stored in value and the meaning for the value is stored in service column. I am looking for way to display the value with service as a legend to the graph (marked with red on the screenshot).

Thanks in advice, Ondrej

You should be able to add a group by tag_service, and in the alias reference the tag like this:
ALIAS BY FAN $tag_service

You can reference other tags the same way within the alias:

ALIAS BY $tag_hostname FAN $tag_service

(this is unique to the influx datasource, other datasource have different syntax or don’t support this at all)

1 Like

I am not sure I understand you well, because I think a lack the terminology here (whoops). By tag you mean a column, field? Or is “tag” something that’s has to be setted up in Grafana?

Copy-pasting did not work for me :smile:

Tag would be the same as a “field” for influxdb. You’re query would need to be modified to have a group by that includes the tags(fields) you want to reference.

the group by would look like this:

GROUP BY time($__interval), "service" "hostname" fill(previous)

1 Like

Thanks it’s now working.

SELECT mean("value") FROM "snmp" WHERE ("hostname" =~ /^$hostname$/ AND "service" =~ /^fan [0-9]+$/) AND $timeFilter GROUP BY time($__interval), "service", "hostname" fill(previous)

It’s sort of logic :slight_smile: The query before had no clue about services. Well space to grow, thanks