You did the correct thing to get ${requestid} associated with the flow. The Gateway is stateless by nature, so "flow" doesn't mean anything to it. Thus you need to pass state via the messages, most often as a header. Adding a correlationID is a relatively common thing to do. I usually use a global Message Received policy to check the incoming request for the header and if one is not added then I either generate a GUID as the correlationID or, as you have done, use ${requestid}. Note that the length of ${requestid} changes over time (see the docs for how it is formatted) since it is essentially a counter from a start time, which can can "funkiness" for some displays, which is why I sometimes use a GUID for the correlationID. Anyway, once it is set in the Global Message Received policy as ${correlationID} (either from the header or as a new value) I then export it (Export Variable assertion) and can then reference it as ${request.shared.correlationID} from all policies. To add it to audit records set the audit.log.service.headerFormat, audit.log.service.detailFormat, and audit.log.service.footerFormat cluster-wide properties to include ${request.shared.correlationID}. Note that this DOES NOT automatically add it to log records, so if you are writing directly to a log using the Add Audit Detail assertion then you must include ${request.shared.correlationID} in the string defined by the assertion.
------------------------------
Jay MacDonald - Adoption Architect - Broadcom API Management (Layer 7)
------------------------------
Original Message:
Sent: 11-14-2019 09:41 AM
From: Marcin Sek
Subject: Tracking id for logs
Hello,
I wanna add some tracking ID to logs. I use some internal calls, and wanna highlight one id too see all messages related to each other. There is gateway variable requestid - but it's unique for each service call, so for my internal calls it changes 2-3 times per "flow".
So I started to adding request id to header and pass to next service - what is working. But it's not perfect. I put my track id each line - where I can, but I must remember about it. Secondly I can add this variable only where I explicitly add logs - so I can't add it to line like:
2019-11-14T15:19:10.125+0100 INFO 2335 com.l7tech.server.message: Processing request for service: Webview [/webview]
But I can see it here:
2019-11-14T15:19:10.122+0100 INFO 2335 com.l7tech.server.policy.assertion.ServerAuditDetailAssertion: -5: Tracking-id: 0000016e69b2ba36-c1
So the question is - if there is another way to set some uuid per flow - not per service?