kubernetes logo

Kubernetes Tutorial : Distributed tracing with Jaeger

Jaeger is an open-source distributed tracing system by Uber Technologies. Like Dapper or Zipkin, it is used for monitoring and troubleshooting microservices-based distributed systems. In this post, we are going to look at how to deploy Jaeger to the Kubernetes cluster.

This quickstart assumes a basic understanding of Kubernetes concepts, please refer to earlier posts for understanding on Kubernetes & how to create, deploy & rollout updates to the cluster.

Jaeger Distributed Tracing
Image – Jaeger Distributed Tracing

#1.Why Distributed Tracing?

In the Microservices architecture, the application is usually structured as a set of loosely coupled, collaborating services. Each service implements a set of related functions. For example, an application might consist of services such as the order management service, the customer management service, etc. Services communicate using either synchronous protocols such as HTTP/REST or asynchronous protocols such as AMQP. Services can be developed and deployed independently of one another. Each service has its own database in order to be decoupled from other services. For more intro on Microservice architecture, check out here.

Service requests often span multiple services. Each service handles a request by performing one or more operations, e.g. database queries, publishes messages, etc. To understand the behavior of an application and troubleshoot problems there is a need to monitor each service but if you use any of the external monitoring tools, it only tells you the overall response time and number of invocations but there would be no insight into the individual operations. To understand how each service is performing we would need to instrument services with code that will do the following

  1. Assign each external request a unique external request id
  2. Pass the external request id to all services that are involved in handling the request
  3. Include the external request id in all log messages
  4. Record information (e.g. start time, end time) about the requests and operations performed when handling an external request in a centralized service

So this where Jaeger can help us, it supports the OpenTracing initiative and can be used for monitoring microservices-based distributed systems:

  • Distributed context propagation
  • Distributed transaction monitoring
  • Root cause analysis
  • Service dependency analysis
  • Performance / latency optimization

#2.Key Features of Jaeger

  • High Scalability – Jaeger backend is designed to have no single point of failure and to scale with the business needs.
  • Native support for OpenTracing – Jaeger backend, Web UI, and instrumentation libraries have been designed from the ground up to support the OpenTracing standard.
  • Storage Backend – Jaeger supports two popular open-source NoSQL databases as trace storage backends: Cassandra 3.4+ and Elasticsearch 5.x/6.x.
  • Modern UI – Jaeger Web UI is implemented in Javascript using popular open-source frameworks like React.
  • Cloud-Native Deployment – Jaeger backend is distributed as a collection of Docker images. Deployment to Kubernetes clusters is assisted by Kubernetes templates and a Helm chart.
  • All Jaeger backend components expose Prometheus metrics by default.

#3.Jaeger Architecture

Jaeger Tracing Architecture
Image – Jaeger Tracing Architecture

Following are the Key components of Jaeger

  • Jaeger clients: These are language-specific implementations of the OpenTracing API. They can be used to instrument applications for distributed tracing either manually or with open source frameworks. Jaeger’s clients adhere to the data model described in the OpenTracing standard.
  • Jaeger agent: Network daemon that listens for spans sent over UDP, which it batches and sends to the collector.
  • Jaeger collector: Receives traces from Jaeger agents and runs them through a processing pipeline.
  • Query: Service that retrieves traces from storage and hosts a UI to display them.

An instrumented service creates spans when receiving new requests and attaches context information (trace id, span id, and baggage) to outgoing requests. This instrumentation has very little overhead and is designed to be always enabled in production.

Span represents a logical unit of work in Jaeger that has an operation name, the start time of the operation, and the duration. Spans may be nested and ordered to model causal relationships. Trace is a data/execution path through the system and can be thought of as a directed acyclic graph of spans.

Distributed Tracing -Trace & Spans
Image – Distributed Tracing -Trace & Spans

In the next section, we will learn how to deploy Jaeger on the Kubernetes cluster.

#4.Deploy Jaeger Template on Kubernetes Cluster

Assuming you already have the Kubernetes cluster ready, Deploying Jaeger is just a simple 1-step procedure. If you want to set up the Kubernetes cluster and get a basic understanding of Kubernetes concepts, please refer to earlier posts for understanding on Kubernetes & how to create, deploy & rollout updates to the cluster.

Execute kubectl create deployment on your cluster. What I have is just a sample template and not to be used in a production environment.

kubectl create -f https://raw.githubusercontent.com/jaegertracing/jaeger-kubernetes/master/all-in-one/jaeger-all-in-one-template.yml

Jaeger Template deployment
Image – Jaeger Template deployment

Post Kubectl create command, you can use Kubectl get command to see the deployments.

Kubectl get deployments command
Image – Kubectl get deployments command

Use kubectl get service jaeger-query to find Jaeger URL.

Get Jaeger URL
Image – Get Jaeger URL

To understand what we have accomplished, the Jaeger template has instrumented services with code that will do the following

  1. Assign each external request a unique external request id
  2. Pass the external request id to all services that are involved in handling the request
  3. Include the external request id in all log messages
  4. Record information (e.g. start time, end time) about the requests and operations performed when handling an external request in a centralized service

Congrats! today we have learned what is Jaeger tracing & how to do deploy it to the Kubernetes cluster.

If you’re looking to run along with Helm, check out, here.

#5.Sample Traces View

Jaeger Traces
Image – Jaeger Traces
Trace Detail View
Image – Traces Detail View

Like this post? Don’t forget to share it!

Useful Resources :

Summary
Kubernetes Tutorial : Distributed tracing with Jaeger
Article Name
Kubernetes Tutorial : Distributed tracing with Jaeger
Description
Jaeger is a distributed tracing system. Like Dapper or Zipkin,it is used for monitoring and troubleshooting microservices-based distributed systems. In this post, we are going look at how to deploy Jaeger on to Kubernetes cluster.
Author
Publisher Name
Upnxtblog
Publisher Logo

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Aadhaar Previous post How to apply for instant e-PAN ?
Next post MiniTool ShadowMaker Backup Solution for PCs