How to track session across several web apps, multiple microservices

1/20/2019

I would like to track a session across multiple web applications, multiple microservices. All of my web applications are static files and microservices are running under nodejs containers with Kubernetes.

I have tracking setup across separate web applications and separate microservices. But it too cumbersome to merge and view everything in a single view.

Is there any approach to view all of them under single session?

-- Kannaiyan
containers
kubernetes
logging
microservices
session

2 Answers

1/24/2019

You can trace HTTP requests across different microservices (apps) using a special header to correlate all subsequent requests to the original one.

For example, your web app sends a HTTP request (REST API call) to the first microservice (A) which finds that the request does not have a correlation ID (x-correlationid header) and adds it, then saves that correrlation id into the current call/session context and forwards it to all subsequent API calls to other microservices. then when all other microservices are following the same logic they will also add/use the correlation ID, you will have the ability to trace a request throughout all the microservices in the system.

this pattern is used by many APM (application performance monitoring) tools. and once all your logs are aggregated in one place, you can then filter your queries by a certain correlation ID to see the full trace of a specific user request/operation.

-- Bishoy
Source: StackOverflow

1/20/2019

Kubernetes itself do not support any request tracing, but you can use Istio together with Kubernetes, which has Distributed Tracing feature.

In short, your application will need to resend attached headers and Istio will detects it, collect information from all your services and show you requests tracing.

Also, it supports Mesh, so, theoretically, your application can work a bit faster and secure (because of network rules).

You can read about Istio here, about tracing here and here is an instruction of how to setup it in Kubernetes.

-- Anton Kostenko
Source: StackOverflow