We're using the APM Python Flask agent to trace HTTP transactions and collect service metrics and Filebeat+Logstash for collecting service logs. We would like to link logs with the APM metrics:
- Using the APM transaction ID seems like a good idea but how the transaction ID can be accessed using the APM Flask agent?
- Moreover, we'd like to replace the APM transaction ID with the Nginx $request_id since Nginx is higher in the stack. This way, Nginx logs, APM metrics, and service logs can all be linked using the Nignx $request_id. How the APM transaction ID can be set using the APM Flask agent such that the set transaction ID gets propagated to the downstream services?
- Any recommended ways to implement 1 and 2?
- Any pitfalls that we need to be aware of when setting and getting a transaction ID?