Skip to content

Prometheus is not fully compatible with OpenMetrics tests #56

@alolita

Description

@alolita

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.

Screenshot 2021-11-03 at 2 49 52 PM

You can see no error has been reported and the scrape is successful.

Screenshot 2021-11-03 at 2 50 20 PM

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:

  1. bad_missing_or_extra_commas_0
  2. bad_metadata_in_wrong_place_1
  3. bad_counter_values_18
  4. bad_grouping_or_ordering_9
  5. bad_counter_values_1
  6. bad_histograms_2
  7. bad_counter_values_16
  8. bad_value_1
  9. bad_missing_or_extra_commas_2
  10. bad_invalid_labels_6
  11. bad_grouping_or_ordering_8
  12. bad_metadata_in_wrong_place_0
  13. bad_grouping_or_ordering_10
  14. bad_grouping_or_ordering_0
  15. bad_value_2
  16. bad_metadata_in_wrong_place_2
  17. bad_text_after_eof_1
  18. bad_value_3
  19. bad_counter_values_0
  20. bad_grouping_or_ordering_3
  21. bad_histograms_3
  22. bad_blank_line

Environment

  • System information:

Darwin 20.6.0 x86_64

  • Prometheus version:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions