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

[googlemanagedprometheusexporter] Include resource labels #12175

Closed
olekgo opened this issue Jul 8, 2022 · 10 comments
Closed

[googlemanagedprometheusexporter] Include resource labels #12175

olekgo opened this issue Jul 8, 2022 · 10 comments
Assignees
Labels
closed as inactive enhancement New feature or request exporter/googlemanagedprometheus Google Managed Prometheus exporter priority:p2 Medium Stale

Comments

@olekgo
Copy link

olekgo commented Jul 8, 2022

Is your feature request related to a problem? Please describe.

In my use case, most of the labels are resource labels and they are ignored by the exporter, which leads to collisions ( "duplicate timeseries enountered" errors). I could be wrong, but I believe this issue is solved in prometheus and prometheusremotewrite exporters using resourcetotelemetry helper.

Describe the solution you'd like
Similar to how its implemented in prometheusexporter and prometheusremotewriteexporter. Probably using resourcetotelemetry helper

Describe alternatives you've considered
I tried to promote resource labels to metrics labels using a processor but didn't find anything that could do the job. But I wouldn't be surprised there's a way.

Additional context
N/A

@codeboten codeboten added the exporter/googlemanagedprometheus Google Managed Prometheus exporter label Jul 8, 2022
@codeboten
Copy link
Contributor

Pinging code owners: @aabmass @dashpole @jsuereth @punya @tbarker25 @damemi

@dashpole dashpole self-assigned this Jul 11, 2022
@dashpole
Copy link
Contributor

dashpole commented Jul 12, 2022

Just curious: which receiver are you using?

The GMP exporter relies primarily on service.name, service.namespace, and service.instance.id (mapped to job and instance in the prometheus_target). The service resource attributes are required to be globally unique, which prevents this issue (in theory). In practice, service resource attributes aren't consistently set, and often aren't globally unique when they are.

But regardless, the request to add the resourcetotelemetry helper is a good idea.

@olekgo
Copy link
Author

olekgo commented Jul 13, 2022

The GMP exporter relies primarily on service.name, service.namespace, and service.instance.id (mapped to job and instance in the prometheus_target).

Interesting.. I am using otlp receiver together with resourcedetection processor (same as in the doc). Out of all labels listed here, project_id, location and job are defined and instance, namespace and cluster(expected) are empty:
Screenshot 2022-07-13 at 01 00 03

When using both GMP exporter and file exporter simultaneously, I can confirm that the file exporter "sees" instance label, as well as all the other resource and metrics labels that are coming directly from the application (via otlp)

Upd: improved wording

@dashpole
Copy link
Contributor

Can you paste your resources from the file exporter?

@olekgo
Copy link
Author

olekgo commented Jul 14, 2022

cat fileexporter.json | jq -s '.[0].resourceMetrics[0].resource'

{
  "attributes": [
    {
      "key": "testattr",
      "value": {
        "intValue": "7357"
      }
    },
    {
      "key": "host.hostname",
      "value": {
        "stringValue": "redacted"
      }
    },
    {
      "key": "service.name",
      "value": {
        "stringValue": "testapp"
      }
    },
    {
      "key": "service.version",
      "value": {
        "stringValue": "unknown"
      }
    },
    {
      "key": "cloud.provider",
      "value": {
        "stringValue": "gcp"
      }
    },
    {
      "key": "cloud.account.id",
      "value": {
        "stringValue": "redacted"
      }
    },
    {
      "key": "cloud.platform",
      "value": {
        "stringValue": "gcp_compute_engine"
      }
    },
    {
      "key": "cloud.availability_zone",
      "value": {
        "stringValue": "us-central1-a"
      }
    },
    {
      "key": "cloud.region",
      "value": {
        "stringValue": "us-central1"
      }
    },
    {
      "key": "host.type",
      "value": {
        "stringValue": "redacted"
      }
    },
    {
      "key": "host.id",
      "value": {
        "stringValue": "redacted"
      }
    },
    {
      "key": "host.name",
      "value": {
        "stringValue": "apptest"
      }
    }
  ]
}

@dashpole
Copy link
Contributor

If you set service.instance.id to something unique per-application, that would set the instance in the outgoing metrics, and prevent duplicate timeseries errors. Otherwise, if you only have 1 instance of your application per-instance you could do:

processors:
  resource:
    attributes:
    - key: service.instance.id
      from_attribute: host.name

which would set instance to the host name.

I'll work on adding resourcetotelemetry

@olekgo
Copy link
Author

olekgo commented Jul 14, 2022

Thanks, it worked. A small note - I had to specify action eg:

processors:
  resource:
    attributes:
    - key: service.instance.id
      from_attribute: host.name
      action: insert

Looking forward to resourcetotelemetry support!

@olekgo
Copy link
Author

olekgo commented Sep 20, 2022

Maybe someone will find this usefull.

After playing with resourcetotelemetry feature (added to a forked version of the collector) I realized that it wasn't what I need - most of the resource attributes were junk (eg. python lib version etc), and I just wanted to copy a few resource attrs to metric attrs (-> GMP metric labels). I was able to accomplish this using the following processor:

  transform:
    metrics:
      queries:
        # set metric labels from resource.attrs
        - set(attributes["config_version"], resource.attributes["service.config_version"])
        - set(attributes["version"], resource.attributes["service.version"])

This basically copies service.config_version and service.version resource attrs to config_version and version metric attrs, therefore makes them available as metrics labels in GMP.

@github-actions
Copy link
Contributor

This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping @open-telemetry/collector-contrib-triagers. If this issue is still relevant, please ping the code owners or leave a comment explaining why it is still relevant. Otherwise, please close it.

Pinging code owners:

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

@github-actions
Copy link
Contributor

This issue has been closed as inactive because it has been stale for 120 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed as inactive enhancement New feature or request exporter/googlemanagedprometheus Google Managed Prometheus exporter priority:p2 Medium Stale
Projects
None yet
4 participants