Skip to content

Latest commit

 

History

History
147 lines (104 loc) · 3.76 KB

prometheus_cowboy2_instrumenter.md

File metadata and controls

147 lines (104 loc) · 3.76 KB

Module prometheus_cowboy2_instrumenter

Collects Cowboy metrics using metrics stream handler .

Description

  • cowboy_early_errors_total
    Type: counter.
    Labels: default - [], configured via early_errors_labels.
    Total number of Cowboy early errors, i.e. errors that occur before a request is received.

  • cowboy_protocol_upgrades_total
    Type: counter.
    Labels: default - [], configured via protocol_upgrades_labels.
    Total number of protocol upgrades, i.e. when http connection upgraded to websocket connection.

  • cowboy_requests_total
    Type: counter.
    Labels: default - [method, reason, status_class], configured via request_labels.
    Total number of Cowboy requests.

  • cowboy_spawned_processes_total
    Type: counter.
    Labels: default - [method, reason, status_class], configured via request_labels.
    Total number of spawned processes.

  • cowboy_errors_total
    Type: counter.
    Labels: default - [method, reason, error], configured via error_labels.
    Total number of Cowboy request errors.

  • cowboy_request_duration_seconds
    Type: histogram.
    Labels: default - [method, reason, status_class], configured via request_labels.
    Buckets: default - [0.01, 0.1, 0.25, 0.5, 0.75, 1, 1.5, 2, 4], configured via duration_buckets.
    Cowboy request duration.

  • cowboy_receive_body_duration_seconds
    Type: histogram.
    Labels: default - [method, reason, status_class], configured via request_labels.
    Buckets: default - [0.01, 0.1, 0.25, 0.5, 0.75, 1, 1.5, 2, 4], configured via duration_buckets.
    Request body receiving duration.

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

Builtin:

  • host,
  • port,
  • method,
  • status,
  • status_class,
  • reason,
  • error.

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.

Function Index

observe/1 Metrics stream handler callback.
setup/0 Sets all metrics up.

Function Details

observe/1


observe(Metrics0::map()) -> ok

Metrics stream handler callback.

setup/0

setup() -> any()

Sets all metrics up. Call this when the app starts.