jenkinsci / prometheus-plugin

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

Disable metrics regex to match label values #642

Closed vytstank closed 6 months ago

vytstank commented 7 months ago

What feature do you want to see added?

"Disabled Metrics" feature is great, but on larger installs it's not enough to reduce metric size.

I've tried to disable *_created metrics, as they are ~ 1/3 of the total size, but found that they are added by the Prometheus client framework, so appear after Disabled Metrics does its job and are part of metrics I would like to have.

Would be nice to have a way to include filtering based on label values. Looking at the code, "Disabled Metrics" is in different context, so maybe it would work as separate feature.

Upstream changes

No response

Are you interested in contributing this feature?

No response

Waschndolos commented 7 months ago

Currently no idea how but I think it would be a good enhancement. I'll check

Waschndolos commented 6 months ago

I found a reference in the prometheus client that there's a environment variable to disable the _created metrics called PROMETHEUS_DISABLE_CREATED_SERIES. Values can be 1, t, true - Maybe this works? When I enable the filtering by regex it's not much won. The original purpose was to not even calculate the metrics when they match the regex (which is also no longer true for the metrics created by the metrics plugin) - If we would filter for values as well it simply doesn't show but it would be calculated in the background - so maybe not that effective?

vytstank commented 6 months ago

Thanks a lot for taking a deeper look into this.

PROMETHEUS_DISABLE_CREATED_SERIES=true passed to java starting jenkins seems to solve my original problem and gives room to grow.

Waschndolos commented 6 months ago

Good that it helps! If you're good I'd like to close the request?

vytstank commented 6 months ago

Yes, I'm good with that. Thanks again