Configuring Auditing
editConfiguring Auditing
editAudit logs are disabled by default. To enable this functionality the following setting should be added to the
elasticsearch.yml
file:
shield.audit.enabled: true
The audit functionality was added to keep track of important events occurring in Elasticsearch, primarily around security concerns. Keeping track and persisting these events is essential for any secured environment and potentially provides evidence for suspicious/malicious activity on the Elasticsearch cluster.
Shield provides two ways to output these events: in a dedicated access.log
file stored on the host’s file system, or
in an Elasticsearch index on the same or separate cluster. These options are not mutually exclusive. For example, both
options can be enabled through an entry in the elasticsearch.yml
file:
shield.audit.outputs: [index, logfile]
It is expected that the index
output type will be used in conjunction with the logfile
output type. This is
because the index
output type can lose messages if the target index is unavailable. For this reason, it is recommended
that, if auditing is enabled, then the logfile
output type should be used as an official record of events. The index
output type can be enabled as a convenience to allow historical browsing of events.
Please also note that, because audit events are batched together before being indexed, they may not appear immediately.
Please refer to the shield.audit.index.flush_interval
setting below for instructions on how to modify the frequency
with which batched events are flushed.
Log Entry Types
editEach audit related event that occurs is represented by a single log entry of a specific type (the type represents the type of the event that occurred). Here are the possible log entry types:
-
anonymous_access_denied
is logged when the request is denied due to missing authentication token. -
authentication_failed
is logged when the authentication token cannot be matched to a known user. -
authentication_failed [<realm>]
is logged for every realm that fails to present a valid authentication token. The value of <realm> is the realm type. -
access_denied
is logged when an authenticated user attempts an action the user does not have the privilege to perform. -
access_granted
is logged when an authenticated user attempts an action the user has the correct privilege to perform. In TRACE level all system (internal) actions are logged as well (in all other level they’re not logged to avoid cluttering of the logs. -
tampered_request
is logged when the request was detected to be tampered (typically relates tosearch/scroll
requests when the scroll id is believed to be tampered) -
connection_granted
is logged when an incoming tcp connection has passed the ip filtering for a specific profile -
connection_denied
is logged when an incoming tcp connection did not pass the ip filtering for a specific profile
To avoid needless proliferation of log entries, Shield enables you to control what entry types should be logged. This can be done by setting the logging level. The following table lists the log entry types that will be logged for each of the possible log levels:
Table 6. Log Entry Types and Levels
Log Level | Entry Type |
---|---|
|
|
|
|
|
|
|
(doesn’t output additional entry types beyond |
|
|
Log Entry Format
editAs mentioned above, every log entry represents an event that occurred in the system. As such, each entry is associated with a timestamp (at which the event occurred), the component/layer the event is associated with and the entry/event type. In addition, every log entry (depending ot its type) carries addition information about the event.
The format of a log entry is shown below:
[<timestamp>] [<local_node_info>] [<layer>] [<entry_type>] <attribute_list>
Where:
-
<timestamp>
- the timestamp of the entries (in the format configured inlogging.yml
as shown above) -
<local_node_info>
- additional information about the local node that this log entry is printed from (the table below shows how this information can be controlled via settings) -
<layer>
- the layer from which this entry relates to. Can be eitherrest
,transport
orip_filter
-
<entry_type>
- the type of the entry as discussed above. Can be eitheranonymous_access_denied
,authentication_failed
,access_denied
,access_granted
,connection_granted
,connection_denied
. -
<attribute_list>
- A comma-separated list of attribute carrying data relevant to the occurred event (formatted asattr1=[val1], attr2=[val2],...
)
Table 7. Local Node Info Settings
Name | Default | Description |
---|---|---|
|
true |
When set to |
|
false |
When set to |
|
false |
When set to |
The following tables describe the possible attributes each entry type can carry (the attributes that will be available depend on the configured log level):
Table 8. [rest] [anonymous_access_denied]
attributes
Attribute | Minimum Log Level | Description |
---|---|---|
|
WARN |
The address the rest request origins from |
|
WARN |
The REST endpoint URI |
|
DEBUG |
The body of the request |
Table 9. [rest] [authentication_failed]
attributes
Attribute | Minimum Log Level | Description |
---|---|---|
|
ERROR |
The address the rest request origins from |
|
ERROR |
The principal (username) that failed to authenticate |
|
ERROR |
The REST endpoint URI |
|
DEBUG |
The body of the request |
|
TRACE |
The realm that failed to authenticate the user. NOTE: A separate entry will be printed for each of the consulted realms |
Table 10. [transport] [anonymous_access_denied]
attributes
Attribute | Minimum Log Level | Description |
---|---|---|
|
WARN |
The type of the origin the request originated from. Can be either |
|
WARN |
The address the request origins from |
|
WARN |
The name of the action that was executed |
|
DEBUG |
The type of the request that was executed |
|
WARN |
A comma-separated list of indices this request relates to (when applicable) |
Table 11. [transport] [authentication_failed]
attributes
Attribute | Minimum Log Level | Description |
---|---|---|
|
ERROR |
The type of the origin the request originated from. Can be either |
|
ERROR |
The address the request origins from |
|
ERROR |
The principal (username) that failed to authenticate |
|
ERROR |
The name of the action that was executed |
|
DEBUG |
The type of the request that was executed |
|
ERROR |
A comma-separated list of indices this request relates to (when applicable) |
|
TRACE |
The realm that failed to authenticate the user. NOTE: A separate entry will be printed for each of the consulted realms |
Table 12. [transport] [access_granted]
attributes
Attribute | Minimum Log Level | Description |
---|---|---|
|
INFO |
The type of the origin the request originated from. Can be either |
|
INFO |
The address the request origins from |
|
INFO |
The principal (username) that failed to authenticate |
|
INFO |
The name of the action that was executed |
|
DEBUG |
The type of the request that was executed |
|
INFO |
A comma-separated list of indices this request relates to (when applicable) |
Table 13. [transport] [access_denied]
attributes
Attribute | Minimum Log Level | Description |
---|---|---|
|
ERROR |
The type of the origin the request originated from. Can be either |
|
ERROR |
The address the request origins from |
|
ERROR |
The principal (username) that failed to authenticate |
|
ERROR |
The name of the action that was executed |
|
DEBUG |
The type of the request that was executed |
|
ERROR |
A comma-separated list of indices this request relates to (when applicable) |
Table 14. [transport] [tampered_request]
attributes
Attribute | Minimum Log Level | Description |
---|---|---|
|
ERROR |
The type of the origin the request originated from. Can be either |
|
ERROR |
The address the request origins from |
|
ERROR |
The principal (username) that failed to authenticate |
|
ERROR |
The name of the action that was executed |
|
DEBUG |
The type of the request that was executed |
|
ERROR |
A comma-separated list of indices this request relates to (when applicable) |
Table 15. [ip_filter] [connection_granted]
attributes
Attribute | Minimum Log Level | Description |
---|---|---|
|
TRACE |
The address the request origins from |
|
TRACE |
The principal (username) that failed to authenticate |
|
TRACE |
The IP filtering rule that granted the request |
Table 16. [ip_filter] [connection_denied]
attributes
Attribute | Minimum Log Level | Description |
---|---|---|
|
ERROR |
The address the request origins from |
|
ERROR |
The principal (username) that failed to authenticate |
|
ERROR |
The IP filtering rule that denied the request |
Audit Logs Settings
editAs mentioned above, the audit logs are configured in the logging.yml
file located in CONFIG_DIR/shield
. The following snippet shows the default logging configuration:
logger: shield.audit.logfile: INFO, access_log additivity: shield.audit.logfile: false appender: access_log: type: dailyRollingFile file: ${path.logs}/${cluster.name}-access.log datePattern: "'.'yyyy-MM-dd" layout: type: pattern conversionPattern: "[%d{ISO8601}] %m%n"
As can be seen above, by default audit information is appended to the access.log
file located in the
standard Elasticsearch logs
directory (typically located at $ES_HOME/logs
).
Storing Audit Logs in an Elasticsearch Index
editIt is possible to store audit logs in an Elasticsearch index. This index can be either on the same cluster, or on
a different cluster (see below). Several settings in elasticsearch.yml
control this behavior.
Table 17. audit log indexing configuration
Attribute | Default Setting | Description |
---|---|---|
|
|
Must be set to index or [index, logfile] to enable |
|
|
Controls how many audit events will be batched into a single write |
|
|
Controls how often to flush buffered events into the index |
|
|
Controls how often to roll over to a new index: hourly, daily, weekly, monthly. |
|
|
The audit events to be indexed. Valid values are |
|
|
The audit events to exclude from indexing. By default, |
audit index settingsThe settings for the index that the events are stored in, can also be configured. The index settings should be placed under
the shield.audit.index.settings
namespace. For example, the following sets the number of shards and replicas to 1 for
the audit indices:
shield.audit.index.settings: index: number_of_shards: 1 number_of_replicas: 1
Forwarding Audit Logs to a Remote Cluster
editTo have audit events stored into a remote Elasticsearch cluster, the additional following options are available.
Table 18. remote audit log indexing configuration
Attribute | Default Setting | Description |
---|---|---|
|
None |
Comma separated list of host:port pairs. These hosts should be nodes in the cluster to which you want to index. |
|
None |
The name of the remote cluster. |
|
None |
The username:password pair used to authenticate with the remote cluster. |
Additional settings may be passed to the remote client by placing them under the shield.audit.index.client
namespace.
For example, to allow the remote client to discover all of the nodes in the remote cluster you could set
the client.transport.sniff option.
shield.audit.index.client.transport.sniff: true