jenkinsci / prometheus-plugin

Jenkins Prometheus Plugin
https://plugins.jenkins.io/prometheus/
Apache License 2.0
181 stars 151 forks source link

Need Build_ID, build_number or job ID in output #661

Closed vipin5050 closed 4 months ago

vipin5050 commented 4 months ago

What feature do you want to see added?

I would like to have build_id, build_number or jenkins job ID to be collected by the prometheus. As I am thinking to have a metrics to do time taken by individual job ID, something like

Screenshot 2024-05-09 at 11 23 30 AM

Upstream changes

No response

Are you interested in contributing this feature?

I can test the builds or solution.

Waschndolos commented 4 months ago

Currently no Computer around, but the Plugin should already provide such Information. Looks you have a dedicated displayname in Grafana. Maybe temporary remove it from the Dashboard, then you should get the Information. If not i can take a closer Look on monday

vipin5050 commented 4 months ago

I was looking in to metrics provided and I couldnt find Build_ID, build_number or job ID, I could be wrong if you can find that would be awesome. If not please try to include if reasonably possible.

Waschndolos commented 4 months ago

I will check on monday, currently on vacation.

Waschndolos commented 4 months ago

@vipin5050. Just checked it. When you use the Prometheus Plugin without any further configuration you'll only get the jenkins_job name as info. Like

default_jenkins_builds_build_duration_milliseconds{jenkins_job="test",repo="NA",buildable="true"}

However there's an option in the configuration page:

image

which also prints out the build number:

default_jenkins_builds_build_duration_milliseconds{jenkins_job="test",repo="NA",buildable="true",number="1",} 628.0
default_jenkins_builds_build_duration_milliseconds{jenkins_job="test",repo="NA",buildable="true",number="2",} 369.0

It will display all builds available, so if you have like 200 builds, you get 200 entries.

vipin5050 commented 4 months ago

Thanks @Waschndolos yes you are right, I can get the job_ID. This is exactly I was looking. Thanks for quick reply. you can close this issue.