prometheusgrafanametrics

Custom TimeSeries in Grafana


My goal is to make timeseries chart in Grafana, that shows a line from SQL Agent Job starting point to the point of time job start + duration (e.g. line from 10:00 till 10:30 with value 1).

There are two simple metrics which I get from Prometheus: job_timestamp, job_duration.

How can I make a desired timeline chart based on these metrics?

I have tried Google without any success.


Solution

  • Assuming job_timestamp has timestamp as value in seconds, job_duration has duration as value in seconds and both of them are unique, you can use following query to get desired result:

    vector(1)
     and timestamp(vector(1)) > scalar(job_timestamp)
     and timestamp(vector(1)) < scalar(job_timestamp + job_duration)