'Datadog agent scrub password from an url
I am following the documentation to scrub sensitive data from your logs in a docker environment.
I am looking for the correct label to use to scrub password from this log
XXX url=https://username:password@host:port/path response_code=200 return_code=ok
I want this result for my log
XXX url=https://username:****@host:port/path response_code=200 return_code=ok
So I guess I should do something like this...
labels:
com.datadoghq.ad.logs: >-
[{
"source": "app",
"service": "api",
"log_processing_rules": [{
"type": "mask_sequences",
"name": "mask_password",
"replace_placeholder": "$1$2:****@$4",
"pattern" : "(?<protocol>.+?\/\/)(?<username>.+?):(?<password>.+?)@(?<address>.+)"
}]
}]
What are the values I should use for pattern and replace_placeholder ? Thanks !
Solution 1:[1]
Try this pattern: https://(.*):(.*)@
This will give you two captures, so username will be in $1 and password in $2. So for your placeholder, try https://{$1}:xxxx@
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | bwest |
