EQL (Event Query Language) Python Library

1.0.0 · active · verified Fri Apr 17

EQL (Event Query Language) is a high-level query language from Microsoft for expressing relationships between events, primarily used in security analytics and threat hunting contexts. The Python library provides tools to parse, validate, and transform EQL queries into an Abstract Syntax Tree (AST). The current stable version is 1.0.0, with releases typically tied to feature enhancements or bug fixes, maintaining a stable API.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to parse a basic EQL query string using the `eql.parse()` function. The function returns an `eql.Query` object, which represents the Abstract Syntax Tree (AST) of the query. This object can then be inspected or used as input for an EQL execution engine (which is not part of this library).

import eql

# Define a simple EQL query string
eql_query_string = "process where eventid == 1 and process_name == 'powershell.exe'"

# Parse the EQL query string into an EQL Query object (AST)
parsed_query = eql.parse(eql_query_string)

print(f"Original EQL: {eql_query_string}")
print(f"Parsed Query Type: {type(parsed_query)}")
print(f"Parsed Query (JSON representation): {parsed_query.to_json(indent=2)}")

# The parsed_query object can then be transformed or evaluated by an external engine.

view raw JSON →