Build Status MetaCPAN Release Coverage Status

NAME

Mojolicious::Plugin::Prometheus - Mojolicious Plugin

SYNOPSIS

# Mojolicious
$self->plugin('Prometheus');

# Mojolicious::Lite
plugin 'Prometheus';

# Mojolicious::Lite, with custom response buckets (seconds)
plugin 'Prometheus' => { response_buckets => [qw/4 5 6/] };

# You can add your own route to do access control
my $under = app->routes->under('/secret' =>sub {
  my $c = shift;
  return 1 if $c->req->url->to_abs->userinfo eq 'Bender:rocks';
  $c->res->headers->www_authenticate('Basic');
  $c->render(text => 'Authentication required!', status => 401);
  return undef;
});
plugin Prometheus => {route => $under};

DESCRIPTION

Mojolicious::Plugin::Prometheus is a Mojolicious plugin that exports Prometheus metrics from Mojolicious.

Hooks are also installed to measure requests response time and count requests based on method and HTTP return code.

HELPERS

prometheus

Create further instrumentation into your application by using this helper which gives access to the Net::Prometheus object. See Net::Prometheus for usage.

METHODS

Mojolicious::Plugin::Prometheus inherits all methods from Mojolicious::Plugin and implements the following new ones.

register

$plugin->register($app, \%config);

Register plugin in Mojolicious application.

%config can have:

METRICS

In addition to exposing the default process metrics that Net::Prometheus already expose this plugin will also expose

AUTHOR

Vidar Tyldum

(the IPC::ShareLite parts of this code is shamelessly stolen from Mojolicious::Plugin::Status written by Sebastian Riedel and mangled into something that works for me)

COPYRIGHT AND LICENSE

Copyright (C) 2018, Vidar Tyldum

This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.

SEE ALSO