grafana / grafana-plugin-sdk-go

A Go SDK for building backend plugins for Grafana
Apache License 2.0
199 stars 59 forks source link

Proposal: FieldConfig for Extract Labels from Name #1030

Open kylebrandt opened 1 month ago

kylebrandt commented 1 month ago

What would you like to be added: A property added to FieldConfig, that instructs consumers that they can/should extract dimensions (create labels) from the field name.

Why is this needed: Some data is like this, in SSE (so it works with alerting and Recorded Queries), we have a hack that does this (somehow?) if the DS Type matches (Currently Graphite, but adding Dynatrace soon.

Adding this as a FieldConfig:

vNext could include an additional property that guides how to extract dimensions/labels, (e.g. { "delim": ".", "keys": ["metric", "namespace", "pod"] }.

Reference: https://github.com/grafana/grafana/pull/90246#issuecomment-2223133158

cc @yuri-tceretian @yesoreyeram @ryantxu

ryantxu commented 1 month ago

I think this makes sense.

yesoreyeram commented 1 month ago

I like the idea. But in practice, ds authors don't know the mapping of the fields. Also It will be tiresome for a customer to enter all the field mapping manually. for every metric this will be different even though they may be of same length.

yesoreyeram commented 1 month ago

I appd we are doing something similar where we don't know the mapping but the delimiter. So the label goes like segment_1, segment_2.

https://github.com/grafana/plugins-private/blob/53be67e0d9e4bb3e9b3ec9e458d8d7e5763c68d8/plugins/dlopes7-appdynamics-datasource/pkg/appd/metrics/multi_framer.go#L105