Possible to use a different tag label?

Hello,

when using a group by tag(item), i get the display field_name(ITEMCODE). is it possible to give them labels (i.e. ITEMCODE 1 = internal, ITEMCODE 2 = external)? that way, the values are less cryptic.

Which data source are you using? InfluxDB? And are you talking about the graph panel legend?

Hi @daniellee – yes i’m reading from influxdb, and yes i’m referring to the graph panel legend. in a typical relational database, for example, i can join the itemcode to a itemcode table and retrieve the label. not sure if that’s possible in influxdb as i haven’t found any examples that can do this. also noted that grafana dynamically generates the query so that may not be an option as well.

so i was wondering if the data itself, once presented can be labeled. the field name i’m trying to model is the mac address, and the itemcode itself is the mac. i was able to set it to just display the mac by using the alias, but i was hoping to display “garage”, if i can associate the mac with this label.

tks.

Would it not just be easier to add an extra tag to the measurements when saving them? You could add a new tag ItemType with values “internal” and “external”.

Hi Daniel,

there are some challenges with this approach:

  1. previously captured data will not have this value and will require some kind of mass update
  2. sometimes, for display purposes, we may have have a different labelling scheme (i.e. internal label may say PUMP#4, but the display would say, Pump for Exhaust). this would make it quite onerous to keep mass updating data for various purposes
  3. it’s not end-friendly. i was planning to have a non-technical user manage the display of the graphs, and this would make training more complicated
  4. new sensors being added to the list may have initial data points missing a label, since in an auto-capture situation we may not know when a sensor is sending data out already

so, from your question, i take it that grafana does not have this functionality at this time?

tks
Lawrence

Well, it is possible (sort of) but not directly with InfluxDB as far as I know.

If you have access to one of the supported sql data sources (Mysql and Postgres), then they support mapping tags to friendlier names for template variables.

They both support this syntax:

SELECT hostname AS __text, id AS __value FROM my_host

So you could have a table with ITEMCODE X as the value and internal/external as the text.

If it is a short list then you do not even need to create a table for it:

SELECT 'internal' AS __text, 'ITEMCODE 1' AS __value UNION SELECT 'external' AS __text, 'ITEMCODE 2' AS __value

You would then use this template variable in your queries instead of the original tag.

P.S. There is a PR for InfluxDB template variables that will be merged soon that is related but probably does not help your case - https://github.com/grafana/grafana/pull/7919#issuecomment-340736497