plugin-tools icon indicating copy to clipboard operation
plugin-tools copied to clipboard

Docs: Need clarification on Long/Wide Formats

Open sarahzinger opened this issue 1 year ago • 4 comments

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

sarahzinger avatar Apr 16 '24 20:04 sarahzinger

@josmperez please have a look and unassign if you are unable to fix this one. Thanks!

derek-cadzow avatar Apr 26 '24 16:04 derek-cadzow

Thanks for pointing this out. I'll take a look.

josmperez avatar Apr 26 '24 18:04 josmperez

Need engineer tech review (@andresmgot ?) of this suggested fix.

josmperez avatar Jul 23 '24 21:07 josmperez

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.

andresmgot avatar Aug 09 '24 08:08 andresmgot