Does Prometheus keep an audit log of who ran each query?
A security reviewer asking which user ran which query needs a direct answer: Prometheus does not keep an audit log. It provides a query log from version 2.16.0 onward, and that log has no user identity field. Each entry records the query, its start, end and step, engine timing statistics, and the time it ended. For queries from the API and consoles, it also records the network address of the client, method and path. Anything that identifies a person has to come from somewhere else.
Closing that gap takes three pieces. First, place an authenticating reverse proxy in front of the web UI and API so every request is tied to a named identity, and configure that proxy to log the user, the original caller and the request path, since the Prometheus log ignores headers such as X-Forwarded-For. Second, enable the query log by setting query_log_file in the global section of prometheus.yml and reloading the configuration. Third, retain both sources together on a schedule your policy sets, using an external tool such as logrotate, because Prometheus does not rotate the query log itself.
Confirm three things before relying on this design. Check that prometheus_engine_query_log_enabled reads active on every server, and alert on prometheus_engine_query_log_failures_total, since failed writes mean missing entries. Confirm with your proxy vendor how it correlates its own log lines with Prometheus query timestamps. Finally, ask your compliance lead whether a reverse proxy log and a query log meet the evidence standard you have agreed with your auditor, because DeployOpen prepares these records but does not decide what an assessor will accept. The Prometheus query log guide lists the exact fields to plan around.
Audit logging capabilities in Prometheus and what they need
This table compares each audit-related capability Prometheus offers or lacks, and marks whether it is built in, needs an outside component, or is not available. Read it as a list of gaps to close: the query log gives you what was asked and when, while the user identity and admin action trail have to come from a proxy or another system.
| Capability | Status | What it means for your audit trail |
|---|---|---|
| Query log (from 2.16.0) | Built in | Records queries once query_log_file is set in the global section of prometheus.yml and the configuration is reloaded. Confirm the version you run includes this option. |
| Per-query parameters and timing | Built in | Each line holds the query with its start, end and step under params, engine timing under stats, and the end time under ts. |
| Caller network address | Built in | API and console queries record the client IP, method and path under httpRequest. Behind a proxy, this is the proxy address, not the original caller. |
| Rule-originated queries | Built in | Recording and alerting rule queries carry a ruleGroup element with the rule file and group name, so they are distinguishable from user queries. |
| User identity per query | Not available | The log has no user identity field. Record the authenticated user in the authenticating reverse proxy or SSO layer and correlate by time and client address. |
| Original caller behind a proxy | Needs outside component | The query log ignores X-Forwarded-For, so the reverse proxy must log the original client address and the user for each request. |
| Log rotation | Needs outside component | Prometheus does not rotate the query log. Use an external tool such as logrotate and confirm it does not interrupt writes. |
| Monitoring the query log | Built in | prometheus_engine_query_log_enabled shows whether logging is active, and prometheus_engine_query_log_failures_total counts queries that could not be logged. Alert on both. |
| Admin API actions | Not available | Queries from the query log do not cover admin operations. Enabling admin or lifecycle endpoints requires a separate record from the proxy or change process. |
What each query log line records about a query
Each line in the Prometheus query log describes one query, and the fields tell you what was asked and how it ran. The query itself sits under params, together with its start, end and step values, which show the time window and resolution the caller requested. The stats element carries engine timing for the query, and ts records the time the query ended. For queries that arrive through the HTTP API or the expression browser, an httpRequest element adds the client IP, the HTTP method and the request path. For queries issued by recording rules and alerting rules, a ruleGroup element names the rule file and the rule group instead. Before you rely on these fields, check them against a test query in your own version, since the exact layout is documented in the Prometheus query log guide.
The most important limit is the client address. Prometheus logs the network address of the connection and ignores headers such as X-Forwarded-For. If an authenticating reverse proxy, load balancer or ingress sits in front of Prometheus, every API query will appear to come from that intermediary, and the original caller is lost unless the proxy records it. Decide early which layer will log the authenticated user and the original client address, then confirm that the proxy's access log can be joined to the Prometheus query log by time and request path. Without that join, the query log can show that a query ran but not who ran it.
The query log covers reads only. It records queries, including those from rules, but it does not describe configuration reloads, changes to the prometheus.yml file, or calls to admin and lifecycle endpoints. Those actions need their own evidence, such as configuration management history, the proxy's logs for the endpoints in question, and Kubernetes audit logs where Prometheus runs under an operator. Confirm which of these sources your organization retains, for how long, and who can read them, since an investigation that depends on a single file will usually be incomplete.
How a user request reaches the query log
The request starts in the user's browser or API client and passes through an authenticating reverse proxy, which is the only place a user identity is recorded. The proxy forwards the query to the Prometheus API, which writes a query log line carrying the network address of the caller and an httpRequest element. Rule evaluations write their own lines with a ruleGroup element, and no user identity appears there. To tie a query to a person, correlate the proxy's log entry with the query log line by timestamp and caller address in your SIEM.
Which component writes each log line, and where a SIEM joins them.
Where the query log falls short for an audit requirement
The query log records what was asked of Prometheus and when, but it was never designed to answer who asked. Each gap below is a place where an audit requirement needs a second source, and the usual fix sits in a component you already run.
No user identity field
Each query log line carries the query, its parameters, engine timing and an end timestamp, but no field naming the user or account that issued it. Prometheus has no user model of its own to write into the log. To answer who ran a query, you need a record from the layer that knows the user, such as the reverse proxy or SSO gateway in front of the UI and API. Confirm that the proxy log includes the authenticated identity and can be joined to query log lines by time and client address.
Query log guideClient IP hides the original caller
The logged client address is the network peer that connected to Prometheus, and the query log ignores forwarding headers such as X-Forwarded-For. Behind a load balancer or reverse proxy, every query can appear to come from the proxy itself. The usual fix is to log the original caller in the proxy, then match those entries to query log lines using timestamps and the query text. Test this with a known query before you rely on it in an audit.
No built-in log rotation
Prometheus does not rotate the query log, so the file grows until something external manages it. Retention of the log therefore depends on a tool such as logrotate or a log shipper, and the retention period is a decision your organization must set and document. Check that rotation does not drop lines during a reload, and that rotated files are kept for the period your audit policy requires.
Admin actions are not in the query log
The query log records queries only. Configuration reloads, shutdowns, and calls to the admin APIs are not written there, so they leave no trace in it. Prometheus keeps the admin API disabled by default, and the lifecycle endpoints are enabled only by explicit flags. Keep both disabled unless you need them, and record any change to those flags or to prometheus.yml in your configuration management system, where changes can be attributed to a person.
No tamper protection or log shipping
The query log is a plain file on the Prometheus host. Prometheus provides no signing, integrity checks or remote shipping for it, so anyone with write access to the host could alter or delete lines. Ship the file to a central log store that the Prometheus operators cannot edit, and restrict file permissions on the host. Ask who can administer the log store and whether those actions are themselves logged.
Failed writes appear only as a metric
When Prometheus cannot log a query, the failure is counted in the prometheus_engine_query_log_failures_total metric rather than recorded as a line. Queries that failed to log are therefore missing from the audit trail with no entry to show it. Alert on any increase in that counter and check prometheus_engine_query_log_enabled to confirm logging is active. Treat a gap in the log as a reportable event, not a silent one.
How the audit answer changes by access pattern
When a single team queries the Prometheus HTTP API directly, the query log is the main server-side record, and it is useful but incomplete. Each API query carries an httpRequest element with the client IP, method and path, which tells you which machine asked and what it asked for. The log has no user identity field, so the address has to be mapped to a person through your own records, such as VPN or bastion logs.
- Enable the log deliberately: Set
query_log_filein the global section ofprometheus.ymland reload the configuration, then confirmprometheus_engine_query_log_enabledreads as active. - Map addresses to people: Shared jump hosts or NAT addresses collapse several users into one IP, so the query log alone cannot separate them.
- Keep the file intact: Prometheus does not rotate the query log, so configure logrotate or an equivalent and ship the file off the host.
- Watch for gaps: Alert on
prometheus_engine_query_log_failures_total, because failed writes mean queries that ran but were not recorded.
Confirm with your team whether analysts use shared credentials or direct network paths, because that decides whether the IP address can ever name one person.
When many teams reach Prometheus through an authenticating reverse proxy, the identity check happens in the proxy, not in Prometheus. The query log records the network address of the proxy, and the log ignores forwarded headers such as X-Forwarded-For. The original caller is therefore absent from the Prometheus log, and the proxy becomes the only place that can name the user.
- Log the caller in the proxy: Record the authenticated subject, the client address, the method and the path on every request that reaches the API or UI.
- Correlate by time and path: Match proxy entries to Prometheus query log entries using the timestamp in
tsand the path inhttpRequest, and state the clock source you rely on. - Protect the proxy logs: Treat the proxy as the system of record for who asked, so restrict write access and ship its logs to storage your auditors can read.
- Check bypass paths: Confirm that Prometheus cannot be reached directly from user networks, because a direct request would appear in the log without any proxy identity.
- Note the header rule: Do not configure Prometheus to trust forwarded headers for this purpose, since the query log does not use them.
Confirm with the team that runs the proxy which fields it records, how long it keeps them, and whether they can be exported without manual steps.
When Grafana is the only way people query Prometheus, the query log mostly shows Grafana's service account. Grafana sends the queries on behalf of each user, so the Prometheus side sees one identity and one address for everyone. The user who opened a dashboard or ran an Explore query is recorded in Grafana's own logs, not in the Prometheus query log.
- Use Grafana logs as the user record: Grafana's logs identify the signed-in user and the data source request, so retain them with the same retention as the Prometheus query log.
- Match on time: Correlate Grafana request entries with Prometheus query log entries by timestamp, since the Prometheus entry shows the query text and timing while Grafana shows the person.
- Separate alert queries: Queries from alerting and recording rules appear with a ruleGroup element, so they should not be mistaken for user activity.
- Limit direct access: If engineers can still reach the Prometheus API without Grafana, those queries will show up with other identities or addresses and need their own explanation.
- Confirm Grafana settings: Check which Grafana version and audit or request logging options your deployment provides before you promise coverage.
Confirm with the Grafana owners whether per-user request logging is enabled and how long those logs survive a restart or rotation.
In air-gapped or firewalled networks, the audit trail has to stay on site, and the query log has to be moved or read without an external service. The query log is a plain file on the Prometheus host, so it can be kept locally, but nothing in Prometheus ships it, archives it or verifies it. Every copy, rotation and retention step has to be designed and run inside the enclosed network.
- Keep the log local and protected: Write the query log to a path with restricted permissions and include it in your host backup plan.
- Plan rotation by hand: Use logrotate or an internal log shipper, because Prometheus will not rotate the file itself.
- Mirror identity records: Keep VPN, bastion and proxy logs inside the same enclave so that the IP address in the query log can be matched to a person.
- Monitor the logging itself: Use
prometheus_engine_query_log_enabledandprometheus_engine_query_log_failures_totalin local monitoring, so a silent failure is visible. - Test retrieval: Confirm that an auditor can read the entries, with a sample query traced end to end, without any external tool.
Confirm with your security team which log retention period and storage location your internal policy requires, since Prometheus does not set one.
Putting query logging and user attribution in production
This sequence turns Prometheus's query log into usable evidence of who queried what, by pairing the server's log with an authenticating proxy that records user identity, and then proves the two can be matched.
Decide which requests need user attribution
Before changing any configuration, the security or platform lead lists which access paths need a named user behind them: the web UI, direct API calls, Grafana data source connections, and any service accounts. Each path is either reached through a proxy that can record identity or it is not. Write this down, because the query log alone only records the network address of the caller and carries no user identity field. Done when every path has an owner and a stated way to attribute requests to a person.
Enable query_log_file and reload the configuration
The platform engineer sets query_log_file in the global section of prometheus.yml to a path the Prometheus process can write, then reloads the configuration. The query log guide documents this setting as available from Prometheus 2.16.0 onward, so confirm the version in use first. Reloading applies the change without a restart when lifecycle reload is enabled. Done when the configuration reload completes without errors in the server logs.
Confirm the log is written and the metric reads active
Run a query from the UI or API, then check that the file at the configured path gains a new line containing the query with its params, stats and ts fields. Query the metric prometheus_engine_query_log_enabled, which shows whether the log is active. Done when a test query produces a log line and the metric reports the log as enabled. If no line appears, check file permissions and the path before moving on.
Place an authenticating proxy in front and log identity
Prometheus has no built-in single sign-on, so the identity team places an authenticating reverse proxy in front of the web UI and API. Configure the proxy to record the authenticated user, the original client address (including any forwarding headers it trusts), the method, the path and a timestamp in its own access log. Restrict direct access to Prometheus so that users cannot bypass the proxy. Done when a request made through the proxy produces a proxy log line that names the user.
Rotate the query log with an external tool
Prometheus does not rotate its own query log, and the query log guide suggests an external tool such as logrotate. The operations team configures rotation for the log path with a retention period set by the organization's own policy, and tests the rotation with a manual run. Confirm that Prometheus continues writing to the new file after rotation and that the rotated files are kept where your retention policy requires. Done when a forced rotation leaves a working log file and archived copies in the expected location.
Alert on query log failures
Add an alert rule on prometheus_engine_query_log_failures_total so that any increase is reported as a problem, since it counts queries that could not be written to the log. Route the alert to the team that owns the monitoring stack through Alertmanager, and make sure the alert also fires if prometheus_engine_query_log_enabled drops to inactive. Done when a test alert reaches the on-call receiver and the rule is visible in the rules page.
Test by matching proxy and query log entries
Run a known query through the proxy as a named test user, using a path and time window you can record in advance. Then find the matching entry in the Prometheus query log by timestamp and the httpRequest path, and find the same request in the proxy log by timestamp and path. The two should agree on time and endpoint, and the proxy entry supplies the user. Repeat for one rule-based query to confirm the ruleGroup element appears. Done when every test request can be traced from the user in the proxy log to the query in the Prometheus log.
What a security reviewer asks to see for query audit
This table lists what an assessor typically asks for when a Prometheus deployment is expected to show who ran which query. Each row names the evidence, where it comes from, and what it cannot prove on its own. The main takeaway is that the query log alone never identifies a user, so the proxy and identity records must be produced alongside it.
| Reviewer request | Where the evidence comes from | What it does not prove |
|---|---|---|
| Proof that query logging is enabled | The query_log_file setting in the global section of prometheus.yml, plus evidence the configuration was reloaded | Only that the setting exists in the file, not that the running server loaded it |
| Proof that query logging is active now | The prometheus_engine_query_log_enabled metric, which shows whether the log is active | Nothing about which queries were recorded before any gap |
| Sample log lines showing query content and timing | Log files written to the path set in query_log_file, including params, stats and ts fields | Who the caller was, since the log has no user identity field |
| Caller network address for API and console queries | The httpRequest element (client IP, method and path) in each line | The end user behind a proxy, because the logged address is the network address and ignores X-Forwarded-For |
| Identity of the person who ran each query | Authentication records and access logs from the authenticating reverse proxy or SSO layer, matched by time and client address | Anything in the Prometheus query log itself |
| Rule-driven queries separated from human queries | The ruleGroup element naming the rule file and group for recording and alerting rule queries | Whether a human ran an ad hoc query through a rule or console |
| Log retention settings | Rotation configuration such as logrotate, plus retention periods set in the log archive or SIEM | Anything Prometheus itself enforces, since it does not rotate the query log |
| Evidence that failed log writes are caught | The prometheus_engine_query_log_failures_total metric and its alerting rule | Queries that failed before the log was enabled |
| Admin API status | Startup flags: --web.enable-admin-api and --web.enable-lifecycle, shown as disabled or enabled in the running configuration | Whether the reverse proxy blocks those paths, which must be confirmed separately |
Questions buyers ask about Prometheus audit logging
Does Prometheus have an audit log?
Prometheus does not ship an audit log in the sense most compliance teams mean. It provides a query log, available as of Prometheus 2.16.0, which records each query that runs against the server. You turn it on by setting query_log_file in the global section of prometheus.yml and reloading the configuration. The query log is useful evidence of what was asked and how heavy it was, but it does not record who asked. Plan to treat it as one input to your logging design, not as a complete audit trail. Confirm the version you run supports the setting before you rely on it.
Can I see which user ran a query without a proxy?
No. Each query log line carries the query, its timing statistics and an end timestamp. Queries from the API or consoles include an httpRequest element with the client network address, method and path. The logged address is the network address and ignores headers such as X-Forwarded-For, and the log has no user identity field. If users reach Prometheus directly, you can correlate an address with a person only through your network records. If they reach it through a reverse proxy or an SSO gateway, the proxy must log the authenticated user, the time and the request, then you join those records to the Prometheus log by time and path.
Does enabling the query log cost extra?
The query log is a feature of the open-source server, so enabling it adds no licence fee. The cost is in what it consumes and who maintains it. Log lines take disk space, and Prometheus does not rotate the file itself, so you need a rotation tool such as logrotate and a retention rule for the archive. Storage, shipping and search for the log are separate charges on whatever platform receives it. Ask your team or partner to estimate log volume from your query rate before choosing a storage tier, because that volume is what drives recurring cost.
Does the license or edition change this?
No. Prometheus is licensed under Apache-2.0 and there is no paid enterprise edition of the project, so the query log behaves the same for every organization that runs the open-source server. Any extra logging capability you add comes from your reverse proxy, your SSO layer or your log platform, each under its own licence or subscription. Check those components' terms separately. A vendor's managed Prometheus service may expose logging differently, so confirm with that provider what it records and retains before assuming parity.
How much work is the proxy and log pipeline?
The work depends on three choices. The first is the proxy: an authenticating reverse proxy that already fronts your identity provider needs its access log format extended with the authenticated user, while a new proxy needs configuration, TLS and testing. The second is the log pipeline, which covers shipping the query log and proxy logs to a central store, parsing the fields and joining them by time and path. The third is retention rules, since your policy sets how long each log is kept, who can read it and how it is protected from tampering. Each of these is a fixed-scope design item that a partner or your team can estimate once the proxy product and storage target are known.
Can my team do this alone?
Often yes, if your team already runs a reverse proxy, a log platform and Prometheus in production. Enabling query_log_file, adding rotation and extending the proxy log format are small configuration tasks. The harder parts are the correlation logic, the retention policy and proving to an auditor that the records are complete and unaltered. Check three skills before deciding: someone who can change the proxy, someone who owns the log platform, and someone who can document the control. DeployOpen can plan and build this as a fixed-scope engagement, prepare the evidence for your compliance assessment, and support it as a retainer, but independent auditors decide whether it meets your obligations.
How do I know the query log is working?
Monitor it from Prometheus itself. The metric prometheus_engine_query_log_enabled shows whether the query log is active, and prometheus_engine_query_log_failures_total counts queries that could not be logged. Alert on any increase in the failures counter, because a gap in the log is a gap in your evidence. Also test the chain end to end: run a known query through the proxy as a named test user, then confirm the user, the time and the query appear together in your central store. Repeat this test after each Prometheus upgrade and after each proxy change.
Which official pages to check each claim against
The Prometheus query log guide is the single source for which fields a query log line contains, how the log is enabled and how it is monitored. Before you write any control statement about Prometheus query logging, check it against that guide. Confirm the query_log_file key in the global section of prometheus.yml, the reload step that follows it, and the fields named under params, stats, ts, httpRequest and ruleGroup. Do not rely on secondhand descriptions, including the summary on this page, for field names.
The Prometheus security model is the companion page for what sits around the query log: how TLS and basic authentication are configured, whether the admin APIs are enabled, and which access paths an unauthenticated caller can reach. Read it alongside the query log guide so that your assumptions about who can send queries match what the server actually accepts. Log lines only show the network address of the caller, so the security model is where you confirm how requests reach the server in the first place.
Confirm behavior against the exact version you run, not the latest documentation. Query log behavior and its monitoring metrics have changed over time, and the guide applies to the version you deploy. Check the release notes for your version in the Prometheus GitHub releases page, and record the version number and the date you verified each claim in your own control evidence. If the version you run differs from the one described in the guide, test the log on a staging instance and inspect a real log line before relying on it.
How DeployOpen sets up Prometheus audit logging in your infrastructure
DeployOpen plans Prometheus audit logging as part of a self-hosted deployment in infrastructure you control. We first confirm which questions your auditors and security team need answered, then configure the query log and the proxy and identity layers that record who ran each query.
How we scope
- Confirm which query and user events your auditors and security team need to answer, and over what period
- Map which parts of the user identity sit in your SSO or reverse proxy and which must be logged there
- Agree in writing the deliverables, exclusions and timeline before any configuration work starts
How we build
- Enable the query log in the global section of prometheus.yml and reload the configuration in a test environment
- Configure the reverse proxy or authentication layer to record the original caller, method and path for each request
- Set up log rotation with an external tool such as logrotate and alert on the query log metrics
How we hand over
- Document which fields the Prometheus query log contains and which attribution fields come from your proxy or identity provider
- Provide a test plan that runs known queries as named users and checks that both log sources match
- Hand over runbooks for log retention, rotation, failure monitoring and how to correlate events across sources
How we support
- Review logging configuration again after Prometheus upgrades, since release lines change on a planned cycle
- Offer ongoing support, upgrades and continuous testing as a retainer if your team wants them
- Keep the scope of any support change in writing, with a fixed-scope quote for each piece of work

