Coder Social home page Coder Social logo

deadtrickster / prometheus-httpd Goto Github PK

View Code? Open in Web Editor NEW
23.0 23.0 16.0 111 KB

Expose Prometheus metrics using inets httpd.

License: MIT License

Emacs Lisp 1.57% Erlang 80.63% HTML 5.05% Shell 5.14% Elixir 7.62%
erlang http instrumentation metrics monitoring prometheus

prometheus-httpd's People

Contributors

benoitc avatar deadtrickster avatar gerhard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

prometheus-httpd's Issues

Refactor to base library

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/1

 `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
}

index/0

Renders standard welcome page with useful links and current metrics path.

Both return {Code, Headers, Body}.

Authorization

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}

Don't install rebar3_elvis_plugin plugin

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"}]}]}]}.

Registry selector

Rendering metrics

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).

Telemetry metrics

Configuration entry: telemetry_registry, default is default.

prometheus-httpd module is not started from my dependencies

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?

LICENSE file missing

Please add the LICENSE file. Not having the file might be a problem for some companies that want to use your software.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.