Join fellow LogicMonitor users at the Elevate Community Conference and get hands-on with our latest product innovations.

Register Now

Resources

Explore our blogs, guides, case studies, eBooks, and more actionable insights to enhance your IT monitoring and observability.

View Resources

About us

Get to know LogicMonitor and our team.

About us

Documentation

Read through our documentation, check out our latest release notes, or submit a ticket to our world-class customer service team.

View Resources

Automatic Instrumentation using the OpenTelemetry Operator for Applications in Kubernetes

Last updated on 07 November, 2024

When instrumenting an application in your Kubernetes infrastructure, you can leverage OpenTelemetry’s operator for Kubernetes. This allows you to automatically instrument your application by deploying the operator, defining an instrumentation resource, and then using an annotation to inject that instrumentation for your application containers.

Use OpenTelemetry Operator for Kubernetes from OpenTelemetry along with the following information to use OpenTelemetry’s operator.

Automatically Instrumenting an Application using the OpenTelemetry Operator

  1. Deploy OpenTelemetry’s Operator using Getting Started from OpenTelemetry.
  2. Define a custom instrumentation resource by providing sampling preferences, the LM OTEL Collector endpoint, and resource attributes to map traces to the correct monitored infrastructure in LogicMonitor to create a custom instrumentation resource similar to the following:
kind: Instrumentation

metadata:

  name: my-instrumentation

spec:

  env:

  - name: OTEL_POD_IP

    valueFrom:

      fieldRef:

        fieldPath: status.podIP

  exporter:

    endpoint: http://mylmotelcollector.endpoint/

  resource:

    addK8sUIDAttributes: true

    resourceAttributes:

{     "resource.type" : "kubernetes-pod",     "ip" : "$(OTEL_POD_ID)"     }

  propagators:

    - tracecontext

    - baggage

    - b3

  sampler:

    type: parentbased_traceidratio

    argument: "0.25"
  1. Apply the pod annotation to pods running applications for automatic instrumentation. This injects the auto instrumentation agent as an init container that downloads the JAR and makes it accessible to the application at startup. For example, you can patch your application deployment using the following:
kubectl patch deployment my-deployment -p '{"spec": {"template":{"metadata":{"annotations":{"instrumentation.opentelemetry.io/inject-java":"my-instrumentation"}}}} }'
In This Article

Start Your Trial

Full access to the LogicMonitor platform.
Comprehensive monitoring and alerting for unlimited devices.