Loading

How to extract API Analytics Information (for apiId, OrgId, clientIP, requestBytes ,responseBytes, eventId) in mule 4 using custom policy.

Data pubblicazione: Aug 5, 2025
Fasi

CONTENT

STEPS TO FOLLOW

  • Create your own custom Policy by following the Getting Started with Custom Policy
  • Download and use the template to create your own custom policy 
  • The template provided would log the following information in the application logs
    • apiID, OrgID, EnvironmentID
    • Client IP
    • EventID
    • Content-Type
    • Request Message Size
    • Response Time(in milliseconds)
    • Response Message Size
  • A Sample application log with masked data is provided below
[00-00 00:00:00.000] INFO  LoggerMessageProcessor [[MuleRuntime].uber.11: [MulesoftSupportPolicy-1233456-sampleApplication-main].1233456-custom-policy.CPU_LITE @429b73e6] [event: 11111111-1111-1111-1111-111111111111]: apiID - 12345678 OrgID - 22222222-2222-2222-2222-222222222222  EnvironmentID - 33333333-3333-3333-3333-333333333333
[00-00 00:00:00.000] INFO  LoggerMessageProcessor [[MuleRuntime].uber.11: [MulesoftSupportPolicy-1233456-sampleApplication-main].1233456-custom-policy.CPU_LITE @429b73e6] [event: 11111111-1111-1111-1111-111111111111]: clientIP 255.255.255.255
[00-00 00:00:00.000] INFO  LoggerMessageProcessor [[MuleRuntime].uber.11: [MulesoftSupportPolicy-1233456-sampleApplication-main].1233456-custom-policy.CPU_LITE @429b73e6] [event: 11111111-1111-1111-1111-111111111111]: EventID 11111111-1111-1111-1111-111111111111
[00-00 00:00:00.000] INFO  LoggerMessageProcessor [[MuleRuntime].uber.11: [MulesoftSupportPolicy-1233456-sampleApplication-main].1233456-custom-policy.CPU_LITE @429b73e6] [event: 11111111-1111-1111-1111-111111111111]: ContentType application/json
[00-00 00:00:00.000] INFO  LoggerMessageProcessor [[MuleRuntime].uber.11: [MulesoftSupportPolicy-1233456-sampleApplication-main].1233456-custom-policy.CPU_INTENSIVE @188295db] [event: 11111111-1111-1111-1111-111111111111]: RequestMessageSize 1160
[00-00 00:00:00.000] INFO  LoggerMessageProcessor [[MuleRuntime].uber.11: [sampleFlow].get:\userName\(NameOfTheUser):sampleApplication-config.CPU_INTENSIVE @6fe67e3b] [event: 11111111-1111-1111-1111-111111111111]: 14 ms
[00-00 00:00:00.000] INFO  LoggerMessageProcessor [[MuleRuntime].uber.11: [MulesoftSupportPolicy-1233456-sampleApplication-main].1233456-custom-policy.CPU_INTENSIVE @188295db] [event: 11111111-1111-1111-1111-111111111111]: ResponseMessageSize 140
  • The provided sample is a guide to extract parameters in policy, the same idea can be extended as per the requirement. 

ADDITIONAL INFORMATION

Dataweave Predefined Variables
CloudHub Reserved Properties

Disclaimer: This example is provided as a reference for your own usage and is not to be considered a MuleSoft product. This example should be considered as a custom solution. The custom solution is not a Supported MuleSoft product.
Numero articolo Knowledge

001116217

 
Caricamento
Salesforce Help | Article