# jertel/elastalert2 architecture

> Architecture diagram of the GitHub repository jertel/elastalert2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jertel/elastalert2
- Repository: https://github.com/jertel/elastalert2

## Overview

ElastAlert 2 evaluates configured rules against Elasticsearch or OpenSearch data and sends notifications when they match. The main workflow is configuration and rule loading, scheduled query/match processing, optional enhancement and aggregation, then alert formatting and delivery. The tree and source index identify the principal modules and several cross-module references; some runtime wiring is not visible in the excerpts, so those relationships are omitted or marked unverified. The README also documents support for both search backends and a broad range of alert destinations.

Main entry points: [`elastalert/elastalert.py`](https://github.com/jertel/elastalert2/blob/master/elastalert/elastalert.py) (Scheduler and matcher), [`elastalert/loaders.py`](https://github.com/jertel/elastalert2/blob/master/elastalert/loaders.py) (Rule loading), [`elastalert/config.py`](https://github.com/jertel/elastalert2/blob/master/elastalert/config.py) (Configuration), [`elastalert/alerters`](https://github.com/jertel/elastalert2/tree/master/elastalert/alerters) (Alert integrations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Configuration and rules"]
  node_config["Configuration<br/>[config.py]"]
  node_rule_loader["Rule loading<br/>[loaders.py]"]
  node_rule_types["Rule types<br/>[ruletypes.py]"]
  node_query_languages["EQL and ES&#124;QL"]
end

subgraph group_engine["Detection engine"]
  node_engine["Scheduler and matcher<br/>[elastalert.py]"]
  node_enhancements["Match enhancements<br/>[enhancements.py]"]
end

subgraph group_support["Search and context"]
  node_search[("Elasticsearch / OpenSearch")]
  node_auth["Search authentication<br/>[auth.py]"]
  node_utilities["Shared utilities<br/>[util.py]"]
  node_index_management["Index management<br/>[create_index.py]"]
  node_discover["Discover links<br/>[kibana_discover.py]"]
  node_opensearch_discover["OpenSearch Discover"]
  node_url_formatters["External URL formatters"]
  node_prometheus["Prometheus metrics"]
end

subgraph group_delivery["Alert delivery"]
  node_alert_text["Alert formatting<br/>[alerts.py]"]
  node_alert_dispatch["Alert dispatch<br/>[elastalert.py]"]
  node_alerters["Alert integrations"]
  node_alert_index["Alert indexing<br/>[indexer.py]"]
end

node_operator(("Rule operator"))
node_destinations(("Notification services"))

node_operator -->|"supplies settings"| node_config
node_config -->|"provides configuration"| node_rule_loader
node_rule_loader -->|"loads rule types"| node_rule_types
node_rule_loader -.->|"provides rules"| node_engine
node_engine -.->|"queries"| node_search
node_auth -.->|"authorizes requests"| node_search
node_engine -->|"applies enhancements"| node_enhancements
node_engine -->|"dispatches matches"| node_alert_dispatch
node_alert_dispatch -->|"formats alerts"| node_alert_text
node_alert_dispatch -.->|"dispatches alerts"| node_alerters
node_alerters -->|"sends notifications"| node_destinations
node_alert_dispatch -.->|"indexes alerts"| node_alert_index
node_engine -->|"builds Kibana links"| node_discover
node_engine -->|"builds OpenSearch links"| node_opensearch_discover
node_engine -->|"formats external URLs"| node_url_formatters
node_engine -->|"reports metrics"| node_prometheus
node_index_management -.->|"manages indices"| node_search
node_engine -->|"uses helpers"| node_utilities
node_query_languages -.->|"supports rule queries"| node_engine

click node_config "https://github.com/jertel/elastalert2/blob/master/elastalert/config.py"
click node_rule_loader "https://github.com/jertel/elastalert2/blob/master/elastalert/loaders.py"
click node_rule_types "https://github.com/jertel/elastalert2/blob/master/elastalert/ruletypes.py"
click node_query_languages "https://github.com/jertel/elastalert2/tree/master/elastalert"
click node_engine "https://github.com/jertel/elastalert2/blob/master/elastalert/elastalert.py"
click node_enhancements "https://github.com/jertel/elastalert2/blob/master/elastalert/enhancements.py"
click node_auth "https://github.com/jertel/elastalert2/blob/master/elastalert/auth.py"
click node_utilities "https://github.com/jertel/elastalert2/blob/master/elastalert/util.py"
click node_index_management "https://github.com/jertel/elastalert2/blob/master/elastalert/create_index.py"
click node_discover "https://github.com/jertel/elastalert2/blob/master/elastalert/kibana_discover.py"
click node_opensearch_discover "https://github.com/jertel/elastalert2/blob/master/elastalert/opensearch_discover.py"
click node_url_formatters "https://github.com/jertel/elastalert2/tree/master/elastalert"
click node_prometheus "https://github.com/jertel/elastalert2/blob/master/elastalert/prometheus_wrapper.py"
click node_alert_text "https://github.com/jertel/elastalert2/blob/master/elastalert/alerts.py"
click node_alert_dispatch "https://github.com/jertel/elastalert2/blob/master/elastalert/elastalert.py"
click node_alerters "https://github.com/jertel/elastalert2/tree/master/elastalert/alerters"
click node_alert_index "https://github.com/jertel/elastalert2/blob/master/elastalert/alerters/indexer.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_config,node_rule_loader,node_rule_types,node_query_languages toneBlue
class node_engine,node_enhancements toneAmber
class node_search,node_auth,node_utilities,node_index_management,node_discover,node_opensearch_discover,node_url_formatters,node_prometheus toneMint
class node_alert_text,node_alert_dispatch,node_alerters,node_alert_index toneRose
class node_operator,node_destinations toneIndigo
```

## Components

### Configuration and rules

- [Configuration](https://github.com/jertel/elastalert2/blob/master/elastalert/config.py): `elastalert/config.py`
- [Rule loading](https://github.com/jertel/elastalert2/blob/master/elastalert/loaders.py): `elastalert/loaders.py`
- [Rule types](https://github.com/jertel/elastalert2/blob/master/elastalert/ruletypes.py): `elastalert/ruletypes.py`
- [EQL and ES|QL](https://github.com/jertel/elastalert2/tree/master/elastalert): `elastalert`

### Detection engine

- [Scheduler and matcher](https://github.com/jertel/elastalert2/blob/master/elastalert/elastalert.py): `elastalert/elastalert.py`
- [Match enhancements](https://github.com/jertel/elastalert2/blob/master/elastalert/enhancements.py): `elastalert/enhancements.py`

### Search and context

- **Elasticsearch / OpenSearch**
- [Search authentication](https://github.com/jertel/elastalert2/blob/master/elastalert/auth.py): `elastalert/auth.py`
- [Shared utilities](https://github.com/jertel/elastalert2/blob/master/elastalert/util.py): `elastalert/util.py`
- [Index management](https://github.com/jertel/elastalert2/blob/master/elastalert/create_index.py): `elastalert/create_index.py`
- [Discover links](https://github.com/jertel/elastalert2/blob/master/elastalert/kibana_discover.py): `elastalert/kibana_discover.py`
- [OpenSearch Discover](https://github.com/jertel/elastalert2/blob/master/elastalert/opensearch_discover.py): `elastalert/opensearch_discover.py`
- [External URL formatters](https://github.com/jertel/elastalert2/tree/master/elastalert): `elastalert`
- [Prometheus metrics](https://github.com/jertel/elastalert2/blob/master/elastalert/prometheus_wrapper.py): `elastalert/prometheus_wrapper.py`

### Alert delivery

- [Alert formatting](https://github.com/jertel/elastalert2/blob/master/elastalert/alerts.py): `elastalert/alerts.py`
- [Alert dispatch](https://github.com/jertel/elastalert2/blob/master/elastalert/elastalert.py): `elastalert/elastalert.py`
- [Alert integrations](https://github.com/jertel/elastalert2/tree/master/elastalert/alerters): `elastalert/alerters`
- [Alert indexing](https://github.com/jertel/elastalert2/blob/master/elastalert/alerters/indexer.py): `elastalert/alerters/indexer.py`

### Other components

- **Rule operator**
- **Notification services**

## Connections

- Rule operator → Configuration: supplies settings
- Configuration → Rule loading: provides configuration (evidence: `elastalert/config.py`)
- Rule loading → Rule types: loads rule types (evidence: `elastalert/loaders.py`)
- Rule loading → Scheduler and matcher: provides rules
- Scheduler and matcher → Elasticsearch / OpenSearch: queries
- Search authentication → Elasticsearch / OpenSearch: authorizes requests
- Scheduler and matcher → Match enhancements: applies enhancements (evidence: `elastalert/elastalert.py`)
- Scheduler and matcher → Alert dispatch: dispatches matches (evidence: `elastalert/elastalert.py`)
- Alert dispatch → Alert formatting: formats alerts (evidence: `elastalert/alerts.py`)
- Alert dispatch → Alert integrations: dispatches alerts (evidence: `elastalert/elastalert.py`)
- Alert integrations → Notification services: sends notifications
- Alert dispatch → Alert indexing: indexes alerts
- Scheduler and matcher → Discover links: builds Kibana links (evidence: `elastalert/elastalert.py`)
- Scheduler and matcher → OpenSearch Discover: builds OpenSearch links (evidence: `elastalert/elastalert.py`)
- Scheduler and matcher → External URL formatters: formats external URLs (evidence: `elastalert/elastalert.py`)
- Scheduler and matcher → Prometheus metrics: reports metrics (evidence: `elastalert/elastalert.py`)
- Index management → Elasticsearch / OpenSearch: manages indices
- Scheduler and matcher → Shared utilities: uses helpers (evidence: `elastalert/elastalert.py`)
- EQL and ES|QL → Scheduler and matcher: supports rule queries (evidence: `elastalert/util.py`)
