prometheus_cowboy2_instrumenter (prometheus_cowboy v0.2.0)
View SourceCollects Cowboy metrics using metrics stream handler
Exported metrics
cowboy_early_errors_total
: Total number of Cowboy early errors, i.e. errors that occur before a request is received.- Type: counter.
- Labels: default -
[]
, configured viaearly_errors_labels
.
cowboy_protocol_upgrades_total
: Total number of protocol upgrades, i.e. when http connection upgraded to websocket connection.- Type: counter.
- Labels: default -
[]
, configured viaprotocol_upgrades_labels
.
cowboy_requests_total
: Total number of Cowboy requests.- Type: counter.
- Labels: default -
[method, reason, status_class]
, configured viarequest_labels
.
cowboy_spawned_processes_total
: Total number of spawned processes.- Type: counter.
- Labels: default -
[method, reason, status_class]
, configured viarequest_labels
.
cowboy_errors_total
: Total number of Cowboy request errors.- Type: counter.
- Labels: default -
[method, reason, error]
, configured viaerror_labels
.
cowboy_request_duration_seconds
: Cowboy request duration.- Type: histogram.
- Labels: default -
[method, reason, status_class]
, configured viarequest_labels
. - Buckets: default -
[0.01, 0.1, 0.25, 0.5, 0.75, 1, 1.5, 2, 4]
, configured viaduration_buckets
.
cowboy_receive_body_duration_seconds
: Request body receiving duration.- Type: histogram.
- Labels: default -
[method, reason, status_class]
, configured viarequest_labels
. - Buckets: default -
[0.01, 0.1, 0.25, 0.5, 0.75, 1, 1.5, 2, 4]
, configured viaduration_buckets
.
cowboy_request_body_size_bytes
: Request body size in bytes.- Type: histogram.
- Labels: default -
[method, reason, status_class]
, configured viarequest_labels
. Buckets: default -
[0 | prometheus_buckets:exponential(1, 8.0, 9)]
(0 KiB - 16 MiB), configured viabody_size_buckets
.
cowboy_response_body_size_bytes
: Response body size in bytes.- Type: histogram.
- Labels: default -
[method, reason, status_class]
, configured viarequest_labels
. Buckets: default -
[0 | prometheus_buckets:exponential(1, 8.0, 9)]
(0 KiB - 16 MiB), configured viabody_size_buckets
.
Configuration
Prometheus Cowboy2 instrumenter configured via cowboy_instrumenter
key of prometheus
app environment.
Default configuration:
{prometheus, [
...
{cowboy_instrumenter, [{duration_buckets, [0.01, 0.1, 0.25, 0.5,
0.75, 1, 1.5, 2, 4]},
{early_error_labels, []},
{request_labels, [method, reason, status_class]},
{error_labels, [method, reason, error]},
{registry, default}]}
...
]}
Labels
Builtin:
- host,
- port,
- method,
- status,
- status_class,
- reason,
- error.
Custom labels
Can be implemented via module exporting label_value/2 function.
First argument will be label name, second is Metrics data from
metrics stream handler
Set this module to labels_module
configuration option.
Summary
Functions
-spec observe(map()) -> ok.
metrics stream handler callback
-spec setup() -> ok.
Sets all metrics up. Call this when the app starts.