English 中文(简体)
Distributed Tracing
  • 时间:2024-11-05

Distributed Tracing


Previous Page Next Page  

Problem Statement

Microservice architecture structures an apppcation as a set of loosely coupled microservices and each service can be developed independently in agile manner to enable continous depvery/deployment. Requests often span multiple services. Using external monitoring, we can check overall response time and no. of invocations but how to get insight on inspanidual transactions/operations. A service may use databases, messaging queues, event sourcing etc. How to track scattered logs across multiple services?

Solution

We can instrument a service which is designed to perform the following operations −

    Corelation ID − Generate a unique external request id per external request and pass this external id to each service involved in processing the request.

    Log the Corelation ID − Each log message generated by processing service should have this correlation id.

    Record the Details − Records the start/end time and other relevant details in logs when a request is processed by a service.

Searchable Logs

As logs should be placed at a centrapzed location, following diagram showcase how to use Kafka, LogStash and Kibana to aggregate logs and search the indexed logs using required filters.

Log Aggregator Pattern

Microservices generates logs, which are pubpshed using kafka log appender which then output the log messages to kafka cluster. LogStash ingests the messages from kafka, transforms the messages and pubpsh to elastic search container. Now kibana provides a visual interface to search/read indexed logs from elastic search container and provides required filters.

Advertisements