Reputation: 21
I am fetching multiple logs from Loki in Grafana, and I want to mask sensitive data (like IP addresses, email addresses, and names) before downloading the logs using the Grafana UI.
The requirement is as follows:
Logs should remain in their original form when viewed in Grafana. When downloaded, the logs must have sensitive data (e.g., IPs, emails, names) masked. What I’ve tried: I attempted to use the following LogQL query with a replace function to mask IP addresses:
{filename="PATH"}
| regexp "(?P<ip>[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3})"
| line_format "{{ replace .line .ip \"***\" }}"
However, this approach does not work. I’m unsure if it’s an issue with how replace is used in the query or if there’s another solution I should try.
Is there a way to achieve this masking behavior in Grafana/Loki while still maintaining the original logs for display? Any ideas or alternative approaches are welcome.
Upvotes: 1
Views: 70