github.com/Jeffail/benthos/v3@v3.65.0/website/docs/components/metrics/about.md (about)

     1  ---
     2  title: Metrics
     3  sidebar_label: About
     4  ---
     5  
     6  Benthos emits lots of metrics in order to expose how components configured within your pipeline are behaving. You can configure exactly where these metrics end up with the config field `metrics`, which describes a metrics format and destination. For example, if you wished to push them via the StatsD protocol you could use this configuration:
     7  
     8  ```yaml
     9  metrics:
    10    statsd:
    11      prefix: foo
    12      address: localhost:8125
    13      flush_period: 100ms
    14  ```
    15  
    16  ## Metric Names
    17  
    18  The metric names that are emitted depend on your configured pipeline, as each individual component will emit one or more metrics, with each name prefixed with a label that uniquely identifies the component within your config (specified with the field `label`). If a component is configured without a label (or an empty one) then a label is generated based on where the component appears within your config.
    19  
    20  The following is a list of standard metric names that are emitted for components of different types. This list does not cover _all_ metric names as it's possible that certain component implementations might have more granular metrics for other events.
    21  
    22  Names are listed here in dot notation, which is how they will appear if sent to StatsD. Metrics exported in Prometheus format will display these metrics with dots replaced with underscores (and underscores replaced with double underscores).
    23  
    24  ### Inputs
    25  
    26  - `<label>.count`: The number of times the input has attempted to read messages.
    27  - `<label>.received`: The number of messages received by the input.
    28  - `<label>.batch.received`: The number of message batches received by the input.
    29  - `<label>.connection.up`
    30  - `<label>.connection.failed`
    31  - `<label>.connection.lost`
    32  - `<label>.latency`: Measures the roundtrip latency from the point at which a message is read up to the moment the message has either been acknowledged by an output or has been stored within an external buffer.
    33  
    34  ### Buffers
    35  
    36  Buffers do not have a label field, and instead will always emit metric names with the prefix `buffer`:
    37  
    38  - `buffer.backlog`: The (sometimes estimated) size of the buffer backlog in bytes.
    39  - `buffer.write.count`
    40  - `buffer.write.error`
    41  - `buffer.read.count`
    42  - `buffer.read.error`
    43  - `buffer.latency`: Measures the roundtrip latency from the point at which a message is read from the buffer up to the moment it has been acknowledged by the output.
    44  
    45  ### Processors
    46  
    47  - `<label>.count`, the number of times the processor has been invoked (once per batch).
    48  - `<label>.sent`, the number of messages returned by the processor.
    49  - `<label>.batch.sent`, the number of message batches returned by the processor.
    50  - `<label>.error`, the number of errors encountered during processing.
    51  
    52  ### Outputs
    53  
    54  - `<label>.count`: The number of times the output has attempted to send messages.
    55  - `<label>.sent`: The number of messages sent.
    56  - `<label>.batch.sent`: The number of message batches sent.
    57  - `<label>.batch.bytes`: The total number of bytes sent.
    58  - `<label>.batch.latency`: Latency of message batch write in nanoseconds. Includes only successful attempts.
    59  - `<label>.connection.up`
    60  - `<label>.connection.failed`
    61  - `<label>.connection.lost`
    62  
    63  ## Changing or Dropping Metric Names
    64  
    65  Each metrics output type has a field `path_mapping` that allows you to change or remove metric names by applying a [Bloblang mapping][bloblang.about]. For example, the following mapping reduces the metrics exposed by Benthos to an explicit list by deleting names that aren't in that list:
    66  
    67  ```yaml
    68  metrics:
    69    prometheus:
    70      prefix: benthos
    71      path_mapping: |
    72        if ![
    73          "foo_received",
    74          "foo_latency",
    75          "bar_sent"
    76        ].contains(this) { deleted() }
    77  ```
    78  
    79  The value of `this` in the context of the mapping is the full name of the metric. Metrics are registered and renamed when Benthos first starts up, and when trace level logging is enabled you will see a log entry for each metric that outlines the effect of your mapping, which can help diagnose them.
    80  
    81  [bloblang.about]: /docs/guides/bloblang/about
    82  
    83  import ComponentSelect from '@theme/ComponentSelect';
    84  
    85  <ComponentSelect type="metrics" singular="metrics target"></ComponentSelect>