How to Create Indexed Attributes with opentelemetry-spring-boot-starter Exporting to ELK #12072
-
I am using opentelemetry-spring-boot-starter 2.7.0 in my application, along with the OpenTelemetry Collector to centralize metrics and traces, exporting this data to the ELK Stack. In the Elastic APM documentation, when using the Elastic agent, there is a functionality called transaction.addTag that allows adding tags/attributes which are automatically indexed in Elasticsearch (documentation: Elastic APM Java Agent - addTag). My question is: What is the equivalent of this functionality when using only opentelemetry-spring-boot-starter and OpenTelemetry? I tried the following code:
However, I noticed that this only creates non-indexed attributes in Elasticsearch. How can I ensure that these attributes are indexed correctly? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
cc @jackshirazi |
Beta Was this translation helpful? Give feedback.
-
Hi @Watlaass, I am not very familiar with the OpenTelemetry collector exporting to ELK, however I can describe how it works with the APM server: With the APM agent, the fields that are added with When using an OpenTelemetry API or instrumentation agent, a custom attribute So while the naming isn't 100% preserved, you should be able to search by order ID. Can you link on the collector/extensions version and configuration of the otel collector that you used to write to Elasticsearch here ? |
Beta Was this translation helpful? Give feedback.
-
Hi @SylvainJuge Yes, the field is indeed sent as labels.order_id. However, the issue is that this attribute is not being indexed in ELK, which prevents global searches in Kibana or creating dashboards based on this attribute. As a result, the field remains just as metadata within the specific transaction, without the ability to be used in broader queries or visualizations. As requested, I’m sharing the relevant configuration below. Here are the Docker Compose file and the specific part of the ELK configuration:
|
Beta Was this translation helpful? Give feedback.
So if I understand this correctly you are exporting to apm-server via the OTLP protocol, not using the otel collector Elasticsearch exporter with the ECS mapping, so what I wrote previously about APM server mapping should apply here.
The labels should be indexed as keywords, can you check the index template in Kibana by going in
Stack Management
>Index Management
>Index Templates
tab, then open thetraces-apm
managed template.Then on the right panel, on the 4th and last tab named
Preview
you should see the JSON of the index template, it should contain this forlabels.*
and similar fornumerical_labels.*
: