How to add a trend line to time series chart

Hi, I want to add a trend line to time-series chart with data being extracted from Prometheus… I have checked many sources but could not find optimal solution. Could someone please help… Thanks!

Welcome to the Grafana community! Your question is a bit vague and can probably be answered better with more details.

  1. Is your data source added to Grafana?
    • Yes? Go to 2.
    • No? Visit {YOUR_GRAFANA_URL}/datasources/new and click on Prometheus to configure your data source. Save and test your configuration.
  2. Create a new dashboard in Grafana. Add a time series panel to it. Select your Prometheus data source in Data Source.
  3. Your data in Prometheus can be queried using the PromQL language. Here’s my favorite resource on PromQL.

Let me know if this helps guide you in the right direction. Good luck!

Yes, the source is added to grafana and I am able to plot time-series. I just need to add a trend-line on top of time-series which I don’t know how to do. Please advice!

It’s possible the feature you are looking for doesn’t exist in Prometheus, but perhaps you are looking for the function predict_linear? From that page, the example is:

predict_linear(demo_disk_usage_bytes[4h], 3600)

Another one you can try is average_over_time, or a combination of the 2 functions. You won’t get a linear approximation from this, but can still be used as a visual guide.