Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance Metrics Reporter Policy documentation with EL samples (Logging of Arrays) #573

Open
apoddany opened this issue Oct 25, 2021 · 0 comments

Comments

@apoddany
Copy link
Contributor

Add some samples on how to log for example the Headers or Params of the Request.

One example to log the Request Headers in multiple ways :

{
    "requestId": "${request.id}",
    "transactionId": "${request.transactionId}",
    "requestHeaders": [
        "${request.headers['User-Agent'][0]}"
    ],
    "requestHeadersList": {
    <#list request.headers as header, value>
    "${header}": "${value?join(",
        ")}"<#sep>,
    </#list>
    },
    "requestHeadersList2": {
    <#list request.headers as header, values>
    "${header}": [
    <#list values as value>
    "${value}"<#sep>,
    </#list>
        ]<#sep>,
    </#list>
    },
    "requestMethod": "${request.method}",
    "uri": "${request.uri}",
    "path": "${request.path}",
    "planUsed": "${request.metrics.plan}"
}

this will result in the following output :

{
    "requestId": "589be0b2-4350-4d08-9be0-b243507d08a1",
    "transactionId": "589be0b2-4350-4d08-9be0-b243507d08a1",
    "requestHeaders": [
        "PostmanRuntime/7.28.4"
    ],
    "requestHeadersList": {
        "X-Forwarded-For": "12.34.56.78",
        "X-Forwarded-Proto": "https",
        "X-Forwarded-Port": "443",
        "Host": "api-dev.graviteeio.com",
        "X-Amzn-Trace-Id": "Root=1-615eead9-6d6e2ae5047bbca1301d6c59",
        "test": "test,123,456, sdfsdf",
        "User-Agent": "PostmanRuntime/7.28.4",
        "Accept": "*/*",
        "Postman-Token": "295d04d0-1a6e-4ef9-838d-271b5213ecb1",
        "Accept-Encoding": "gzip, deflate, br",
        "X-Gravitee-Transaction-Id": "589be0b2-4350-4d08-9be0-b243507d08a1",
        "X-Gravitee-Request-Id": "589be0b2-4350-4d08-9be0-b243507d08a1"
    },
    "requestHeadersList2": {
        "X-Forwarded-For": [
            "12.34.56.78"
        ],
        "X-Forwarded-Proto": [
            "https"
        ],
        "X-Forwarded-Port": [
            "443"
        ],
        "Host": [
            "api-dev.graviteeio.com"
        ],
        "X-Amzn-Trace-Id": [
            "Root=1-615eead9-6d6e2ae5047bbca1301d6c59"
        ],
        "test": [
            "test,123,456",
            "sdfsdf"
        ],
        "User-Agent": [
            "PostmanRuntime/7.28.4"
        ],
        "Accept": [
            "*/*"
        ],
        "Postman-Token": [
            "295d04d0-1a6e-4ef9-838d-271b5213ecb1"
        ],
        "Accept-Encoding": [
            "gzip, deflate, br"
        ],
        "X-Gravitee-Transaction-Id": [
            "589be0b2-4350-4d08-9be0-b243507d08a1"
        ],
        "X-Gravitee-Request-Id": [
            "589be0b2-4350-4d08-9be0-b243507d08a1"
        ]
    },
    "requestMethod": "GET",
    "uri": "/at/echo",
    "path": "/at/echo",
    "planUsed": "78033416-dce4-493a-8334-16dce4c93ada"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant