observability-zero-to-hero day-6

Β·

4 min read

observability-zero-to-hero day-6

πŸ•΅οΈβ€β™‚οΈ What is Jaeger?

  • Jaeger is an open-source, end-to-end distributed tracing system used for monitoring and troubleshooting microservices-based architectures. It helps developers understand how requests flow through a complex system, by tracing the path a request takes and measuring how long each step in that path takes.

❓ Why Use Jaeger?

  • In modern applications, especially microservices architectures, a single user request can touch multiple services. When something goes wrong, it’s challenging to pinpoint the source of the problem. Jaeger helps by:

  • 🐒 Identifying bottlenecks: See where your application spends most of its time.

  • πŸ” Finding root causes of errors: Trace errors back to their source.

  • ⚑ Optimizing performance: Understand and improve the latency of services.

πŸ“š Core Concepts of Jaeger

  • πŸ›€οΈ Trace: A trace represents the journey of a request as it travels through various services. Think of it as a detailed map that shows every stop a request makes in your system.

  • πŸ“ Span: Each trace is made up of multiple spans. A span is a single operation within a trace, such as an API call or a database query. It has a start time and a duration.

  • 🏷️ Tags: Tags are key-value pairs that provide additional context about a span. For example, a tag might indicate the HTTP method used (GET, POST) or the status code returned.

  • πŸ“ Logs: Logs in a span provide details about what’s happening during that operation. They can capture events like errors or important checkpoints.

  • πŸ”— Context Propagation: For Jaeger to trace requests across services, it needs to propagate context. This means each service in the call chain passes along the trace information to the next service.

🏠 Architecture

Project Architecture

βš™οΈ Setting Up Jaeger

Step 1: Instrumenting Your Code

  • To start tracing, you need to instrument your services. This means adding tracing capabilities to your code. Most popular programming languages and frameworks have libraries or middleware that make this easy.

  • We have already instrumented our code using OpenTelemetry libraries/packages. For more details, refer to day-4/application/service-a/tracing.js or day-4/application/service-b/tracing.js.

Step 2: Components of Jaeger

  • Jaeger consists of several components:

  • Agent: Collects traces from your application.

  • Collector: Receives traces from the agent and processes them.

  • Query: Provides a UI to view traces.

  • Storage: Stores traces for later retrieval (often a database like Elasticsearch).

Step 3: Export Elasticsearch CA Certificate

  • This command retrieves the CA certificate from the Elasticsearch master certificate secret and decodes it, saving it to a ca-cert.pem file.
kubectl get secret elasticsearch-master-certs -n logging -o jsonpath='{.data.ca\.crt}' | base64 --decode > ca-cert.pem

Step 4: Create Tracing Namespace

  • Creates a new Kubernetes namespace called tracing if it doesn't already exist, where Jaeger components will be installed.
kubectl create ns tracing

Step 5: Create ConfigMap for Jaeger's TLS Certificate

  • Creates a ConfigMap in the tracing namespace, containing the CA certificate to be used by Jaeger for TLS.
kubectl create configmap jaeger-tls --from-file=ca-cert.pem -n tracing

Step 6: Create Secret for Elasticsearch TLS

  • Creates a Kubernetes Secret in the tracing namespace, containing the CA certificate for Elasticsearch TLS communication.
kubectl create secret generic es-tls-secret --from-file=ca-cert.pem -n tracing

Step 7: Add Jaeger Helm Repository

  • adds the official Jaeger Helm chart repository to your Helm setup, making it available for installations.
helm repo add jaegertracing https://jaegertracing.github.io/helm-charts

helm repo update

Step 8: Install Jaeger with Custom Values

  • πŸ‘‰ Note: Please update the password field and other related field in the jaeger-values.yaml file with the password retrieved earlier in day-4 at step 6: (i.e NJyO47UqeYBsoaEU)"

  • Command installs Jaeger into the tracing namespace using a custom jaeger-values.yaml configuration file. Ensure the password is updated in the file before installation.

helm install jaeger jaegertracing/jaeger -n tracing --values jaeger-values.yaml

Step 9: Port Forward Jaeger Query Service

  • Command forwards port 8080 on your local machine to the Jaeger Query service, allowing you to access the Jaeger UI locally.
kubectl port-forward svc/jaeger-query 8080:80 -n tracing

🧼 Clean Up

helm uninstall jaeger -n tracing

helm uninstall elasticsearch -n logging

# Also delete PVC created for elasticsearch

helm uninstall monitoring -n monitoring

cd day-4

kubectl delete -k kubernetes-manifest/

kubectl delete -k alerts-alertmanager-servicemonitor-manifest/

# Delete cluster
eksctl delete cluster --name observability

Application code: https://github.com/bittush8789/observability-zero-to-hero/tree/main/day-6

Happy Leaning…….

Β