Vault audit logs track who requested what and when, and how Vault responded — they are the foundation for accountability. The File Audit Device writes those events to a local file on the host as one JSON event per line.
This article focuses on local file output, walking through the commands and terminology commonly tested on certifications, the permissions and rotation design you cannot skip in real operations, and the security pitfalls — all at a hands-on level of detail.
Vault audit devices record the metadata of every request and response. The File Audit Device is the simplest: it appends JSON lines to the path you specify. Sensitive values are HMAC-hashed by default, so plaintext is not left on disk.
Local file output fits well with single-node setups, the OS-standard logrotate, and shipper agents such as Filebeat or Fluent Bit. On certification exams, the most frequent topics are the enable/disable commands, the parameter name (file_path), and the HMAC behavior (sensitive values hashed by default).
| Device | Destination | Main Advantage | Main Caveat |
|---|---|---|---|
| file | Local file | Simple, easy to introduce | Files scattered per node; permissions and capacity management required |
| syslog | Local syslog (forward as needed) | Easy to fit into centralized management | Depends on the syslog configuration of the environment |
| socket | UNIX / TCP socket | Low-latency hand-off to an external process | Depends on the availability of the receiving process |
| stderr | Standard error | Easy to pick up via container log platforms | Long-term retention requires a separate mechanism |
Flow of local file output
Check the list of audit devices
vault audit list -detailedEnabling the device takes a single command. Create the directory in advance and set ownership and permissions so that the Vault process can write to it. By default, sensitive values are HMAC-hashed, so the default configuration does not emit plaintext.
After enabling, generate a single request (for example, vault status or a kv operation) and confirm that events are written to the file. Disable by specifying the mount path (e.g., file/).
Example of enable → verify → disable
sudo mkdir -p /var/log/vault
sudo chown vault:vault /var/log/vault
# Enable the audit device (local file)
vault audit enable file file_path=/var/log/vault/audit.log
# Check status
vault audit list -detailed
# Trigger an event to verify
vault status
sudo tail -n1 /var/log/vault/audit.log
# Disable (the default path name is file/)
vault audit disable file/The File Audit Device writes one JSON event per line (i.e., NDJSON). Representative fields include time, type (request/response), request.path, request.operation, remote_address, auth info (such as policies), and whether an error occurred. Sensitive values (such as secret data or token values) are HMAC-hashed by default, and plaintext is not retained.
When you need to correlate events, the audit hash API (sys/audit-hash/<device-name>) lets you compute what HMAC value a given string would become in the log — locally. This lets you track without storing plaintext.
Sample line (some fields abbreviated)
{
"time":"2026-04-19T10:15:30.123456Z",
"type":"request",
"auth":{
"client_token":"hmac-sha256:2f9c...",
"display_name":"root",
"policies":["root"]
},
"request":{
"id":"c7b0...",
"operation":"read",
"path":"sys/health",
"remote_address":"192.0.2.10",
"data":{
"foo":"hmac-sha256:91ab..."
}
},
"response":{
"status":200
},
"error":false
}Permissions should follow least privilege. Make the audit log directory vault-owned, restrict the group to roles that actually need read access, and set files to roughly 0640. Keep read access for backup and shipper agents to the minimum necessary.
Use existing infrastructure such as the OS logrotate for rotation. The copytruncate approach is simple, but make the decision with the understanding that it may briefly drop lines. Be explicit about post-rotation permissions (the create directive), compression, and generation count. Monitoring disk usage (with thresholds and alerts) is mandatory.
Example logrotate configuration (/etc/logrotate.d/vault-audit)
/var/log/vault/audit.log {
weekly
rotate 12
compress
dateext
missingok
notifempty
create 0640 vault vault
copytruncate
}log_raw is disabled by default, so plaintext secrets are not emitted in the default behavior. Avoid setting log_raw=true outside of verification scenarios. Grant read permissions strictly based on separation of duties, and keep an audit trail of accesses as well.
HMAC is salted per audit device. During investigations, use the audit hash API to generate the equivalent value and compare. Retention period, encryption, and tamper detection (such as WORM) should be aligned with internal policy and external regulations (for example, finance or healthcare).
Comparing HMAC values (audit hash API example)
# When the audit device name is file/
vault write sys/audit-hash/file input="[email protected]"When you see Permission denied or No such file or directory, check whether the directory exists, who owns it, and any SELinux / AppArmor constraints. If nothing is written to the file, distinguish between the enable state of the audit device (vault audit list) and whether you actually triggered an event (whether any operation occurred).
For exam preparation, the enable / disable / list commands, the required parameter file_path, the fact that sensitive values are HMAC-hashed by default, and the operational premise that local file output relies on OS-side rotation are all high-yield points.
One-liner for a sanity check (generate an event → confirm the most recent line)
vault kv put secret/demo foo=bar
sudo tail -n1 /var/log/vault/audit.log | jq -r '.type + " " + .request.path'Associate / Ops
問題 1
You want to safely emit Vault audit logs to a local file and manage them with the OS logrotate. Which command is the most appropriate initial setup? (Assume plaintext secrets must not be retained.)
正解: A
Local file output is enabled with the file device and a file_path. The path name (-path=...) is optional but may be set as in the example. log_raw defaults to false (no plaintext emitted), so it does not need to be set. syslog is a different device, and sys/audit-hash is a hashing API, not an enable command.
How do I change the output path (file_path) after the audit device is enabled?
Audit device parameters cannot be modified after enablement. Disable the target audit device first (vault audit disable <path>), then re-enable it with the new file_path. Take the opportunity to review rotation and permission settings as well.
What happens if the disk fills up and audit writes fail?
If audit writes fail, Vault fails closed by design, and requests may error out depending on the situation. Capacity monitoring, alerting, and log rotation are mandatory. Consider running multiple audit devices in parallel to avoid a single point of failure.
Can multiple audit devices be enabled simultaneously?
Yes. You can run file and syslog devices side by side, for example. This lets you keep a local copy while also forwarding to an aggregation backend through a separate path. Each device has its own parameters, so when troubleshooting, check which specific device is failing.
Practice with certification-focused question sets
無料で問題を解いてみるNicheeLab Editorial Team
NicheeLab editorial team focused on data engineering and cloud certification learning. Content is structured around practical study needs and official exam domains.
Vault Core Concepts: Sealed/Unsealed, Auth, Secrets (2026)
Vault fundamentals — sealed/unsealed state, auth methods, se...
Vault Operations Professional (VOP-003): Complete Guide (2026)
Pass the Vault Operations Professional exam — enterprise pat...
Vault Path-Based Routing: API URL Structure (2026)
How Vault's path-based routing works — mount points, sub-pat...
Vault Tokens: Auth Token Mechanics (2026)
Token fundamentals — service vs. batch tokens, accessor, ren...
Vault Token Types: Service, Batch, Periodic (2026)
Service vs. batch tokens compared — performance, ACL behavio...