krakend-ce
krakend-ce copied to clipboard
Add / Concat JWT claims to log messages
Environment info: devopsfaith/krakend:2.0.4 successfully deployed with flexible configuration.
Describe what are you trying to do: I'm already propagating some JWT claims as HTTP Headers to the up stream services (backend). However, for tracebility and log filtering reasons, I would also like to concatenate these headers accross all log messages (I'm using EFK stack for logging).
Is this somehow possible?
Your configuration file: krakend.json snippet
{
"$schema": "https://www.krakend.io/schema/v3.json",
"version": 3,
"name": "API Gateway",
"timeout": "10000ms",
"cache_ttl": "300s",
"output_encoding": "no-op",
"sequential_start": true,
"extra_config":
{
"telemetry/logging":
{
"level": "DEBUG",
"prefix": "[KRAKEND]",
"syslog": false,
"stdout": true,
"format": "logstash"
}
},
"endpoints":
[
{
"endpoint": "/admin/tenants",
"method": "GET",
"extra_config":
{
"auth/validator":
{
"alg": "RS256",
"jwk_url": "http://ms-jwks.backoffice/.well-known/jwks.json",
"disable_jwk_security": true,
"cache": true,
"roles_key_is_nested": true,
"roles_key": "resource_access.admin.roles",
"roles":
[
"Admin"
],
"scopes_key": "scope",
"scopes":
[
"profile"
],
"scopes_matcher": "any",
"propagate_claims":
[
[
"realm",
"X-TenantId"
]
],
"operation_debug": true
}
},
"output_encoding": "no-op",
"input_headers":
[
"*"
],
"input_query_strings":
[
"*"
],
"backend":
[
{
"url_pattern": "/tenants",
"method": "GET",
"encoding": "no-op",
"sd": "static",
"disable_host_sanitize": true,
"host":
[
"http://ms-admin.backoffice"
]
}
]
}
]
}
Additional comments:
For example, in the configuration snippet above, I would like to concat JWT.realm to all log messages. Something like:
"telemetry/logging":
{
"level": "DEBUG",
"prefix": "[ {JWT.realm} ]",
"syslog": false,
"stdout": true,
"format": "logstash"
}
Any news about this?
This is not possible out of the box. You should create a plugin for a feature like this.
This issue was marked as resolved a long time ago and now has been automatically locked as there has not been any recent activity after it. You can still open a new issue and reference this link.