NAME

Net::Prometheus::Pushgateway - client module for pushing metrics to prometheus exporter (pushgateway, prometheus aggregation gateway)

SYNOPSYS

use Net::Prometheus::Pushgateway;

# Create Net::Prometheus::Pushgateway object for pushgateway exporter
my $metric = Net::Prometheus::Pushgateway->new(
    '-host'         => '127.0.0.1',
    '-port'         => 9091,
    '-path'         => '/metrics/job/<job_name>/instance/<instance_name>',
);
# OR
# Create Net::Prometheus::Pushgateway object for prometheus aggregation gateway
my $metric = Net::Prometheus::Pushgateway->new(
    '-host'         => '127.0.0.1',
    '-port'         => 9091,
    '-path'         => '/api/ui/metrics',
);

# Send increment metric
$metric->increment(-metric_name => 'perl_metric_increment', -label => {'perl_label' => 5});

# Send summary metric
$metric->summary(-metric_name => 'perl_metric_summary', -label => {'perl_label' => 5}, -value => 15);

# Send histogram metric
$metric->histogram(-metric_name => 'perl_metric_histogram', -label => {'perl_label' => 5}, -value => 15, -buckets => [qw/1 2 3 4 5/]);

METHODS

new(%opt)

Create Net::Prometheus::Pushgateway object

Options:
    -host                   => Prometheus exporter host
    -port                   => Prometheus exporter port number
    -path                   => Path to prometheus exporter host (/api/ui/metrics - prometheus aggregation gateway, /metrics/job/<job_name>/instance/<instance_name> - prometeus
    -timeout                => LWP::UserAgent timeout (default: 5)

PUSH METRICS

add(%opt)

Push custom metrics

Options:
    -metric_name            => Name of pushed metrics
    -label                  => HashRef to metric labels
    -value                  => Metric value
    -type                   => Metric type (default: untyped. Valid metric types in %Net::Prometheus::Pushgateway::METRIC_VALID_TYPE)S

increment(%opt)

Push increment metrics

Options:
    -metric_name            => Name of pushed metrics
    -label                  => HashRef to metric labels

summary(%opt)

Push summary metrics

Options:
    -metric_name            => Name of pushed metrics
    -value                  => Metric value
    -label                  => HashRef to metric labels (default: {})

histogram(%opt)

Push histogram metric

Options:
    -metric_name            => Name of pushed metrics
    -value                  => Metric value
    -label                  => HashRef to metric labels (default: {})
    -buckets                => ArayRef to buckets values

DEPENDENCE

LWP::UserAgent

AUTHORS

  • Pavel Andryushin <vrag867@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2020 by Pavel Andryushin.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.