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

[Question] Why does metricDescriptor have to be created from the app #360

Open
Jeyob opened this issue Nov 13, 2024 · 2 comments
Open

[Question] Why does metricDescriptor have to be created from the app #360

Jeyob opened this issue Nov 13, 2024 · 2 comments
Assignees

Comments

@Jeyob
Copy link

Jeyob commented Nov 13, 2024

Hi,

Couldn't find any better place to ask this question (so sorry in advance)

I was just curious to understand what the relationship is between opentelemetry instrumentation and the Terraform monitoring resource?

The CloudMonitoringMetricsExporter when sending the metrics also appears to be making requests to create metric descriptors thus requiring the "roles/monitoring.metricWriter" permission on the running identity.

but then what is the purpose of the terraform resource? It would have been quite neat if I could just define the metric descriptors through terraform and then have my application use that without having to add additional permissions.

Thanks!
Jonas

@Jeyob
Copy link
Author

Jeyob commented Nov 19, 2024

On second thought, one use case for having the terraform resource being created beforehand is that it does give us something to reference in Cloud monitoring dashboards I suppose, without data necessarily having to be present..

@dashpole
Copy link
Contributor

roles/monitoring.metricWriter is also required to call createTimeSeries, which writes the actual metric data. Even if you don't createMetricDescriptor, you will still need that permission.

If you call createTimeSeries, that will actually create a metric descriptor for you if one doesn't already exist. However, the unit and description of the metric are not populated (since createTimeSeries does not include those fields). We call createMetricDescriptor in order to populate those fields using the unit and description from the OpenTelemetry metric definition.

Using createMetricDescriptor isn't perfect. Requests often fail initially because of rate limiting, especially if a bunch of new metric descriptors are created at once, such as when starting a many replicas of the same pod (which each produce the same metrics). This just causes log spam, but can be confusing for users.

It can be tedious to create a terraform resource for each metric, since customers often have hundreds of metrics. Also, a typo or incorrect value type (int vs float) can cause metric writes to fail. So we generally recommend leaving managing descriptors to the exporter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants