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

Add support for dot separated measurements #69

Closed
wants to merge 1 commit into from

Conversation

kvesterling
Copy link

Add topic as a tag enabling further functionality in grafana.
Use a dot in the measurement instead of / such that we can use $1,$2,$3, etc for aliases in Grafana.

This will break a lot of dashboards currently in use, but the benefits outweigh the little bit of work to straighten it out.

Add topic as a tag enabling further functionality in grafana
@mman
Copy link
Collaborator

mman commented Mar 18, 2024

Thanks for the PR @kvesterling, let me please dig into this a bit deeper. Since it's gonna break everything, I am not going to merge this as is, but I think it would be a great addition while preserving backwards compatibility in a reasonable way. Let me please investigate how to move this forward...

@kvesterling
Copy link
Author

It does break the grafana dashboards, BUT it's worth the pain. I've already rebuilt the majority of them. Easy fix if you just do a replace in the JSON, then it's just a few things after that. BUT much gets easier.

Let me know what you need fixed.

@mman
Copy link
Collaborator

mman commented Apr 19, 2024

Adding a note for myself how this is supposed to work. If you structure your InfluxDB measurements in a way that the measurement field contains multiple values separated by dots. then the parts of the measurement delimited by the dots are available in the query builder as variables $0, $1, ...

image

I am not convinced this is a way to go, as (AFAIK) general InfluxDB recommendation is to keep the number of measurements as low as possible and add as many tags as you wish to add necessary dimensions.

@mman
Copy link
Collaborator

mman commented Apr 19, 2024

@kvesterling Sorry for my late reply.

Could you please post perhaps couple more screenshots where and how you use the measurements with dots to actually compose a query and where having $0, $1 is benefiting you?

Also what do you actually get by copying the measurement name itself into another tag? I'm not seeing the benefit immediately.

As a side note, one of the main goals of Venus Grafana integration is to allow people to easily explore all the measurements available and make panels out of them easily - without necessarily knowing what is out there. InfluxDB data source query builder is helping this with measurement autocomplete, but we have been bitten by victronenergy/venus-docker-grafana#8 since day zero until today, and I think if we affect how measurements are named, it would be great to help address this issue as well.

Unfortunately given how measurement auto complete is implemented (https://github.com/grafana/grafana/blob/8f38ef70ceaea12ca27bc0d856951e6e036da115/public/app/plugins/datasource/influxdb/influxql_query_builder.ts#L62) I do not see an easy way to do it.

For now please add couple more examples how separating measurement components with dots actually helps you.

I stand my initial comment though, we are not gonna break anyones dashboards, if we merge this, it will be a configurable option - perhaps default for new releases but with backwards compatibility. Thanks for your understanding.

@kvesterling
Copy link
Author

kvesterling commented Apr 19, 2024

I think I miscommunicated. If you store THE measurement with dots as opposed to slashes, then you can use $1, $2, $3 in grafana... Using slashes defeats that capability. If you would do so, I'd be more inclined to contribute to your branch. Even provide the updated dashboards, etc...

I was able to update the dashboards quite easily, and I agree that it does break what's there, but being able to say...

image

Is this what you mean buy auto-complete?
image

@mman
Copy link
Collaborator

mman commented Apr 20, 2024

@kvesterling I understand the benefit of using dots in the measurement, was just curious to see more examples like your SELECT over all AC inputs and aliasing using $3.

Could I also ask what is the reason of adding the measurement as additional tag?

And yes, for the autocomplete, the current implementation is to return first 100 rows that match what you type in and because we have currently a lot of measurements, the autocomplete only displays the beginning. My thinking is around the lines of displaying top level categories, and perhaps first subcategory (up to a second delimiter) so that you can quickly skim though the available tree of all measurements. But as I said, that's just an unrelated side note.

@mman
Copy link
Collaborator

mman commented Apr 22, 2024

I have created issue #82 to discuss this in further detail. Please move the discussion there.

@mman mman changed the title Update influxdb.js Add support for dot separated measurements May 15, 2024
@mman
Copy link
Collaborator

mman commented May 17, 2024

Superseded by #98

@mman mman closed this May 17, 2024
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

Successfully merging this pull request may close these issues.

2 participants