Question

Difficulty: MediumLog Analytics Workspaces and KQL Queries

An administrator needs to query Syslog messages from Linux virtual machines in a Log Analytics workspace.

The administrator wants to identify all log entries from the 'auth' facility that have a severity level of 'err' and were generated within the last 24 hours24\text{ hours}. The query must display only the time of the event, the computer name, and the log message.

Which KQL query should the administrator run to meet these requirements?

  1. Syslog
    | where TimeGenerated > ago(24h)
    | where Facility == "auth" and SeverityLevel == "err"
    | project TimeGenerated, Computer, SyslogMessage
    Answer
  2. B
    Syslog
    | project TimeGenerated, Computer, SyslogMessage
    | where TimeGenerated > ago(24h)
    | where Facility == "auth" and SeverityLevel == "err"
  3. C
    Syslog
    | where TimeGenerated > ago(24h)
    | where Facility = "auth" and SeverityLevel = "err"
    | project TimeGenerated, Computer, SyslogMessage
  4. D
    Syslog
    | where TimeGenerated > ago(24h)
    | where Facility == "auth" or SeverityLevel == "err"
    | project TimeGenerated, Computer, SyslogMessage

Answer

The query that filters by TimeGenerated, Facility, and SeverityLevel using the double equals comparison operator (==) before using the project operator to limit the output columns to TimeGenerated, Computer, and SyslogMessage.
The correct query begins with the Syslog table, filters logs from the last 24 hours, applies the correct criteria using the double equals comparison operator (==) combined with the logical 'and' operator, and then uses the 'project' operator to output only the requested columns (TimeGenerated, Computer, and SyslogMessage). This maintains the required columns in the pipeline for filtering before they are projected.

Step-by-Step Solution

1
Identify the base table and filter by time.
Start the query with the Syslog table, and filter log entries generated in the last 24 hours using '| where TimeGenerated > ago(24h)'.
Filtering records by time first optimizes query performance by reducing the dataset early.
2
Filter by the required criteria using correct operators.
Add '| where Facility == "auth" and SeverityLevel == "err"'.
The 'and' operator ensures both criteria must be met, and the double equals (==) is the correct comparison operator in KQL.
3
Project the requested columns.
Apply '| project TimeGenerated, Computer, SyslogMessage'.
The project operator selects only the specified columns for the final output. This must be done after all filters that require other columns have been executed.

Key Concept

KQL query pipeline processing, filtering, and column projection
Estimated Time:1m 30s
Rate this question