telemetry_metrics_prometheus v0.3.0 TelemetryMetricsPrometheus View Source
Prometheus Reporter for Telemetry.Metrics
definitions.
Provide a list of metric definitions to the init/2
function. It's recommended to
run TelemetryMetricsPrometheus under a supervision tree, usually under Application.
def start(_type, _args) do
# List all child processes to be supervised
children = [
{TelemetryMetricsPrometheus, [metrics: metrics()]}
...
]
opts = [strategy: :one_for_one, name: ExampleApp.Supervisor]
Supervisor.start_link(children, opts)
end
defp metrics, do:
[
counter("http.request.count"),
sum("http.request.payload_size", unit: :byte),
last_value("vm.memory.total", unit: :byte)
]
By default, metrics are exposed on port 9568
at /metrics
. The port number
can be configured if necessary. You are not required to use the included server,
though it is recommended. https
is not supported yet, in which case the
TelemetryMetricsPrometheus.Core
library should be used instead. The
TelemetryMetricsPrometheus.Core.scrape/1
function will expose the metrics in
the Prometheus text format.
Please see the TelemetryMetricsPrometheus.Core
docs for information on metric
types and units.
Link to this section Summary
Link to this section Types
option()
View Source
option() ::
TelemetryMetricsPrometheus.Core.prometheus_option()
| {:port, pos_integer()}
| {:metrics, TelemetryMetricsPrometheus.Core.metrics()}
option() :: TelemetryMetricsPrometheus.Core.prometheus_option() | {:port, pos_integer()} | {:metrics, TelemetryMetricsPrometheus.Core.metrics()}
options()
View Source
options() :: [option()]
options() :: [option()]
Link to this section Functions
child_spec(options)
View Source
child_spec(options()) :: Supervisor.child_spec()
child_spec(options()) :: Supervisor.child_spec()
Reporter's child spec.
This function allows you to start the reporter under a supervisor like this:
children = [
{TelemetryMetricsPrometheus, options}
]
See start_link/1
for a list of available options.
Returns a child specification to supervise the process.
start_link(options)
View Source
start_link(options()) :: GenServer.on_start()
start_link(options()) :: GenServer.on_start()
Starts a reporter and links it to the calling process.
Available options:
:metrics
- a list ofTelemetry.Metrics
definitions to monitor. required:name
- the name to set the process's id to. Defaults to:prometheus_metrics
:port
- port number for the reporter instance's server. Defaults to9568
All other options are forwarded to TelemetryMetricsPrometheus.Core.init/2
.