Overview

A Simple web server (ranch) that allows your application to be scraped by prometheus

Installation

To install Prometheus Sidecar, just add an entry to your mix.exs:

def deps do
  [
    {:prometheus_sidecar, "~> 0.1"}
  ]
end

Configuration

There are no required configurations. By default, Prometheus Sidecar will start a simple non-secure (http) web server on http://localhost:5001 with the following endpoints:

Advanced Configuration Options

System EnvElixir configDefaultDescription
PROMETHEUS_SIDECAR_PORT:port5001Change the default port.
PROMETHEUS_SIDECAR_ENABLE_SERVER:enable_servertrueDo not start up the server.
PROMETHEUS_SIDECAR_MAX_CONNECTIONS:max_connections16_384Max connections.
N/A:https[]Enables HTTPS.

For each option you can use either the System environment approach, or the elixir config approach:

PROMETHEUS_SIDECAR_PORT=5001
config :prometheus_sidecar, port: 5001

See the PrometheusSidecar.Env module for more details.

Prometheus Plugs Configuration

Prometheus Sidecar internally uses prometheus_plugs, which greatly facilitates setting any prometheus configurations. See the configuration documentation for details.

Here is an example of how to change /metrics to /stats and require basic auth to access the endpoint

config :prometheus, PrometheusSidecar.PlugExporter, 
  path: "/stats",
  format: :auto,
  registry: :default,
  auth: {:basic, "username", "password"}

Note for the above changes to take effect, run mix deps.clean prometheus_sidecar && mix deps.get

HTTPS

See the HTTPS Guide