Skip to content
Tutorials Center
My learning

Topics

Lesson 30 of 36 ยท Operations and Integration

Vault Audit Devices: Logging Every Request Safely

Learn how Vault audit devices record every request and response: enabling file, syslog and socket devices, HMAC-hashed sensitive values, fail-closed behaviour and a log parser stand-in.

Security teams ask: who read this secret, when, and from where? Vault answers with audit devices. Each enabled device receives a detailed record of every request and response. Vault is designed to be fail closed for auditing: if it cannot write to any enabled audit device, it refuses to serve requests. That guarantees there is no unlogged activity.

Vault does not run on this site. Commands are real; the JavaScript blocks parse a sample log line and mimic hashing with a labelled stand-in.

Enabling devices

Terminal
vault audit enable file file_path=/var/log/vault/audit.log
vault audit enable syslog tag="vault" facility="AUTH"
vault audit enable socket address="logs.internal:9090" socket_type=tcp
vault audit list -detailed

Enable at least two devices on different destinations. If one becomes blocked (a full disk), Vault keeps working as long as another device succeeds. If all fail, Vault blocks requests until one recovers, so monitor disk space and rotate logs (send SIGHUP to reopen the file after rotation).

Enable an audit device before you start using Vault for real work, and never delete the only device's log target without a replacement: a broken sole device stops all requests.

What a record contains

Each request and response is written as one JSON line. The important fields:

  • type: request or response
  • auth: token accessor, policies, entity id and display name
  • request: operation, path, remote address, namespace, headers
  • response: data, lease information, errors
  • time: RFC 3339 timestamp

Sensitive values are not written in clear text. Strings such as tokens, passwords and secret data are replaced with a salted HMAC-SHA256 hash (hmac-sha256:...). You cannot read the secret from the log, but you can compare: ask Vault to hash a known value with vault write sys/audit-hash/file input="my-value" and search for the result. That lets you find out whether a specific secret was used without storing it in logs.

JSON
{"time":"2030-01-01T10:00:00Z","type":"request","auth":{"display_name":"oidc-alice","policies":["app-readonly"]},"request":{"operation":"read","path":"secret/data/myapp/db","remote_address":"10.0.0.5"}}
JS Stand-in: summarize an audit log

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Using the logs

  • Ship them to a SIEM (Splunk, Elastic, Loki) and build alerts: reads of sensitive paths, permission denied bursts, root token use, policy changes, sys/seal.
  • Remember response bodies can still be large, and log_raw=true disables hashing. Never enable log_raw in production.
  • Audit logs contain metadata that may be sensitive (paths, usernames), so protect them like secrets.
  • With Vault namespaces, include the namespace in queries.
JS Stand-in: alert on suspicious events

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does Vault do if it cannot write to any enabled audit device?

    Vault fails closed so no activity goes unrecorded.
  2. 2. How are secret values shown in an audit log?

    Hashing hides the value but still lets you match a known value.
  3. 3. Why enable more than one audit device?

    As long as one device succeeds, Vault can continue.
  4. 4. Which setting should never be on in production?

    log_raw writes sensitive values without hashing.

Summary

  • Audit devices (file, syslog, socket) log every request and response.
  • Sensitive values are HMAC-hashed; sys/audit-hash lets you compare.
  • Vault fails closed; use at least two devices and watch their health.
  • Ship logs to a SIEM and alert on risky events.

Next: Backup, Disaster Recovery and Monitoring