jenkinsci / prometheus-plugin

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

Option to aggregate PR-builds from same place #500

Closed macetw closed 1 week ago

macetw commented 1 year ago

What feature do you want to see added?

With projects that are large, with many PRs, metrics are potentially too large, giving too much detail between different PRs, where differences between PRs is not helpful for metrics given the extra storage and bandwidth required.

As an SRE managing metrics and dashboards for Jenkins builds, I would like to simplify and simplify the aggregation across PRs of the same build, so that I don't have to store and transmit so much data and Prometheus doesn't have to work so hard to aggregate it at query time.

For example, if I have a build with 2 PRs, and it shows statistics like this:

     default_jenkins_builds_duration_milliseconds_summary_count{jenkins_job="mybuild/PR-481"} 1.0
     default_jenkins_builds_duration_milliseconds_summary_sum{jenkins_job="mybuild/PR-481"} 2000.0
     default_jenkins_builds_duration_milliseconds_summary_count{jenkins_job="mybuild/PR-81"} 3.0
     default_jenkins_builds_duration_milliseconds_summary_sum{jenkins_job="mybuild/PR-81"} 4000.0

with this option enabled, it would aggregate like so:

     default_jenkins_builds_duration_milliseconds_summary_count{jenkins_job="mybuild"} 4.0
     default_jenkins_builds_duration_milliseconds_summary_sum{jenkins_job="mybuild"} 6000.0

(and for all other per-build metrics)

We will want to continue to differentiate on the other labels. "buildable" and "repo"

Upstream changes

No response

macetw commented 1 year ago

Appears highly related to: https://github.com/jenkinsci/prometheus-plugin/issues/343 (I'm not the only one who suggested this)

Waschndolos commented 1 year ago

Hi, thank you for the issue. I'll have to investigate how this is possible. Sounds like a valid use case. So should this only be applied to PullRequests? Or should it be more like a general grouping by.. I don't know regex or something?

macetw commented 1 year ago

Maybe it could regex on PR builds, but it might be more simple to generalize it. We might want metrics for all folders of builds, to show aggregation at the directory level. The use case is slightly different, but the logic might be more simple to implement. Like for builds:

     foo/bar/PR-1 job
     foo/bar/PR-2 job
     foo/foobar job

We could want to:

The directory statistics could be very powerful for groups of teams. Our specific use case is for multibranch pipeline jobs, but this might also work to generalize outside that specific use case.

Waschndolos commented 1 year ago

I see. I cannot promise that I'll be able to implement it fast but I'll see what I can do. Think it could be useful :)

github-actions[bot] commented 1 year ago

Stale issue message

Waschndolos commented 1 year ago

"activity"

seguins commented 1 year ago

I have the same issue when I'm using this plugin with the workflow-multibranch plugin. A quick win could be to detect builds attached to a multibranch workflow and aggregate them together.

@Waschndolos, I have some free time to work on it if you want.

Waschndolos commented 1 year ago

@seguins. Hey thank you for reaching out. My plan was to implement this feature when I'm done testing my refactoring in the refactoring branch (https://github.com/jenkinsci/prometheus-plugin/tree/refactoring). But I guess I'm able to merge it when you've already have an idea to implement this in the current code. Otherwise I'll try to finish testing this week on my companies Jenkins instance and after that feel free to help :)

github-actions[bot] commented 1 year ago

Stale issue message

Waschndolos commented 11 months ago

Quick update. It's not forgotten :) I'm working on it. Didn't have a good idea yet but I might be making progress right now.

github-actions[bot] commented 9 months ago

Stale issue message

github-actions[bot] commented 7 months ago

Stale issue message

Waschndolos commented 6 months ago

My idea didn't work. Don't have a good idea on how to implement it. Does anybody have one?

drewandersen commented 2 months ago

@Waschndolos what was your idea? I might be able to take on this work.

Waschndolos commented 2 months ago

@drewandersen. Don't have a specific one but probably it's best to let the plugin calculate all individual metrics and then before writing it out to group the relevant metrics somehow. Maybe it's possible to write a custom CollectorRegistry which can do that?

github-actions[bot] commented 2 weeks ago

Stale issue message