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?
Expected result:
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
a_total -1
# EOF
What did you see instead? Under which circumstances?
Current behavior:
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:
- bad_missing_or_extra_commas_0
- bad_metadata_in_wrong_place_1
- bad_counter_values_18
- bad_grouping_or_ordering_9
- bad_counter_values_1
- bad_histograms_2
- bad_counter_values_16
- bad_value_1
- bad_missing_or_extra_commas_2
- bad_invalid_labels_6
- bad_grouping_or_ordering_8
- bad_metadata_in_wrong_place_0
- bad_grouping_or_ordering_10
- bad_grouping_or_ordering_0
- bad_value_2
- bad_metadata_in_wrong_place_2
- bad_text_after_eof_1
- bad_value_3
- bad_counter_values_0
- bad_grouping_or_ordering_3
- bad_histograms_3
- bad_blank_line
Environment
Darwin 20.6.0 x86_64
version=2.31.0
- Prometheus configuration file:
global:
scrape_interval: 5s
scrape_configs:
- job_name: "open-metrics-scrape"
static_configs:
- targets: ["localhost:3000"]
cc: @PaurushGarg @mustafain117