Search code examples
jenkinsprometheusgrafanapromql

How to find the fluctuation of a metric for prometheus/grafana?


i am using prometheus and grafana to visualize data from a jenkins instance. I am using Jenkins metrics and prometheus metrics plugins to extract metrics for Prometheus, i have created a basic Grafana dashboard for instant metrics and some graphs and right now i need to create a promql query to extract the fluctuation from the last time the metric changes for the build time of a Jenkins job. I found out about changes() and rate() promql function but i don't get the result i am waiting. The last query that i used was: changes(default_jenkins_builds_last_build_duration_milliseconds{jenkins_job="$project"}[1m])

where the variable $project let me select the job that i need to investigate in Grafana.

is that the right approach ??? do you have any alternative idea ???


Solution

  • Unfortunately the only way to do it, for me is this PromQl query,

    round((default_jenkins_builds_last_build_duration_milliseconds > 1.5 * (avg_over_time(default_jenkins_builds_last_build_duration_milliseconds[30d]) and default_jenkins_builds_last_build_result_ordinal == 0))/1000/60 , 2)
    

    It isn't the cleanest way but with some alert suppression it can work.