The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

App::ElasticSearch::Utilities::Metrics - Fetches performance metrics about the node

VERSION

version 8.8

SYNOPSIS

This provides a simple API to export some core metrics from the local ElasticSearch instance.

    use App::ElasticSearch::Utilities qw(es_connect);
    use App::ElasticSearch::Utilities::Metrics;

    my $metrics_fetcher = App::ElasticSearch::Utilities::Metrics->new(
        connection           => es_connect(),
        with_cluster_metrics => 1,
        with_index_metrics   => 1,
    );

    my $metrics = $metrics_fetcher->get_metrics();

ATTRIBUTES

connection

An `App::ElasticSearch::Utilities::Connection` instance, or automatically created via es_connect().

ignore

An array of metric names to ignore, in addition to the static list when parsing the `_node/_local/stats` stats. Defaults to:

    [qw(adaptive_selection discovery)]

Plus ignores sections containing ingest, ml, transform UNLESS those roles appear in the node's roles. Also, unless the node is tagged as a data* node, the following keys are ignored:

    [qw(force_merge indexing indices merges pressure recovery segments translog)]

node_details

The Node details provided by the _nodes/_local API.

node_id

The Node ID for the connection, will be automatically discovered

with_cluster_metrics

Boolean, set to true to collect cluster metrics in addition to node metrics

with_index_metrics

Boolean, set to true to collect index level metrics in addition to node metrics

METHODS

get_metrics()

Retrieves the metrics from the local node.

collect_node_metrics()

Returns all relevant stats from the _nodes/_local API

collect_cluster_metrics()

Return all relevant stats from the _cluster/health API as well as a count of `index.blocks.*` in place.

collect_index_metrics()

This method totals the shard, and segment state and size for the current node by index base name.

AUTHOR

Brad Lhotsky <brad@divisionbyzero.net>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2024 by Brad Lhotsky.

This is free software, licensed under:

  The (three-clause) BSD License