Monitoring a Vault Environment

Vault Telemetry

# Set in vault config file
telemetry {
  disable_hostname = true
  prometheus_retention_time = "12h"
}

Audit Logs

What Audit Devices Does Vault Support

Important Info about Audit Devices

NOTE: No audit devices are enabled by default

WARNING: If an audit devices is enabled, Vault requires at least one audit device to write the log before completing the Vault request. A full volume will cause vault to stop responding.

# Enable file audit device at default path
vault audit enable file file_path="/var/log/vault_audit.log"
Success! Enabled the file audit device at: file/

# Enable file audit device at custom path of "logs"
# Enable at a custom path inside of vault
# Add -local to disable replication
vault audit enable -path=logs file \
  file_path="/var/log/audit.log"
Success! Enabled the file audit device at: logs/

# View audit devices enabled on the cluster
vault audit list
Path    Type    Description
---- ---- -----------
file/   file    n/a
syslog/ syslog  n/a

vault audit list --detailed
Path       Type      Description    Replication    Options
----       ----      -----------    -----------    -------
syslog/    syslog    n/a            replicated     n/a

# Disable an Audit Device
vault audit disable syslog/
Success! Disabled audit device (if it was enabled) at: syslog/

cat /var/log/audit.log | jq
{
  "time": "2023-05-08T18:57:41.561900902Z",
  "type": "request",
  "auth": {
    "client_token": "hmac-sha256:e7bd02262daf2763188bd3dc6c8be322c8a62f39ae2462bd0b80ba1efab2761f",
    "accessor": "hmac-sha256:4ff8d448f14c5bf379b4ce81b7bc48aedaadc2ee929272c66ef43fb92cca1195",
    "display_name": "root",
    "policies": [
      "root"
    ],
    "token_policies": [
      "root"
      ...

# Required Permissions for interacting with the file audit device at the default path of file/
path "sys/audit/file" {
  capabilities = ["read","create","list","update","delete","sudo"]
}

Operation Logs

Specifying the Log Level

  1. Use the CLI flag -log_level when starting the Vault service vault server –config=/opt/vault/vault.hcl –log-level=debug
  2. Set the environment variable VAULT_LOG_LEVEL
    Change takes effect after Vault server is restarted
    export VAULT_LOG_LEVEL=trace
  3. Set the log_level configuration parameter in the Vault configuration file
    Change takes effect after Vault server is restarted
    log_level=warn
# Can view logs using journalctl
# shift+g to go to bottom of logs
journalctl –b -–no-pager –u vault