Kubernetes Tutorial : Distributed tracing with Jaeger
Jaeger is a distributed tracing system released as open source by Uber Technologies. 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.
Why Distributed Tracing ?
In the Microservices architecture,application is structured as a set of loosely coupled, collaborating services. Each service implements a set of narrowly, 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,check out here.
Services 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 need to monitor each service but if you use any of the external monitoring tool,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 services is performing we would need to instrument services with code that will do the following
- Assigns each external request a unique external request id
- Passes the external request id to all services that are involved in handling the request
- Includes the external request id in all log messages
- Records information (e.g. start time, end time) about the requests and operations performed when handling a external request in a centralized service
So this where Jaeger can help us,it support OpenTracing initiative & can be used for monitoring microservices-based distributed systems:
- Distributed context propagation
- Distributed transaction monitoring
- Root cause analysis
- Service dependency analysis
- Performance / latency optimization
Key Features of Jaeger
- High Scalability – Jaeger backend is designed to have no single points of failure and to scale with the business needs.
- Native support for OpenTracing – Jaeger backend, Web UI, and instrumentation libraries have been designed from 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.
- 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
Following are the key components of Jaeger
- Jaeger clients : They 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. The 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.
Deploy Jaeger Template on Kubernetes Cluster
Assuming you already have Kubernetes cluster ready up & running,Deploying Jaeger is just simple 1-step procedure.If you want to setup Kubernetes cluster & get basic understanding of Kubernetes concepts, please refer earlier posts for understanding on Kubernetes & how to create,deploy & rollout updates to the cluster.
kubectl create deployment on your cluster,this is just sample template and not to be used in production environment.
kubectl create -f https://raw.githubusercontent.com/jaegertracing/jaeger-kubernetes/master/all-in-one/jaeger-all-in-one-template.yml
Kubectl create command,you can use
Kubectl get command to see the deployments.
kubectl get service jaeger-query to find Jaeger URL.
To view traces,visit the Jaeger URL.
Congrats! today we have learnt what is Jaeger tracing & how to do deploy to Kubernetes cluster.
If you’re looking to run along with Helm,check out,here.
Sample Traces View
Like this post? Don’t forget to share it!