Audit logging helps you keep track of who did what and when in your Elasticsearch system. It is like a security camera that records important actions for safety and review.
Audit logging in Elasticsearch
Start learning this pattern below
Jump into concepts and practice - no test required
or
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Introduction
Syntax
Elasticsearch
xpack.security.audit.enabled: true xpack.security.audit.outputs: [ index, logfile ] xpack.security.audit.logfile.events.include: [ authentication_success, authentication_failed, access_granted, access_denied ]
Enable audit logging by setting
xpack.security.audit.enabled to true.Choose where to send audit logs using
xpack.security.audit.outputs, like to an index or a log file.Examples
Elasticsearch
xpack.security.audit.enabled: true xpack.security.audit.outputs: [ logfile ] xpack.security.audit.logfile.events.include: [ authentication_failed ]
Elasticsearch
xpack.security.audit.enabled: true xpack.security.audit.outputs: [ index ] xpack.security.audit.index.events.include: [ access_granted, access_denied ]
Sample Program
This configuration turns on audit logging and sends important security events to both a log file and an Elasticsearch index. It tracks successful and failed logins, plus access permissions.
Elasticsearch
xpack.security.audit.enabled: true xpack.security.audit.outputs: [ index, logfile ] xpack.security.audit.logfile.events.include: [ authentication_success, authentication_failed, access_granted, access_denied ] xpack.security.audit.index.events.include: [ authentication_success, authentication_failed, access_granted, access_denied ]
Important Notes
Audit logging can generate many logs; monitor disk space to avoid full storage.
Use filters to include only important events and reduce noise.
Audit logs help with security compliance and troubleshooting.
Summary
Audit logging records user actions and security events in Elasticsearch.
Enable it by setting xpack.security.audit.enabled to true.
Choose outputs like log files or Elasticsearch indexes to store audit data.
Practice
1. What is the main purpose of audit logging in Elasticsearch?
easy
Solution
Step 1: Understand audit logging function
Audit logging tracks what users do and records security-related events.Step 2: Compare with other options
Improving search speed, backing up data, or monitoring cluster health are different Elasticsearch features.Final Answer:
To record user actions and security events -> Option AQuick Check:
Audit logging = record user actions [OK]
Hint: Audit logging tracks user and security events only [OK]
Common Mistakes:
- Confusing audit logging with backup or monitoring
- Thinking it speeds up search queries
- Assuming it manages cluster health
2. Which setting enables audit logging in Elasticsearch's configuration file?
easy
Solution
Step 1: Identify correct setting syntax
The official setting to enable audit logging isxpack.security.audit.enabledset to true.Step 2: Check other options for correctness
Other options use incorrect keys or values not recognized by Elasticsearch.Final Answer:
xpack.security.audit.enabled: true -> Option BQuick Check:
Enable audit logging = xpack.security.audit.enabled true [OK]
Hint: Look for 'xpack.security.audit.enabled' set to true [OK]
Common Mistakes:
- Using incorrect key names
- Using 'yes' or 'on' instead of true
- Mixing audit and security keys
3. Given this audit logging config snippet:
What does this configuration do?
xpack.security.audit.enabled: true xpack.security.audit.outputs: ["logfile", "index"]
What does this configuration do?
medium
Solution
Step 1: Analyze 'enabled' setting
Settingxpack.security.audit.enabled: trueturns audit logging on.Step 2: Analyze 'outputs' setting
Outputs set to ["logfile", "index"] means audit data is saved to log files and Elasticsearch indexes.Final Answer:
Enables audit logging and sends data to log files and Elasticsearch index -> Option AQuick Check:
Enabled + logfile and index outputs = Enables audit logging and sends data to log files and Elasticsearch index [OK]
Hint: Enabled true + outputs list means multiple destinations [OK]
Common Mistakes:
- Assuming logging is disabled
- Thinking output is only console
- Ignoring multiple output destinations
4. You enabled audit logging with
xpack.security.audit.enabled: true but see no audit logs. What is a likely cause?medium
Solution
Step 1: Check audit logging enablement
Audit logging is enabled, so it should produce logs if outputs are set.Step 2: Verify output configuration
Ifxpack.security.audit.outputsis missing or empty, logs have nowhere to go, so no logs appear.Final Answer:
Audit outputs are not configured, so logs have no destination -> Option DQuick Check:
Enabled but no outputs = no logs [OK]
Hint: Check audit outputs setting if no logs appear [OK]
Common Mistakes:
- Assuming cluster offline without checking
- Restarting Kibana instead of Elasticsearch
- Blaming user permissions without audit config check
5. You want to audit only authentication events and store them in a dedicated Elasticsearch index. Which configuration snippet achieves this?
hard
Solution
Step 1: Enable audit logging
Setxpack.security.audit.enabled: trueto turn on audit logging.Step 2: Set output to Elasticsearch index only
Usexpack.security.audit.outputs: ["index"]to store logs in an index.Step 3: Filter to authentication events
Setxpack.security.audit.categories: ["authentication"]to audit only authentication events.Final Answer:
Enable audit, output to index, filter authentication events -> Option CQuick Check:
Enable + index output + authentication category = xpack.security.audit.enabled: true xpack.security.audit.outputs: ["index"] xpack.security.audit.categories: ["authentication"] [OK]
Hint: Enable true + output index + category authentication [OK]
Common Mistakes:
- Disabling audit logging by mistake
- Choosing wrong categories like access_granted
- Using logfile output instead of index only
