plugin-tools
plugin-tools copied to clipboard
Docs: Need clarification on Long/Wide Formats
Which areas does this feature request relate to
- [ ] Create Plugin
- [ ] Sign Plugin
- [ ] Plugin E2E
- [X] Documentation
Problem
I'm working on a datasource and reading through the long vs wide data frame section and find myself a bit confused by this line:
"Grafana can detect and convert data frames in long format into wide format."
This doesn't happen automatically right? My understanding is that grafana offers some helper functions to make this easier, perhaps we could add docs for that? Or does the timeseries visualization always convert dataframes to wide?
I think it'd also be good to mention here that if developers want to their dataframes to support alerting they need to use wide dataframes
Solution
Maybe link to the wideToLong and longToWide functions? https://github.com/grafana/grafana-plugin-sdk-go/blob/main/data/time_series.go#L210
Alternatives
No response
Additional context
No response
Are you interested in contributing the solution?
- [ ] Yes
- [ ] No
@josmperez please have a look and unassign if you are unable to fix this one. Thanks!
Thanks for pointing this out. I'll take a look.
Need engineer tech review (@andresmgot ?) of this suggested fix.
I agree that the sentence is a bit confusing, maybe @marefr can correct me if I am wrong but it could clarify:
- When it says "Grafana can detect ...", I believe it means that "With the Grafana plugin SDK for Go, a plugin can detect ...". That clarifies that it can detect the data frame type if you are using a backend for your plugin (this is, the library is written in go).
- For detecting and converting a data frame, we could give an example:
tsSchema := frame.TimeSeriesSchema()
if tsSchema.Type == data.TimeSeriesTypeLong {
wideFrame, err := data.LongToWide(frame, nil)
if err == nil {
// handle error
}
// return wideFrame
}
Or does the timeseries visualization always convert dataframes to wide?
I don't think this happens but I am no expert of the timeseries visualization so maybe it's the case.
I think it'd also be good to mention here that if developers want to their dataframes to support alerting they need to use wide dataframes
I was not aware of this either.