weaveworks / grafanalib

Python library for building Grafana dashboards
Apache License 2.0
1.85k stars 307 forks source link

Target alias #648

Closed JaSei closed 1 week ago

JaSei commented 5 months ago

What does this do?

Some targets (Influx for example) use alias instead of legendFormat (which is Prometheus "alias"). This commit setup both of them by current legendFormat.

Why is it a good idea?

For Influxdb SqlTarget isn't now possible to set "alias" via Target. Of course is possible to use InfluxDBTarget (https://github.com/weaveworks/grafanalib/blob/main/grafanalib/influxdb.py) but there missing other options (like hide, because it's not child of Target). So I've chosen solution to extend Target to support all needed for my influx.

Context

Questions

If you don't like this solution, I see other solutions

  1. add new alias option - similar as #285
  2. InfluxDBTarget class should be inherit from Target