What did you do?
We want to ensure OpenMetrics / Prometheus compatibility in the OpenTelemetry Collector. We have been building compatibility tests to verify the OpenMetrics spec is fully supported on both the OpenTelemetry Collector Prometheus receiver and PRW exporter as well as in Prometheus itself.
We used the OpenMetrics metrics test data available at https://github.com/OpenObservability/OpenMetrics/tree/main/tests/testdata/parsers
Out of a total of 161 negative tests in OpenMetrics,
94 tests pass (these tests are dropped) with an 'up' value of 0;
67 tests are not dropped and have an 'up' value of 1 and 22 tests have incorrectly ingested metrics.
In order to test Prometheus itself, we set up a metrics HTTP endpoint that exposes invalid/bad metrics from the OpenMetrics tests. We then configured Prometheus 2.31.0 to scrape the metrics endpoint.
What did you expect to see?
The scrape should fail since the target has invalid metric and the appropriate error should be reported.
For e.g with following metric data: bad_counter_values_1 (https://raw.githubusercontent.com/OpenObservability/OpenMetrics/main/tests/testdata/parsers/bad_counter_values_1/metrics)
# TYPE a counter
What did you see instead? Under which circumstances?
Scrape is successful. There are multiple bad test cases that are scraped successfully by Prometheus.
For example - Using bad_counter_values_1 (#5 listed below) does not show an error even though it is an negative counter value. According to OpenMetrics tests, this metric should not be parsed.
You can see no error has been reported and the scrape is successful.
Similar to bad_counter_values_1 test case, there are multiple bad test cases where the scrape is successful and metrics are ingested by Prometheus:
Darwin 20.6.0 x86_64
- Prometheus configuration file:
- job_name: "open-metrics-scrape"
- targets: ["localhost:3000"]
cc: @PaurushGarg @mustafain117