Color by field name

Got it. Thanks. I am not able to throw this into my InfluxDB at the moment, but I did think of this…can you just change the color of each item on the legend to the same color? Just click on the colored bar in the legend and pick a color? Or is that not the issue? I suppose you could use Overrides in Grafana as well.
image

Yes, that was my first idea. But the number of the sensors are not fixed. I suppose there is a fixed number of colors in grafana, so that the first sensor always have the color A, the second one is B, etc. This is fine because each sensor position will have the same color. But when I use the extra tag ‘block’, this order can not be maintaned.

@grant2, Do you have any idea to move on?

Hi @danielvamos

Sorry for the delay. Does creating an Override like this help apply the color to each “block”? I guess this assumes all the values are being returned by the same Query A.

1 Like

Hello,

In your suggestion, I have only one series.
image

But for my only query called A has multiple series due to the number of tags used. Each of which as name field. How can I assign same color for each series where tag name ‘name’ has the same value?

Thank you!

What are the tag names?

Hello,

My goal is to provide a single color for each series where the name tag has the same value, as noted above.
For example: the value of the name tag: Series 1 occured in multiple series, but each series has different color due to the group() fulx function and the default nature of coloring in grafana.

Here are my tags:

Using multiple columns in group function, I can visually separate series of points belong to one common tag so that I need to keep this tag in group function. When I apply the group function only for name, the coloring is OK, but all line-segments are connected, which is not good for me.

Is there any override function to keep the line segments separated, but provide single color for a given series where name tags are the same?
Maybe:

  • fields returned by query
  • fields with names matching regex

But I cant make it work with none of these.
Thank you for your help!

Have you experimented with this to see if it helps to keep the line segments separated?
image

Hello!
There is no null value in my query result, so that this option does not have any effect. I am not using aggregate window either.

Any idea?

What does the above query look like when run in Influx Data Explorer with the toggle selected to show raw data? If you can also remove the |> group line from your query and share that screenshot as well, that will help me and others see the shape of your data being returned.

Here are the results:

Check the panel titles.

In the first picture, the line segments are OK due to block is involved to the group, but coloring is different for the same name.

In the second one, the coloring is OK, but segments are lost.

That helps, but can you do the same two queries in Influx Data Explorer showing the raw data?

For the first chart:

And for the second one:

Note that, more points are returned when group has only name tag.

Can you clarify what you mean by “segments are lost”?

Thank you for your time.


Segments are losts means, that I can not see the two blocks because all points are connected.

A possible solution I found :

  1. query with:
    |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: true)
  2. visualize with
    image
  3. enjoy

But with the solution mentioned above, I still have limitations:

  1. using aggregateWindow, I am losing the original timestamp of the point, that I use in Data links and navigation.

To keep the original timestamp, I am updating the query like this:

  |> filter(fn: (r) => r["_field"] == vField)
  |> map(fn: (r) => ({ r with tOrigin: r._time}))  
  |> group(columns: ["name"])
  |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: true)
  |> yield(name: "mean")

To make the Data links work, I would like to use the tOrigin tag as template variable but the tag not listed, so my Data links navigation does not working anymore.
So this is another dead end.
image

I am pretty stumped by this as well. I am almost certain is has to do with Grafana (not Influx) and wanting to join the different segments. The aggregateWindow solution is what I was also originally thinking to remedy the problem, but as you noted, that introduces some other problems.

I will keep thinking…

1 Like

I have never used the following overrides before:

  • fields returned by query
  • fields with names matching regex

Do you think any can help?

I am thinking about, can Grafana provide group-ing? In my flux query, I am going to provide map with aggreateWindow, but not groupping the series by name. Can Grafana provide group in Transformation to provide a visualization that I need?

Any idea? Should I open a feature request ticket?