Search code examples
grafanagrafana-templatinggrafana-variable

How to plot horizontal line in Timeseries in Grafana


I use grafana to plot timeseries data. In a timeseries plot i want to add a constant line which comes from a monitoring level. The value of that level is dynamic (from a postgres database) the timeseries come from a ifluxdb Datasource.

The monitoring level have no timestamp. The result should look like this:

enter image description here

I have searched quite a while how to do this, but not found a good explanation.


Solution

  • It is possible to add dynamic thresholds using the Config from query option.

    1. Add a new query below your standard metric query. This will likely be called B (tip: rename this to something more descriptive).

      Here you query the static reference value. Eg SELECT expected_number_of_widgets FROM baseline

    2. Open Transformation tab

    3. Find Configuration from Query results

    4. Choose Config query = B

    5. At the dropdown for expected_number_of_widgets, choose Use as: Threshold1.

    6. In the right panel, under Thresholds, make sure Show Tresholds is enabled and remove the default threshold of 80.

    For more details, see https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/transform-data/#config-from-query-results