-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Metric will be skipped when producing scrape output for PrometheusMeterRegistry #5192
Comments
I can confirm this bug in 1.13.0 |
Downgrading the Prometheus Java client as mentioned here solves the problem: https://github.com/micrometer-metrics/micrometer/wiki/1.13-Migration-Guide |
I have tried downgrading to another version using the following pom.xml and the problem persists: <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>micrometer-bug</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>19</maven.compiler.source>
<maven.compiler.target>19</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
<version>1.13.0</version>
</dependency>
</dependencies>
</project> When I switch to version When I switch to version
Having a look at the release notes for 1.6.0 doesn't reveal a change in the behaviour of tag keys. So my guess is, that the error message is correct and should have been thrown in the versions 1.6.0+, but disappeared for some reason. Can someone confirm the correct behaviour? Is Prometheus able to handle meters with the same name but different tag keys? |
After some debugging I figured out that the problem was the total suffix of one of my metrics. I have two metrics:
which leads with the new prometheus version to one metric abc(tags=[]) as the new behaviour of the Registry is to remove the total suffix. The second metric is not processed as the tags are not equal. @danielksb the tag keys must be equal if you register a metric with the same name. Otherwise it is ignored. |
I checked the Prometheus spec on writing client libraries: https://prometheus.io/docs/instrumenting/writing_clientlibs/#labels They mention:
This means my expectations were wrong. However prio to version 1.5 there was an error message when creating an invalid meter. Should I open a ticket for adding the error message again to warn users about their mistake or was the error message deliberately removed? |
Duplicate of #877 |
Doing this is discouraged by the Prometheus server and validated by the Prometheus client.
you should do this:
Please let me know if this is not the case (duplicate of #877) and we can reopen this issue. |
It was intentionally removed (users asked for it). |
It was intentional as @jonatan-ivanov mentioned, but see the corresponding documentation. You can configure a callback for meter registration failure that logs and/or throws an exception. |
Describe the bug
If two metrics have the same name but different tags, they will be registered in the PrometheusMeterRegistry as two distinct meters.
After calling
PrometheusMeterRegistry::scrape
one of the two meters will not be part of the output. See below for an example.Environment
To Reproduce
How to reproduce the bug:
Expected behavior
The function call to
PrometheusMeterRegistry::scrape
should contain entries for all registered meters:The text was updated successfully, but these errors were encountered: