Prometheus::Tiny - A tiny Prometheus client
use Prometheus::Tiny; my $prom = Prometheus::Tiny->new; $prom->set('some_metric', 5, { some_label => "aaa" }); print $prom->format;
Prometheus::Tiny is a minimal metrics client for the Prometheus time-series database.
Prometheus::Tiny
It does the following things differently to Net::Prometheus:
No setup. You don't need to pre-declare metrics to get something useful.
Labels are passed in a hash. Positional parameters get awkward.
No inbuilt collectors, PSGI apps, etc. Just the metrics.
Doesn't know anything about different metric types. You get what you ask for.
These could all be pros or cons, depending on what you need. For me, I needed a compact base that I could back on a shared memory region. See Prometheus::Tiny::Shared for that!
my $prom = Prometheus::Tiny->new
$prom->set($name, $value, { labels })
Set the value for the named metric. The labels hashref is optional.
$prom->add($name, $amount, { labels })
Add the given amount to the already-stored value (or 0 if it doesn't exist). The labels hashref is optional.
$prom->inc($name, { labels })
A shortcut for
$prom->add($name, 1, { labels })
$prom->dec($name, { labels })
$prom->add($name, -1, { labels })
$prom->declare($name, help => $help, type => $type)
"Declare" a metric by setting its help text or type.
my $metrics = $prom->format
Output the stored metrics, values, help text and types in the Prometheus exposition format.
Please report any bugs or feature requests through the issue tracker at https://github.com/robn/Prometheus-Tiny/issues. You will be notified automatically of any progress on your issue.
This is open source software. The code repository is available for public review and contribution under the terms of the license.
https://github.com/robn/Prometheus-Tiny
git clone https://github.com/robn/Prometheus-Tiny.git
Rob N ★ <robn@robn.io>
This software is copyright (c) 2017 by Rob N ★
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Prometheus::Tiny, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Prometheus::Tiny
CPAN shell
perl -MCPAN -e shell install Prometheus::Tiny
For more information on module installation, please visit the detailed CPAN module installation guide.