How to choose field name? (Hide attributes provided by InfluxDB/Telegraf

  • What Grafana version and what operating system are you using?
    I am using the latest version of the free Grafana Enteprise

  • What are you trying to achieve?
    I am trying to display memory usage statistics provided from an InfluxDB OSS 2.7 bucket, generated by a telegraf agent running the docker input plugin

  • How are you trying to achieve it?
    Using the following Query:

fields = ["usage", ]
from(bucket: "MyBucket")
  |> range(start: v.timeRangeStart, stop:v.timeRangeStop)
  |> filter(fn: (r) =>
    r.host == "${Host}" and
    r._measurement == "docker_container_mem" and
    contains(value: r.container_name, set:[${Containers:csv}]) and
    contains(value: r._field, set:fields)
  )
  • What happened?
    The data appears as expected, but the graph is hard to read due to all the tags/attributes attached to the field names. Eg, instead of one set of data being named:
    usage {container_name="MyContainer"}
    it appears as
    usage {com.docker.compose.config-hash="0ca69f9d7b39dacd8a57fb449181740e7bdd2f86ca17a0460b3caa49e4ccce19", com.docker.compose.container-number="1", com.docker.compose.oneoff="False", com.docker.compose.project="MyProject", com.docker.compose.service="MyService", com.docker.compose.version="1.24.1", container_image="MyImage", container_name="MyContainerName", container_status="running", container_version="unknown", engine_host="MyHost", host="MyHost", server_version="19.03.3"}

  • What did you expect to happen?
    I would like the legend and mouse-over tooltip to simply display usage {container_name="MyContainer"} for each of the containers.

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

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

  • Did you follow any online instructions? If so, what is the URL?
    No

Welcome @samwcoulter

Which visualization are you using?

@yosiasz Time Series

I was able to solve my issue by adding the following to the end of my Query:

  |> group(columns: ["_field", "container_name", "host"])
  |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)

I don’t know why the aggregateWindow is needed, but the data doesn’t display properly without it.

1 Like

Hi, i got the same issue this morning, thank you for the tips.
Did you manage to remove the "usage " ?

@juliendzk

Yes, reduce the group command to:

|> group(columns: ["container_name"])