audit Block
Placement | audit |
The audit
block configures the Nomad agent to configure Audit logging behavior.
Audit logging is an Enterprise-only feature.
When enabled, each HTTP request made to a nomad agent (client or server) will
generate two audit log entries. These two entries correspond to a stage,
OperationReceived
and OperationComplete
. Audit logging will generate a
OperationReceived
event before the request is processed. An OperationComplete
event will be sent after the request has been processed, but before the response
body is returned to the end user.
By default, with a minimally configured audit block (audit { enabled = true }
)
The following default sink will be added with no filters.
The sink will create an audit.log
file located within the defined data_dir
directory inside an audit
directory. delivery_guarantee
will be set to
"enforced"
meaning that all requests must successfully be written to the sink
in order for HTTP requests to successfully complete.
audit
Parameters
enabled
(bool: false)
- Specifies if audit logging should be enabled. When enabled, audit logging will occur for every request, unless it is filtered by afilter
.sink
(sink: default)
- Configures a sink for audit logs to be sent to.filter
(array<filter>: [])
- Configures a filter to exclude matching events from being sent to audit logging sinks.
sink
Block
The sink
block is used to make audit logging sinks for events to be
sent to. Currently only a single sink is supported.
The key of the block corresponds to the name of the sink which is used for logging purposes
sink
Parameters
type
(string: "file", required)
- Specifies the type of sink to create. Currently only"file"
type is supported.delivery_guarantee
(string: "enforced", required)
- Specifies the delivery guarantee that will be made for each audit log entry. Available options are"enforced"
and"best-effort"
."enforced"
will halt request execution if the audit log event fails to be written to its sink."best-effort"
will not halt request execution, meaning a request could potentially be un-audited.format
(string: "json", required)
- Specifies the output format to be sent to a sink. Currently only"json"
format is supported.mode
(string: "0600")
- Specifies the permissions mode for the audit log files using octal notation.path
(string: "[data_dir]/audit/audit.log")
- Specifies the path and file name to use for the audit log. By default Nomad will use its configureddata_dir
for a combined path of/data_dir/audit/audit.log
. Ifrotate_bytes
orrotate_duration
are set file rotation will occur. In this case the filename will be post-fixed with a timestamp"filename-{timestamp}.log"
rotate_bytes
(int: 0)
- Specifies the number of bytes that should be written to an audit log before it needs to be rotated. Unless specified, there is no limit to the number of bytes that can be written to a log file.rotate_duration
(duration: "24h")
- Specifies the maximum duration a audit log should be written to before it needs to be rotated. Must be a duration value such as 30s.rotate_max_files
(int: 0)
- Specifies the maximum number of older audit log file archives to keep. If 0, no files are ever deleted.
filter
Block
The filter
block is used to create filters to filter out matching events
from being written to the audit log. By default, all events will be sent to an
audit log for all stages (OperationReceived and OperationComplete). Filters
are useful for operators who want to limit the performance impact of audit
logging as well as reducing the amount of events generated.
endpoints
, stages
, and operations
support globbed pattern matching.
Query parameters are ignored when evaluating filters.
filter
Parameters
type
(string: "HTTPEvent", required)
- Specifies the type of filter to create. Currently only HTTPEvent is supported.endpoints
(array<string>: [])
- Specifies the list of endpoints to apply the filter to.stages
(array<string>: [])
- Specifies the list of stages ("OperationReceived"
,"OperationComplete"
,"*"
) to apply the filter to for a matching endpoint.operations
(array<string>: [])
- Specifies the list of operations to apply the filter to for a matching endpoint. For HTTPEvent types this corresponds to an HTTP verb (GET, PUT, POST, DELETE...).
Audit Log Format
Below are two audit log entries for a request made to /v1/job/web/summary
. The
first entry is for the OperationReceived
stage. The second entry is for the
OperationComplete
stage and includes the contents of the OperationReceived
stage plus a response
key.
If the request returns an error the audit log will reflect the error message.