# Compute Metric Statistics

### Description

The Compute Metric Statistics processor can be used to calculate statistics for metrics over fixed time intervals to reduce metric throughput.

### Supported Types

| Metrics | Logs | Traces |
| ------- | ---- | ------ |
| ✓       |      |        |

### Configuration Table

<table><thead><tr><th width="96.24609375">Parameter</th><th width="113.05078125">Type</th><th>Default</th><th width="541.98046875">Description</th></tr></thead><tbody><tr><td>interval</td><td><code>int</code></td><td><code>60</code></td><td>The interval in seconds on which to aggregate metrics. Calculated metrics will be emitted after the interval passes.</td></tr><tr><td>include</td><td><code>regex</code></td><td><code>.*</code></td><td>A regex that must match against the metric's name in order to calculate statistics from it. The default value matches all metrics.</td></tr><tr><td>stats</td><td><code>[]string</code></td><td><code>["min", "max", "avg"]</code></td><td>A list of statistics to calculate on matched metrics. Valid values are: <code>min</code>, <code>max</code>, <code>avg</code>, <code>first</code>, and <code>last</code>.</td></tr></tbody></table>

### Example Configuration

#### Calculate Average, Minimum, and Maximum

Calculate the average, minimum, and maximum values of each incoming metric, and emit them with a `.avg`, `.min`, and `.max` suffix, respectively.

**Web Interface**

<figure><img src="https://1405008107-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgmiOMzBfoNFwmKJFHMcJ%2Fuploads%2Fgit-blob-13283a584b66839bf3c78b2f8bddac677a57bc90%2Fintegrations-processors-compute-metric-statistics-image-1.png?alt=media" alt="Bindplane docs - Compute Metric Statistics - image 1"><figcaption></figcaption></figure>

**Standalone Processor**

```yaml
apiVersion: bindplane.observiq.com/v1
kind: Processor
metadata:
  id: calculate-avg-min-max
  name: calculate-avg-min-max
spec:
  type: metric_stats
  parameters:
    - name: interval
      value: 60
    - name: include
      value: '.*'
    - name: stats
      value: ['min', 'max', 'avg']
```

#### Take the Most Recent Value

Take the last value of a metric over a 60 second interval, and emit the metric with a suffix of `.last`.

**Web Interface**

<figure><img src="https://1405008107-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgmiOMzBfoNFwmKJFHMcJ%2Fuploads%2Fgit-blob-f30643a3065fd58b08ad7cceb1cb788e0aed0180%2Fintegrations-processors-compute-metric-statistics-image-2.png?alt=media" alt="Bindplane docs - Compute Metric Statistics - image 2"><figcaption></figcaption></figure>

**Standalone Processor**

```yaml
apiVersion: bindplane.observiq.com/v1
kind: Processor
metadata:
  id: calculate-last-value
  name: calculate-last-value
spec:
  type: metric_stats
  parameters:
    - name: interval
      value: 60
    - name: include
      value: '.*'
    - name: stats
      value: ['last']
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.bindplane.com/integrations/processors/compute-metric-statistics.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
