opentelemetry-js icon indicating copy to clipboard operation
opentelemetry-js copied to clipboard

Support Resource in the Prometheus Exporter

Open mayurkale22 opened this issue 5 years ago • 11 comments
trafficstars

The Resources were added to the default SDK in opentelemetry-js#846. They need to be integrated in the export workflow of the Prometheus exporter similar to opentelemetry-js#843

mayurkale22 avatar Mar 17 '20 02:03 mayurkale22

What is the desired behaviour to support Resource? If there is clear guidance, I should be able to implement it.

I tried changing the PrometheusSerializer to append record.resource.attributes to the attributes for each metric unconditionally, but that looks like it might be too many attributes or too much data (especially for the unit tests, which have a full path to Node.js as the service_name).

michaelfig avatar Feb 15 '22 03:02 michaelfig

It is going to be specified at https://github.com/open-telemetry/opentelemetry-specification/pull/2266 to drop all resource attributes, only converting job and instance to Prometheus labels.

legendecas avatar Feb 15 '22 03:02 legendecas

Hi! To clarify things on my end: is this about exposing the resource attributes passed, for example to MeterProvider, in the exporter as the "target" info family metric like described here ?

klacabane avatar Jul 11 '22 15:07 klacabane

This is about including resource attributes as part of the serialized prometheus output data. As far as I know this behavior is actually not in the specification so this issue might actually just be closed as not planned. It is open so we can determine what other SIGs do with resource data in prometheus and attempt to be consistent.

dyladan avatar Jul 11 '22 20:07 dyladan

We have spec texts on how to transform OpenTelemetry resource attributes to Prometheus labels: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/data-model.md#resource-attributes-1.

legendecas avatar Jul 12 '22 03:07 legendecas

Similar issue in the net https://github.com/open-telemetry/opentelemetry-dotnet/issues/3087 and java sdk https://github.com/open-telemetry/opentelemetry-java/issues/4552 with a follow up discussion on potential specification improvements https://github.com/open-telemetry/opentelemetry-specification/issues/2640.

So we should be able to update the PrometheusSerializer.serialize function so that it also transforms the resource attributes available in the ResourceMetrics input to a target info group. Is there some other places that needs to be updated ?

klacabane avatar Jul 12 '22 09:07 klacabane

So we should be able to update the PrometheusSerializer.serialize function so that it also transforms the resource attributes available in the ResourceMetrics input to a target info group.

Yes, that's where we need to update. Do you plan to work on this? If so I can assign this to you.

legendecas avatar Jul 12 '22 09:07 legendecas

There is a related spec issue right now to determine precedence of keys https://github.com/open-telemetry/opentelemetry-specification/issues/2535

dyladan avatar Jul 12 '22 12:07 dyladan

@legendecas I'm trying to evaluate the work required for our use case atm. I'm still questioning what should happen downstream, in the collectors, as the info type does not appear to be supported. I've tried two parsing libraries and both ended in a failure to parse the metric type info. So I assume this needs a corresponding implementation in the other end ?

klacabane avatar Jul 12 '22 12:07 klacabane

@klacabane I'm not sure what you are referring to as the info type. I believe PrometheusSerializer.serialize is the place that needs to be updated to export resource attributes for downstream to take that into account.

legendecas avatar Jul 18 '22 17:07 legendecas

We need to transform the resource attributes into an info type in the PrometheusSerializer.serialize and I was wondering how the client pulling this data should interpret them. It's out of this issue's scope but I didn't find relevant informations. Currently the clients choke on the info metric type so my assumption is that clients would have to support this new type and have specific logic tying the attributes of the info block to the other metrics in the payload.

klacabane avatar Jul 19 '22 09:07 klacabane

I can work on this :slightly_smiling_face:

pichlermarc avatar Sep 28 '22 15:09 pichlermarc