How to pass jmx-metrics configuration parameters to the k8s opentelemetry auto-instrumentation injected java agent #9601
-
Hi, I hope I make myself clear to explain this question. I deployed in my k8s cluster the opentelemetry-operator and opentelemetry-collector using helm charts (https://opentelemetry.io/docs/kubernetes/getting-started/) with the objective to monitor a Java application, concretelly a JMX one. To monitor this JMX application I have injected the java auto-instrumentation agent into the java k8s container using the open-telemetry operator and creating an "Instrumentation" Custom Resource like somehow is explained here https://opentelemetry.io/docs/kubernetes/operator/automatic/#java or here https://github.com/open-telemetry/opentelemetry-operator#opentelemetry-auto-instrumentation-injection Now my next step should be to pass to this injected java auto-instrumentation agent the configuration to monitor the desired JMX MBeans like is required and explained here https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/jmx-metrics/javaagent#configuration-files However I couldn't figure out how to do it. I mean, in the previous doc is explained that for opentelemetry-java-instrumentation agent injected by a java command, this should be passed like
but i don't understand how to relate this line I searched in the API Reference for the opentelemetry Instrumentation CR (https://github.com/open-telemetry/opentelemetry-operator/blob/main/docs/api.md#instrumentation) but I can't see it there neither. Could someone shed some light here please? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
Instead of |
Beta Was this translation helpful? Give feedback.
-
Hi, I tried both options apiVersion: opentelemetry.io/v1alpha1
kind: Instrumentation
metadata:
name: java-autoinstrumentation
spec:
exporter:
endpoint: http://opentelemetry-collector.otel.svc:4317
propagators:
- tracecontext
- baggage
- b3
sampler:
type: parentbased_traceidratio
argument: "1"
java:
image: XXXXXX/open-telemetry/opentelemetry-operator/autoinstrumentation-java:1.25.1
env:
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: http://opentelemetry-collector.otel.svc:4317
- name: OTEL_JMX_CONFIG
# value: ./jmx_metrics_config.yaml
value: |
---
rules:
- bean: java.lang:type=Threading
mapping:
ThreadCount:
metric: my.own.jvm.thread.count
type: updowncounter
desc: The current number of threads
unit: "1"
resources:
limits:
memory: '400Mi'
cpu: '200m'
requests:
memory: '200Mi'
cpu: '100m' that's - name: OTEL_JMX_CONFIG
value: ./jmx_metrics_config.yaml or - name: OTEL_JMX_CONFIG
value: |
---
rules:
- bean: java.lang:type=Threading
mapping:
ThreadCount:
metric: my.own.jvm.thread.count
type: updowncounter
desc: The current number of threads
unit: "1" but none works. Anyone has tried to do something similar succesfully? |
Beta Was this translation helpful? Give feedback.
-
Also would be possible to have the java agent injected using the "Instrumentation" k8s CR as I did till now but passing the metric definitions via java command
without |
Beta Was this translation helpful? Give feedback.
Also would be possible to have the java agent injected using the "Instrumentation" k8s CR as I did till now but passing the metric definitions via java command
without
-javaagent:path/to/opentelemetry-javaagent.jar
?