Bird
Raised Fist0
Elasticsearchquery~20 mins

Audit logging in Elasticsearch - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Challenge - 5 Problems
🎖️
Audit Logging Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:00remaining
Purpose of Audit Logging in Elasticsearch

What is the main purpose of enabling audit logging in Elasticsearch?

ATo monitor cluster health and node resource usage
BTo track and record security-related events such as user authentication and access attempts
CTo automatically backup data to a remote location
DTo improve search query performance by caching frequent queries
Attempts:
2 left
💡 Hint

Think about what audit logs are generally used for in security contexts.

Configuration
intermediate
1:30remaining
Enabling Audit Logging in elasticsearch.yml

Which configuration snippet correctly enables audit logging for all events in Elasticsearch?

A
xpack.security.audit.enabled: true
xpack.security.audit.logfile.events.exclude: ["authentication_failed"]
B
xpack.security.audit.enabled: false
xpack.security.audit.logfile.events.include: ["access_denied"]
C
xpack.security.audit.enabled: true
xpack.security.audit.logfile.events.include: ["authentication_failed"]
D
xpack.security.audit.enabled: true
xpack.security.audit.logfile.events.include: ["*"]
Attempts:
2 left
💡 Hint

Look for the setting that enables audit logging and includes all events.

💻 Command Output
advanced
1:30remaining
Output of Audit Log Entry for Failed Login

Given audit logging is enabled, what is the expected key field value in the audit log entry when a user fails to login?

A"event.action": "authentication_failed"
B"event.action": "access_granted"
C"event.action": "cluster_health"
D"event.action": "index_created"
Attempts:
2 left
💡 Hint

Think about what action describes a failed login attempt.

Troubleshoot
advanced
2:00remaining
Troubleshooting Missing Audit Logs

You enabled audit logging in Elasticsearch but no audit logs appear in the log files. Which is the most likely cause?

AThe audit log file path is not writable by Elasticsearch process
BElasticsearch cluster is offline
CAudit logging is enabled but the log level is set too high, filtering out audit events
DThe index templates are missing
Attempts:
2 left
💡 Hint

Consider file permissions and where logs are written.

Best Practice
expert
2:30remaining
Best Practice for Managing Audit Log Size

What is a recommended best practice to manage the size and retention of Elasticsearch audit logs in a production environment?

AManually delete audit log files weekly from the file system
BDisable audit logging during peak hours to reduce log size
CConfigure log rotation and retention policies using Elasticsearch's built-in rollover and ILM (Index Lifecycle Management)
DStore audit logs only in memory to avoid disk usage
Attempts:
2 left
💡 Hint

Think about automated ways to keep logs manageable over time.

Practice

(1/5)
1. What is the main purpose of audit logging in Elasticsearch?
easy
A. To record user actions and security events
B. To improve search speed
C. To backup data automatically
D. To monitor cluster health

Solution

  1. Step 1: Understand audit logging function

    Audit logging tracks what users do and records security-related events.
  2. Step 2: Compare with other options

    Improving search speed, backing up data, or monitoring cluster health are different Elasticsearch features.
  3. Final Answer:

    To record user actions and security events -> Option A
  4. Quick 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
A. security.audit.log: on
B. xpack.security.audit.enabled: true
C. audit.logging.enabled: yes
D. xpack.audit.security: enabled

Solution

  1. Step 1: Identify correct setting syntax

    The official setting to enable audit logging is xpack.security.audit.enabled set to true.
  2. Step 2: Check other options for correctness

    Other options use incorrect keys or values not recognized by Elasticsearch.
  3. Final Answer:

    xpack.security.audit.enabled: true -> Option B
  4. Quick 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:
 xpack.security.audit.enabled: true
 xpack.security.audit.outputs: ["logfile", "index"] 

What does this configuration do?
medium
A. Enables audit logging and sends data to log files and Elasticsearch index
B. Disables audit logging but logs to file
C. Enables audit logging but only logs to console
D. Enables audit logging but stores data only in memory

Solution

  1. Step 1: Analyze 'enabled' setting

    Setting xpack.security.audit.enabled: true turns audit logging on.
  2. Step 2: Analyze 'outputs' setting

    Outputs set to ["logfile", "index"] means audit data is saved to log files and Elasticsearch indexes.
  3. Final Answer:

    Enables audit logging and sends data to log files and Elasticsearch index -> Option A
  4. Quick 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
A. User permissions prevent audit logging
B. Elasticsearch cluster is offline
C. Audit logging requires a restart of Kibana
D. Audit outputs are not configured, so logs have no destination

Solution

  1. Step 1: Check audit logging enablement

    Audit logging is enabled, so it should produce logs if outputs are set.
  2. Step 2: Verify output configuration

    If xpack.security.audit.outputs is missing or empty, logs have nowhere to go, so no logs appear.
  3. Final Answer:

    Audit outputs are not configured, so logs have no destination -> Option D
  4. Quick 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
A. xpack.security.audit.enabled: true xpack.security.audit.outputs: ["index", "logfile"] xpack.security.audit.categories: ["access_denied"]
B. xpack.security.audit.enabled: true xpack.security.audit.outputs: ["logfile"] xpack.security.audit.categories: ["access_granted"]
C. xpack.security.audit.enabled: true xpack.security.audit.outputs: ["index"] xpack.security.audit.categories: ["authentication"]
D. xpack.security.audit.enabled: false xpack.security.audit.outputs: ["index"] xpack.security.audit.categories: ["authentication"]

Solution

  1. Step 1: Enable audit logging

    Set xpack.security.audit.enabled: true to turn on audit logging.
  2. Step 2: Set output to Elasticsearch index only

    Use xpack.security.audit.outputs: ["index"] to store logs in an index.
  3. Step 3: Filter to authentication events

    Set xpack.security.audit.categories: ["authentication"] to audit only authentication events.
  4. Final Answer:

    Enable audit, output to index, filter authentication events -> Option C
  5. Quick 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