Skip to content
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

Add test for Prometheus Receiver to verify timeseries with empty label values are supported #5996

Closed
mustafain117 opened this issue Oct 29, 2021 · 1 comment · Fixed by #6407
Labels
ci-cd CI, CD, testing, build issues comp:prometheus Prometheus related issues comp: receiver Receiver

Comments

@mustafain117
Copy link
Contributor

Is your feature request related to a problem? Please describe.
We want to ensure that the Prometheus receiver supports timeseries with empty label values. According to Prometheus documentation (https://prometheus.io/docs/concepts/data_model/), a label with an empty label value is considered equivalent to a label that does not exist.
Describe the solution you'd like
We propose the following solution:

Add a test that verifies timeseries with empty label values are supported.

The test will create a timeseries with empty label value.

Note that a label with an empty value is considered equivalent to a label that does not exist, i.e. Prometheus receiver should drop the label.

Case 1: Metric data with empty label value and no other label:

# HELP test_gauge0 This is my gauge
# TYPE test_gauge0 gauge
test_gauge0{label1=""} 10

Expected Result: MetricDescriptor for test_gauge0 should not have “label1” as a LabelKey.

Case 2: Metric with two time-series, one has a value for the label "foo" whereas the other doesn’t:

# HELP gauge_test some test gauges.
# TYPE gauge_test gauge
gauge_test{id="1",foo="bar"} 1.0
gauge_test{id="2",foo=""}    2.0

Expected Result:

  • MetricDescriptor for gauge_test should have “foo” as a LabelKey
  • Timeseries for gauge_test{id=“2”, foo=“”} should have
    metricspb.LabelValue{ Value: “”, HasValue: false}

The corresponding OTLP format of the above case should be:

metrics := []*metricspb.Metric{
  {
    MetricDescriptor: &metricspb.MetricDescriptor{
      Name:      "gauge_test",
      Type:      metricspb.MetricDescriptor_GAUGE_DOUBLE,
      LabelKeys: []*metricspb.LabelKey{{Key: "id"}, {Key: "foo"}}},
    Timeseries: []*metricspb.TimeSeries{
      {
        StartTimestamp: nil,
        LabelValues:    []*metricspb.LabelValue{{Value: "1", HasValue: true}, {Value: "bar", HasValue: true}},
        Points: []*metricspb.Point{
          {Timestamp: currentTimestamp, Value: &metricspb.Point_DoubleValue{DoubleValue: 1.0}},
        },
      },
      {
        StartTimestamp: nil,
        LabelValues:    []*metricspb.LabelValue{{Value: "2", HasValue: true}, {Value: "", HasValue: false}},
        Points: []*metricspb.Point{
          {Timestamp: currentTimestamp, Value: &metricspb.Point_DoubleValue{DoubleValue: 2.0}},
        },
      },
    },
  },
}

Additional context
Related to open-telemetry/wg-prometheus#57

CC: @alolita @Aneurysm9

@alolita alolita added comp:prometheus Prometheus related issues ci-cd CI, CD, testing, build issues comp: receiver Receiver labels Nov 2, 2021
@mustafain117
Copy link
Contributor Author

@alolita please assign this issue to me.

povilasv referenced this issue in coralogix/opentelemetry-collector-contrib Dec 19, 2022
This is not a breaking change since the LogRecordFlags were not yet released

Signed-off-by: Bogdan <bogdandrutu@gmail.com>

Signed-off-by: Bogdan <bogdandrutu@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci-cd CI, CD, testing, build issues comp:prometheus Prometheus related issues comp: receiver Receiver
Projects
None yet
2 participants