I am looking into how we can improve logging across our microservice architecture applications.
The ask is that we have some way of being able to group all logs by the session they belong to, so we can more easily see the journey the user has been on that has results in any issue.
I am a little bit out of my comfort zone on this one, but it looks like a couple of reasonable options might be either to use - X-Amzn-Trace-Id from the ALB requests, or to use AWS X-Ray
Has anyone got good experience of this and able to give some pointers?
I highly recommend using tracing rather than logging. Honeycomb is a great tracing vendor. Basically, any info you would have put into a log message can go as a string attribute in your trace, and they’re structured like the call graph of each request rather than an undifferentiated stream of text
You want to look at Real user monitoring if you want session based, user journey information.
Most observability platforms have this ( including Cloudwatch and Honeycomb)
If you use RUM with Cloudwatch, you can enable x ray checkbox on the client side and it will correlate with traces too
Traces are based off requests and not a session so May not be what you want.
I will go cloud agnostic way unless AWS offers certain features that are difficult to beat.
These came to my mind:
A) Enable “auditd” -this generates audit info, it is a robust solution and does not allow others to mess around. You can set rules - these settings can provide rich information such as file access, kernel modules usage, among other system activities. Since everything in Linux is a file, you can check if any read / write happens (as an example).
B) Prometheus & Graphana (popular for micro-services), Splunk, Datadog, netdata (simple to install, easy to monitor, provides in-built helpful information on the systems behavior: https://www.netdata.cloud), etc., etc.
C) Copy logs (or stream logs) and put them in a database such as Postgres. Easy to run queries. You may also use Kafka, Spark streaming, etc. This can be overkill, but useful to think if you wanted to do data warehousing type analytics, AI/ML and other advanced activities on the logs.
D) Use automation tools such as Ansible to aggregate logs. This approach scales well, relatively easy to grow.
E) May be, just forget all the above. Bring all logs into a machine (set SSH keys, copy all logs to this machine), run bash scripts (cut, awk and others).
In short: it depends on what you want to do; think long term as well.