Launch OpenTelemetry in eks and collect the metric, trace, logs

Use Helm+Terraform to installing and initialization the OpenTelmetry and Enable auto instrumentation the workloads

Dowload the OpenTelmetry Operator Helm package to local

1# add OpenTelemetry chat repo
2helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts
3# pull the chat package
4helm pull open-telemetry/opentelemetry-operator
5# https://github.com/open-telemetry/opentelemetry-demo
6# Or download the opentelmetry-demo chat
7helm pull open-telemetry/opentelemetry-demo
8tar -xzvf opentelemetry-operator-0.24.1.tgz
9tar -xzvf opentelemetry-demo-0.19.1.tgz

Create OpenTelmetry resources in Terraform code

  • The namesapce resource named to opentelemetry
 1resource "kubernetes_namespace" "opentelemetry" {
 2    metadata {
 3      annotations = {
 4        name = "opentelemetry"
 5      }
 6      labels = {
 7        "kubesphere.io/namespace" = "opentelemetry"
 8      }
 9      name = "opentelemetry"
10    }
11}
  • Create opreator resource
 1resource "helm_release" "opentelemetry_operator" {
 2    name = "opentelemetry-operator"
 3    chart = "./charts/opentelemetry-operator"
 4    namespace = kubernetes_namespace.opentelemetry.metadata.0.name
 5
 6    values = [
 7        <<-EOF
 8        manager:
 9          image:
10            repository: myregister.com/opentelemetry/operator
11            tag: v0.70.0
12          collectorImage:
13            repository: myregister.com/opentelemetry/collector-contrib
14            tag: 0.72.0
15          autoInstrumentationImage:
16              java:
17                repository: "myregister.com/otlp/javaagent"
18                tag: "v1.0-23.0"
19              nodejs:
20                repository: "myregister.com/otlp/nodejs"
21                tag: "v1.0-16"
22              python:
23                repository: "myregister.com/otlp/python"
24                tag: "v1.0"
25              dotnet:
26                repository: "myregister.com/otlp/dotnet"
27                tag: "v1.0-6.0"
28        kubeRBACProxy:
29            image:
30                repository: myregister.com/kubebuilder/kube-rbac-proxy
31                tag: v0.13.0
32
33
34        EOF
35    ]
36}
  • Create instrumetation custom resource
 1resource "helm_release" "opentelemetry_instrumentation" {
 2   name = "opentelemetry-instrumentation"
 3   chart = "./charts/raw"
 4   namespace = "workloads-apps"
 5   values = [
 6        <<-EOF
 7        nameOverride: opentelemetry-instrumentation
 8        resources:
 9            - apiVersion: opentelemetry.io/v1alpha1
10              kind: Instrumentation
11              metadata:
12                name: opentelemetry-instrumentation
13              spec:
14                exporter:
15                  endpoint: http://signoz-otel-collector.signoz:4317
16                propagators:
17                  - tracecontext
18                  - baggage
19                  - b3
20                sampler:
21                  type: parentbased_traceidratio
22                  argument: "0.25"
23                nodejs:
24                  env:
25                    - name: OTEL_EXPORTER_OTLP_ENDPOINT
26                      value: http://signoz-otel-collector.signoz:4317
27                dotnet:
28                   env:
29                     - name: OTEL_EXPORTER_OTLP_ENDPOINT
30                       value: http://signoz-otel-collector.signoz:4318
31                java:
32                    env:
33                      - name: OTEL_EXPORTER_OTLP_ENDPOINT
34                        value: http://signoz-otel-collector.signoz:4317
35                python:
36                  env:
37                    # Required if endpoint is set to 4317.
38                    # Python autoinstrumentation uses http/proto by default
39                    # so data must be sent to 4318 instead of 4137.
40                    - name: OTEL_EXPORTER_OTLP_ENDPOINT
41                      value: http://signoz-otel-collector.signoz:4318
42        EOF
43   ]
44}

Enable the pod to instrumetation the app

add annotations to deployment spec template sections

 1# for java
 2spec:
 3  replicas: 1
 4  selector:
 5    matchLabels:
 6      app: opentelemetry-demo-for-java
 7  template:
 8    metadata:
 9      annotations:
10          instrumentation.opentelemetry.io/inject-java: 'true'
11# for dotnet use following annotation
12annotations:
13    instrumentation.opentelemetry.io/container-names: dotnet-for-instrumentation
14    instrumentation.opentelemetry.io/inject-dotnet: 'true'        

Also use open source Signoz as Telemetry backend and frontend tools

1# add signoz helm chat repo
2helm repo add signoz https://charts.signoz.io
3tar -xzvf signoz-0.11.3.tgz