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

data type of metric datapoint value does not match Google Managed Prometheus defined data type #36228

Closed
nabheet opened this issue Nov 6, 2024 · 3 comments
Assignees
Labels
bug Something isn't working exporter/googlemanagedprometheus Google Managed Prometheus exporter

Comments

@nabheet
Copy link

nabheet commented Nov 6, 2024

Component(s)

exporter/googlemanagedprometheus

What happened?

Description

I am getting this error:

One or more TimeSeries could not be written: timeSeries[54]: Value type for metric prometheus.googleapis.com/system_network_errors_total/counter conflicts with the existing value type (INT64).; timeSeries[53]: Value type for metric prometheus.googleapis.com/system_network_errors_total/counter conflicts with the existing value type (INT64).

Steps to Reproduce

I am using Python OTEL instrumentation to generate this data. Here is the detailed debug output from OTEL Collector.
image

Now, it seems to me that the data coming from the Python Instrumentation contains a float64 value. And I am guessing that in Google Managed Prometheus it is defined as Int64. Which is fine because if figure I could just cast the float to int and drop the decimals as this is a counter and decimals are irrelevant.

So here is what I tried:

  transform/metrics:
    error_mode: ignore
    metric_statements:
      - context: metric
        conditions:
          - resource.attributes["cloud.region"] == nil
        statements:
          - set(resource.attributes["cloud.region"], "${env:GCP_CLOUD_REGION}")

      - context: datapoint
        conditions:
          - metric.name == "system.network.errors"
        statements:
          - set(sum, value_int)
          # - set(value, Int(value))

I don't think I understand OTTL and OTEL configuration enough to implement this. I couldn't find anything specific to what I wanted in the examples. Any assistance would be greatly appreciated.

Expected Result

I would be happy with a way to cast the floating point value to an integer value for each of the system.network.errors metric datapoints.

Actual Result

Please HELP!!!!!

Collector version

v0.112.0

Environment information

Environment

OS: Google Container OS and docker

OpenTelemetry Collector configuration

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317

  prometheus/scraper:
    config:
      global:
        scrape_interval: 30s
      scrape_configs:
        - job_name: metric-exporter
          scheme: https
          static_configs:
            - targets:
              - ${env:SOME_METRIC_EXPORTER}

  # prometheus/self-metrics:
  #   config:
  #     scrape_configs:
  #       - job_name: otel-self-metrics
  #         scrape_interval: 1m
  #         static_configs:
  #         - targets:
  #           - localhost:8888

  statsd:
    enable_metric_type: true
    timer_histogram_mapping:
      - statsd_type: "histogram"
        observer_type: "histogram"
        histogram:
          max_size: 50
      - statsd_type: "distribution"
        observer_type: "histogram"
        histogram:
          max_size: 50
      - statsd_type: "timing"
        observer_type: "summary"

processors:
  batch:

  memory_limiter:
    # drop metrics if memory usage gets too high
    check_interval: 10s
    limit_percentage: 95
    spike_limit_percentage: 20

  # automatically detect Cloud Run resource metadata
  resourcedetection:
    detectors:
      - env
      - gcp

  filter/self-metrics:
    error_mode: ignore
    metrics:
      include:
        match_type: strict
        metric_names:
        - otelcol_process_uptime
        - otelcol_process_memory_rss
        - otelcol_grpc_io_client_completed_rpcs
        - otelcol_googlecloudmonitoring_point_count

  filter/drop-metrics:
    error_mode: ignore
    metrics:
      metric:
        - name == "http.server.response.size"
        - name == "http.server.request.size"
        - name == "http.client.response.size"
        - name == "http.client.request.size"


        - name == "process.open_file_descriptor.count"
        - name == "process.runtime.cpython.cpu.utilization"
        - name == "process.runtime.cpython.thread_count"
        - name == "process.runtime.cpython.memory"
        - name == "http.client.duration"

  transform/metrics:
    error_mode: ignore
    metric_statements:
      - context: metric
        conditions:
          - resource.attributes["cloud.region"] == nil
        statements:
          - set(resource.attributes["cloud.region"], "${env:GCP_CLOUD_REGION}")

      - context: datapoint
        conditions:
          - metric.name == "system.network.errors"
        statements:
          - set(sum, value_int)

exporters:
  googlemanagedprometheus: # Note: this is intentionally left blank
  googlecloud:             # Note: this is intentionally left blank
  debug:
    verbosity: detailed

extensions:
  health_check:
    endpoint: "0.0.0.0:${env:OTEL_HEALTHCHECK_PORT}"

service:
  extensions:
    - health_check
  telemetry:
    logs:
      level: debug
  pipelines:
    traces:
      receivers:
        - otlp
      processors:
        - memory_limiter
        - batch
      exporters:
        - googlecloud

    metrics:
      receivers:
        - otlp
        - prometheus/scraper
        - statsd
      processors:
        - memory_limiter
        - filter/drop-metrics
        - transform/metrics
        - batch
      exporters:
        - googlemanagedprometheus
        # leave this debug exporter commented out so it is
        # easier to enable and I don't forget about it
        - debug

    # metrics/self-metrics:
    #   exporters:
    #     - googlemanagedprometheus
    #   processors:
    #     - filter/self-metrics
    #     - memory_limiter
    #     - resourcedetection
    #     - batch
    #   receivers:
    #     - prometheus/self-metrics

Log output

No response

Additional context

No response

@nabheet nabheet added bug Something isn't working needs triage New item requiring triage labels Nov 6, 2024
@github-actions github-actions bot added the exporter/googlemanagedprometheus Google Managed Prometheus exporter label Nov 6, 2024
Copy link
Contributor

github-actions bot commented Nov 6, 2024

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@dashpole
Copy link
Contributor

Take a look at https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/googlemanagedprometheusexporter#conflicting-value-types. That should help you solve it. Let me know if you have any other questions

@dashpole dashpole removed the needs triage New item requiring triage label Nov 14, 2024
@dashpole dashpole self-assigned this Nov 14, 2024
@nabheet
Copy link
Author

nabheet commented Nov 15, 2024

Perfect! thank you! This seems to have solved this particular error.

@nabheet nabheet closed this as completed Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working exporter/googlemanagedprometheus Google Managed Prometheus exporter
Projects
None yet
Development

No branches or pull requests

2 participants