simPod/GrafanaJsonDatasource

How to name graphs / metrics?

zeisss opened this issue · 3 comments

zeisss commented

Hi, thanks for this!

I am currently prototyping an endpoint for use with GrafanaJsonDatasource to show daily aggregated stats for our tenants.

In /metrics I return one metric with two payloads: the tenant name and what field (e.g. total users or active users). For reference, the /query endpoint roughtly looks like this:

[{"target": "daily", "datapoints": [ [value(), timestamp()], ... ]}]

Using those in a dashboard panel now just gives me two graphs labeled daily (the name of the metric). I don't see any options to name these, neither in Grafana nor via the API in the response, as the target field needs to match the target from the request.

image

I would expect either the option to customize the label (similar to a Prometheus datasource) or have another field in the response where I can provide a label).

simPod commented

Did you try returning different names in your response? It does not have to be the same as in request.

zeisss commented

No I didn't, as I assumed the target field in the response must correlate to the target in a request. But now thinking about this, Grafana actually doesn't need it, right?

zeisss commented

With a first test, this seems to be working just fine. Thank you for the help.