Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding documentation page on what ElastAlert metrics are being exposed via --prometheus_port configuration flag #498

Merged
merged 7 commits into from
Oct 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
- None

## Other changes
- None
- [Docs] Add exposed metrics documentation - [#498](https://github.com/jertel/elastalert2/pull/498) - @thisisxgp

# 2.2.2

Expand Down
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Contents:
recipes/writing_filters
recipes/adding_enhancements
recipes/adding_loaders
recipes/exposing_rule_metrics
recipes/signing_requests
recipes/faq

Expand Down
58 changes: 58 additions & 0 deletions docs/source/recipes/exposing_rule_metrics.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
.. _exposingrulemetrics:

Exposing Rule Metrics
=====================

Configuration
-------------
Running ElastAlert with ``--prometheus_port`` configuration flag will expose ElastAlert 2 Prometheus metrics on the specified port. Prometheus metrics are disabled by default.

To expose ElastAlert rule metrics on port ``9979`` run the following command:

.. code-block:: console

$ elastalert --config config.yaml --prometheus_port 9979

Rule Metrics
------------

The metrics being exposed are related to the `ElastAlert metadata indices <https://elastalert2.readthedocs.io/en/latest/elastalert_status.html>`_. The exposed metrics are in the `Prometheus text-based format <https://prometheus.io/docs/instrumenting/exposition_formats/#text-based-format>`_. Metrics are of the metric type `counter <https://prometheus.io/docs/concepts/metric_types/#counter>`_ or `gauge <https://prometheus.io/docs/concepts/metric_types/#gauge>`_ and follow the `Prometheus metric naming <https://prometheus.io/docs/practices/naming/>`_.

In the standard metric definition, the metric names are structured as follows:

.. code-block:: console

elastalert_{metric}_{unit}

Where:

- ``{metric}`` is a unique name of the metric. For example, ``hits``.
- ``{unit}`` is the unit of measurement of the metric value. For example, ``total`` is a counter type metric and ``created`` is a gauge type metric.

All metrics except ``elastalert_errors_{unit}`` have values that apply to a particular rule name. In the exported metrics, these can be identified using the ``rule_name`` `Prometheus label <https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels>`_.

Find below all available metrics:

+---------------------------------------+-----------------+---------------------------+---------------+
| METRIC | Type | Description | Label |
+=======================================+=================+===========================+===============+
| ``elastalert_scrapes_{unit}`` | Counter, Gauge | Number of scrapes | ``rule_name`` |
+---------------------------------------+-----------------+---------------------------+---------------+
| ``elastalert_hits_{unit}`` | Counter, Gauge | Number of hits | ``rule_name`` |
+---------------------------------------+-----------------+---------------------------+---------------+
| ``elastalert_matches_{unit}`` | Counter, Gauge | Number of matches | ``rule_name`` |
+---------------------------------------+-----------------+---------------------------+---------------+
| ``elastalert_time_taken_{unit}`` | Counter, Gauge | Time taken in seconds | ``rule_name`` |
+---------------------------------------+-----------------+---------------------------+---------------+
| ``elastalert_alerts_sent_{unir}`` | Counter, Gauge | Number of alerts sent | ``rule_name`` |
+---------------------------------------+-----------------+---------------------------+---------------+
| ``elastalert_alerts_not_sent_{unit}`` | Counter, Gauge | Number of alerts not sent | ``rule_name`` |
+---------------------------------------+-----------------+---------------------------+---------------+
| ``elastalert_alerts_silenced_{unit}`` | Counter, Gauge | Number of silenced alerts | ``rule_name`` |
+---------------------------------------+-----------------+---------------------------+---------------+
| ``elastalert_errors_{unit}`` | Counter, Gauge | Number of errors | |
+---------------------------------------+-----------------+---------------------------+---------------+




2 changes: 1 addition & 1 deletion docs/source/running_elastalert.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ logs `localhost:9200` instead of the actual ``es_host``:``es_port``.
``--pin_rules`` will stop ElastAlert 2 from loading, reloading or removing rules
based on changes to their config files.

``--prometheus_port`` exposes ElastAlert 2 Prometheus metrics on the specified
``--prometheus_port`` exposes ElastAlert 2 `Prometheus metrics <https://elastalert2.readthedocs.io/en/latest/recipes/exposing_rule_metrics.html>`_ on the specified
port. Prometheus metrics disabled by default.

``--rule <rule.yaml>`` will only run the given rule. The rule file may be a
Expand Down