deadtrickster / prometheus-httpd Goto Github PK
View Code? Open in Web Editor NEWExpose Prometheus metrics using inets httpd.
License: MIT License
Expose Prometheus metrics using inets httpd.
License: MIT License
The idea is to have this lib as a foundation for other exporters - plugs, elli, cowboy, etc.
prometheus_httpd_config
stays the same.
prometheus_http
will have shared /metrics
behaviour with two exports:
`render(Env)`
Env
is a map:
%{
path => Path. %% present if you want prometheus_http to handle routing and registry extraction
accept => Accept, %% accepted content types
accept_encoding => AcceptEncoding, %% accepted encodings
registry => Registry, %% ignored if path present, can generate 409 if registry config isn't auto
}
Renders standard welcome page with useful links and current metrics path.
Both return {Code, Headers, Body}
.
the accept dependancy is missing and raise an undef error when the source code fall there:
https://github.com/deadtrickster/prometheus-httpd/blob/master/src/prometheus_http.erl#L133
By default all resources are public.
To enable authorizaton set authorizaton
config entry to authorizaton provider.
prometheus_httpd
comes with basic auth provider with configuration shortcuts:
%% enable basic auth
{authorizaton, {basic, Login, Password}}
%% enable basic auth with external credentials
%% CredentialsProvider is Callable or {Callable, Args}
%% Callable is Fun/2, Module exporting authorize/2, or {Module, authorize/2}
{authorizaton, {basic, CredentialsProvider}}
%% custom authorization provider
%% Provider = is Callable or {Callable, Args}
%% Callable is Fun/1, Module exporting authorize/1, or {Module, authorize/1}
{authorizaton, Provider}
I got server internal error when I start prometheus_httpd and visit http://ip:8081/metrics
Both prometheus_httpd
and accept
use the rebar3_archive_plugin
, which in turn depends on the rebar3_elvis_plugin
, which conflicts with rebar3_lint. Using the latter in a project that depends on prometheus_httpd
may fail in weird ways.
The dependency has actually been removed from the current rebar3_archive_plugin
code, but prometheus_httpd
and accept
depend on older versions of the plugin. It would be nice to update them to use the current rebar3_archive_plugin
code (or to remove that dependency).
FWIW, this works for me as a workaround:
{overrides,
[% The rebar3_archive_plugin (used by prometheus_httpd and accept) depends on
% the rebar3_elvis_plugin, which conflicts with rebar3_lint.
{del,
[{plugins, [{rebar3_archive_plugin, "0.0.1"}]},
{plugins, [{rebar3_archive_plugin, "0.0.2"}]}]}]}.
Configuration entry: registry
, default is auto
.
Dynamic value - from path /metrics(/:registry)
with default to default
.
If configured to auto
, get registry from path. Otherwise, from configuration.
If configured to other than auto
and /metrics/:registry
should return 409 (conflict).
Configuration entry: telemetry_registry
, default is default
.
I have a Diameter application (no Cowboy or other http servers) and I'm starting to add Prometheus metrics support.
I've added to my rebar dependencies:
{deps, [
{lager, "3.8.0"},
{prometheus, "4.5.0"},
prometheus_diameter_collector,
prometheus_httpd,
prometheus_process_collector
]}.
Then, in my app.app.src, I added them to the applications
part:
{application, dccaserver,
[
{description, "Diameter DCCA Server"},
{vsn, "1"},
{registered, []},
{applications, [
kernel,
stdlib,
lager,
sasl,
diameter,
prometheus,
prometheus_process_collector,
prometheus_diameter_collector,
prometheus_httpd,
ocsgateway
]},
{mod, { dccaserver_app, []}},
{env, []}
]}.
But prometheus_httpd
is not started automatically on my application start. If I run it on a shell (rebar shell), and run prometheus_httpd:start()
, the metrics are exposed correctly.
Am I doing something wrong?
Please add the LICENSE file. Not having the file might be a problem for some companies that want to use your software.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.