Skip to content

pipeline: processors: metrics-selector: general cleanup #1933

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 15 additions & 16 deletions pipeline/processors/metrics-selector.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
# Metrics Selector
# Metrics selector

The _Metrics Selector_ processor lets you choose which metrics to include or exclude, similar to the [Grep](../pipeline/filters/grep) filter for logs.
The _metrics selector_ processor lets you choose which metrics to include or exclude, similar to the [grep](../pipeline/filters/grep) filter for logs.

<img referrerpolicy="no-referrer-when-downgrade" src="https://static.scarf.sh/a.png?x-pxid=326269f3-cfea-472d-9169-1de32c142b90" />

## Configuration parameters

The Metrics Selector processor supports the following configuration parameters:
The metrics selector processor supports the following configuration parameters:

| Key | Description | Default |
| :---------- | :--- | :--- |
| `metric_name` | The string that determines which metrics are affected by this processor, depending on the active [matching operation](#matching-operations). | |
| Key | Description | Default |
| --- | ----------- | ------- |
| `metric_name` | The string that determines which metrics are affected by this processor, depending on the active [matching operation](#matching-operations). | _none_ |
| `context` | Specifies matching context. Possible values: `metric_name` or `delete_label`. | `metrics_name` |
| `action` | Specifies whether to include or exclude matching metrics. Possible values: `INCLUDE` or `EXCLUDE`. | |
| `operation_type` | Specifies the [matching operation](#matching-operations) to apply to the value of `metric_name`. Possible values: `PREFIX` or `SUBSTRING`. | |
| `label` | Specifies a label key and value pair. | |
| `action` | Specifies whether to include or exclude matching metrics. Possible values: `INCLUDE` or `EXCLUDE`. | _none_ |
| `operation_type` | Specifies the [matching operation](#matching-operations) to apply to the value of `metric_name`. Possible values: `PREFIX` or `SUBSTRING`. | _none_ |
| `label` | Specifies a label key and value pair. | _none_ |

## Matching operations

The Metrics Selector processor has two matching operations: prefix matching and substring matching.
The metrics selector processor has these matching operations: prefix matching and substring matching.

### Prefix matching

Prefix matching compares the value of `metric_name` to the beginning of each incoming metric name. For example, `metric_name: fluentbit_input` results in a match for metrics named `fluentbit_input_records`, but not for metrics named `total_fluentbit_input`.
Prefix matching compares the value of `metric_name` to the beginning of each incoming metric name. For example, the value `fluentbit_input` results in a match for metrics named `fluentbit_input_records`, but not for metrics named `total_fluentbit_input`.

If no `operation_type` value is specified and the value of `metric_name` is a standard string, the Metrics Selector processor defaults to prefix matching.
If no `operation_type` value is specified, and if the value of `metric_name` is a standard string, the metrics selector processor defaults to prefix matching.

### Substring matching

Substring matching treats the value of `metric_name` as a regex pattern, and compares this pattern against each incoming metric name accordingly. This pattern can appear anywhere within the name of the incoming metric. For example, `metric_name: bytes` results in a match for metrics named `bytes_total` and metrics named `input_bytes_count`.
Substring matching treats the value of `metric_name` as a regular expression pattern, and compares this pattern against each incoming metric name accordingly. This pattern can appear anywhere within the name of the incoming metric. For example, the value `bytes` results in a match for both metrics named `bytes_total` and metrics named `input_bytes_count`.

If the value of `metric_name` is a string wrapped in forward slashes (for example, `metric_name: /storage..*/`), the Metrics Selector processor defaults to substring matching, regardless of whether an `operation_type` value is specified. This means that a `metric_name` value wrapped in forward slashes will always use substring matching, even if `operation_type` is set to `PREFIX`.
If the value of `metric_name` is a string wrapped in forward slashes (for example, `metric_name: /storage..*/`), the metrics selector processor defaults to substring matching, regardless of whether an `operation_type` value is specified. This means that a `metric_name` value wrapped in forward slashes will always use substring matching, even if `operation_type` is set to `PREFIX`.

However, if `operation_type` is explicitly set to `SUBSTRING`, you don't need to wrap the value of `metric_name` in forward slashes.

## Configuration examples

The following examples show possible configurations of the Metrics Selector processor.
The following examples show possible configurations of the metrics selector processor.

### Without `context`

Expand Down Expand Up @@ -93,7 +93,6 @@ pipeline:
- name: labels
delete: name


outputs:
- name: stdout
match: '*'
Expand Down