How to Configure Configure Audit Logs for Queries for Grafana

Published
Length
3 min read

Luis Felipe Dias

All posts

To configure audit logs for queries for grafana, you enable query logging in your system settings. This setup records who ran each dashboard request and what data source it hit. Teams use Grafana to read metrics and logs across many backends. Without clear records, you cannot tell which user ran a heavy or sensitive request. Setting up query tracking helps security teams check data usage and spot odd habits. How to configure audit logs for queries for grafana Grafana connects to your databas

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

To configure audit logs for queries for grafana, you enable query logging in your system settings. This setup records who ran each dashboard request and what data source it hit.

Teams use Grafana to read metrics and logs across many backends. Without clear records, you cannot tell which user ran a heavy or sensitive request. Setting up query tracking helps security teams check data usage and spot odd habits.

How to configure audit logs for queries for grafana

Grafana connects to your databases and log stores using shared service accounts. When a user opens a dashboard, the app sends a request to the backend. By default, the database only sees the shared Grafana service role. It does not see the specific human user who clicked the panel.

To fix this gap, you turn on request logging in the Grafana server settings. This setting writes an event each time a user or dashboard queries a data source. The log entry captures the user identity, the time, and the target data source. You can send these events to a local file or a central log store.

This setup affects both human users and automated API keys. Every panel load, explore view run, and alert check creates a record. Safe defaults mean logging all read events on sensitive data sources from day one. You should also limit who can read or delete the log files on the server. Keep the log output on a separate volume so full disks do not stop dashboards.

How to check logs and spot static setup gaps

After you turn on logging, you must test that records show up as expected. Log in as a test user and run a fresh query in the explore view. Check your central log store to confirm the event shows the right user email. Make sure the log includes the raw query text and the data source name.

You should also check how the system handles failed requests and timeouts. Good audit trails record both blocked attempts and slow runs that strain the database. Set up a daily check to confirm that log delivery stays active.

Kubernetes Audit Logs + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Static logging in Grafana still leaves big security gaps once a session starts. The app logs the request, but it still uses one broad database credential underneath. Anyone with explore rights on that data source can query every table that role reaches. Static logs only tell you about a bad query after the data leaves the store. They do not block risky commands or rewrite sensitive fields like emails or card numbers.

Ways to manage sensitive data in query results

Logs alone cannot stop a user from pulling customer phone numbers or national IDs. When a dashboard or user runs a wide query, the database returns all matching rows. If the shared database role has read rights, the user gets the full text. Plus, sensitive strings might end up written inside the audit log file itself.

Teams should pair query logging with strict role limits in the target database. Create read roles that only touch the exact tables needed for charts. Do not give the dashboard app a root database key. If users need to run raw queries, split those data sources from standard dashboard views. Review your query logs every week to find broad requests and tighten database permissions.

Add runtime guardrails and masking beside your databases and APIs

Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.

Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.

Frequently asked questions

Does Grafana log every database query by default?

No, standard server logs focus on system errors and basic web requests. You must enable specific auditing or request logging settings to capture every data source query.

Why does my database log only show one Grafana user?

Grafana uses a single saved credential for each configured data source. The database only sees that shared service role unless you pass user headers or log inside Grafana.

Can audit logs contain sensitive customer data?

Yes, if a user puts emails or card numbers in a query filter, the log records it. You must secure audit log files with the same care as your main database.

The query runs. The emails stay hidden.