Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grafana won't display different topics from MQTT data source in the same panel with distinct field value name #39

Open
gilles380 opened this issue Mar 3, 2022 · 4 comments

Comments

@gilles380
Copy link

Using grafana 8.x, Mosquitto MQTT :

Create one panel
first MQTT data source query with TOPIC 1
Second MQTT data source query with TOPIC 2

6485c3ede96a30ca7d2a88fa7d52c30b328c0040

"value" label is being displayed twice.
Can't find a way to display different value label

@andershz
Copy link

andershz commented Mar 4, 2022

I have noticed the same thing, although I have 20 topics, not 2, and I use gauges instead of timelines.
I assume the topics you subscribe to publish simple numeric values, not json objects.
In that case it is by (lack of) design they are all mapped to the field name "Value".
I tried to solve this by adding field overrides, mapping "Fields returned by query" to "Display name".
That did not work so well in practice, it was very hard to configure it since fields appeared and disappeared in the
"Fields returned by query"-dropdown in a seemingly random manor.
In the end I got all 20 fields configured by manually modifying the panel json.
But even then it did not work very well, metrics would frequently revert back to being displayed as "Value" until the page was reloaded in the browser.
What I did then was to modify the backend code so that when the payload is a single value rather than a json object it will be sent to the frontend using the topic as field name instead of "Value".
In cases where I don't want the MQTT topic as display name I can just add a field override mapping "Fields with name" to "Display name". That seems to be stable unlike the mapping from "Fields returned by query".

Another thing that you might not have noticed with just 2 topics is that you are probably missing every second update to each topic.
I found that when using N topics in the same dashboard, (or rather with the same MQTT data source), for each topic only every 1/N update is sent from backend to frontend. This is more visible when using many topics as I do.
I had to modify the backend code to fix that as well.

@gpinkos
Copy link

gpinkos commented Apr 23, 2022

This is the transformation (outer join + organize fields) that I used to distinguish the different fields:

image

@Buronn
Copy link

Buronn commented Dec 13, 2022

This still not working for me, I have two topics (light/1 and light/2) and both needs to be separated, I can't mix them.

@shinton-ps
Copy link

I've found this to be an issue since before the official beta release, but the latest beta release broke all of my dashboards. In my case my topics are comprised of multiple values, e.g.

{
    "value1": 1.234
    "value2": 5.678
    ...
}

With the latest beta release my data drops out after only a few seconds (publishing at 5 Hz). Sometimes it's one topic, sometimes it's both. Sometimes I can get one back by changing the time range or refreshing the page, but then it drops out again soon after.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants