Dancer2::Plugin::PrometheusTiny - use Prometheus::Tiny with Dancer2
This plugin integrates Prometheus::Tiny::Shared with your Dancer2 app, providing some default metrics for requests and responses, with the ability to easily add further metrics to your app. A route is added which makes the metrics available via the configured "endpoint".
See Prometheus::Tiny for more details of the kind of metrics supported.
The following metrics are included by default:
http_request_duration_seconds => {
help => 'Request durations in seconds',
type => 'histogram',
},
http_request_size_bytes => {
help => 'Request sizes in bytes',
type => 'histogram',
buckets => [ 1, 50, 100, 1_000, 50_000, 500_000, 1_000_000 ],
},
http_requests_total => {
help => 'Total number of http requests processed',
type => 'counter',
},
http_response_size_bytes => {
help => 'Response sizes in bytes',
type => 'histogram',
buckets => [ 1, 50, 100, 1_000, 50_000, 500_000, 1_000_000 ],
}
get '/some/route' => sub {
prometheus->inc(...);
}
Returns the Prometheus::Tiny::Shared
instance.
Example:
plugins:
PrometheusTiny:
endpoint: /prometheus-metrics # default: /metrics
filename: /run/d2prometheus # default: (undef)
include_default_metrics: 0 # default: 1
metrics: # default: {}
http_request_count:
help: HTTP Request count
type: counter
See below for full details of each configuration setting.
The endpoint from which metrics are served. Defaults to /metrics
.
It is recommended that this is set to a directory on a memory-backed filesystem. See "filename" in Prometheus::Tiny::Shared for details and default value.
Defaults to true. If set to false, then the default metrics shown in "DESCRIPTION" will not be added.
Declares extra metrics to be merged with those included with the plugin. See See "declare" in Prometheus::Tiny for details.
Defaults to Prometheus::Tiny::Shared.
WARNING: You should only set this if you are running a single process plack server such as Twiggy, and you don't want to use file-based store for metrics. Setting this to Prometheus::Tiny will mean that metrics are instead stored in memory.
Peter Mottram (SysPete) <peter@sysnix.com>
None yet.
Copyright (c) 2021 the Catalyst::Plugin::PrometheusTiny "AUTHOR" and "CONTRIBUTORS" as listed above.
This library is free software and may be distributed under the same terms as Perl itself.