Skip to content
Open
Show file tree
Hide file tree
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
19 changes: 16 additions & 3 deletions src/content/docs/guides/analytics/collect-metrics.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ the snapshot of all historical metrics.
## Summarize metrics

You can [transform](/guides/transformation/filter-and-select-data) metrics like
ordinary data, e.g., write aggregations over metrics to compute runtime
ordinary data, for example, write aggregations over metrics to compute runtime
statistics suitable for reporting or dashboarding:

```tql
Expand All @@ -41,8 +41,8 @@ summarize runtime=sum(duration), pipeline_id
sort -runtime
```

The above example computes the total runtime over all pipelines grouped by their
unique ID.
The previous example computes the total runtime over all pipelines grouped by
their unique ID.

## Inspect pipeline throughput

Expand All @@ -57,3 +57,16 @@ sort -egress_events

The `events` fields count records that passed through the pipeline during the
metric period. The `bytes` fields approximate the amount of data transferred.

## Send metrics to Prometheus

Use `shape="prometheus"` with <Op>metrics</Op> and <Op>to_prometheus</Op> to
send live metrics to a Prometheus-compatible Remote Write receiver:

```tql
metrics live=true, shape="prometheus"
to_prometheus "https://prometheus.example/api/v1/write"
```

The <Integration>prometheus</Integration> integration page covers endpoint
setup, authentication headers, and additional examples.
5 changes: 3 additions & 2 deletions src/content/docs/integrations/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ communication over numerous protocols and APIs:
- **Message queues**: <Integration>kafka</Integration>,
<Integration>nats</Integration>, <Integration>amazon/sqs</Integration>,
<Integration>amqp</Integration>
- **Databases**: <Integration>snowflake</Integration>,
<Integration>clickhouse</Integration>, <Integration>mysql</Integration>
- **Databases and analytics**: <Integration>snowflake</Integration>,
<Integration>clickhouse</Integration>, <Integration>mysql</Integration>,
<Integration>prometheus</Integration>
- **Network protocols**: <Integration>tcp</Integration>,
<Integration>udp</Integration>, <Integration>http</Integration>,
<Integration>syslog</Integration>
Expand Down
67 changes: 67 additions & 0 deletions src/content/docs/integrations/prometheus.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
title: Prometheus
---

[Prometheus](https://prometheus.io/) is an open-source monitoring system and
time-series database. Tenzir can send metric events to Prometheus-compatible
Remote Write receivers, including Prometheus, Grafana Mimir, Cortex, Thanos
Receive, and VictoriaMetrics.

Use <Op>metrics</Op> with `shape="prometheus"` and <Op>to_prometheus</Op> to
send Tenzir node metrics to a Prometheus Remote Write endpoint. This integration
doesn't expose a scrape endpoint for the Prometheus pull model.

## Prerequisites

Before you send metrics, configure your receiver to accept Remote Write traffic.
For Prometheus, start the server with the Remote Write receiver enabled and use
the `/api/v1/write` endpoint.

Store endpoint URLs and authentication headers as
[secrets](/explanations/secrets) when they contain credentials.

## Examples

### Send canonical metric events

Send events that already use the default metric shape expected by
<Op>to_prometheus</Op>:

```tql
from {
metric: "http_requests_total",
value: 42,
timestamp: 2026-05-15T10:00:00Z,
labels: {
method: "GET",
status: 200,
},
}
to_prometheus "https://prometheus.example/api/v1/write"
```

### Export Tenzir node metrics

Convert live Tenzir node metrics to Prometheus samples:

```tql
metrics live=true, shape="prometheus"
to_prometheus "https://prometheus.example/api/v1/write"
```

### Add authentication headers

Pass additional HTTP headers when your receiver requires authentication. Header
values are resolved as secrets.

```tql
metrics live=true, shape="prometheus"
to_prometheus "prometheus-remote-write-url",
headers={Authorization: "prometheus-remote-write-token"}
```

## See Also

- <Op>metrics</Op>
- <Op>to_prometheus</Op>
- <Guide>analytics/collect-metrics</Guide>
12 changes: 12 additions & 0 deletions src/content/docs/reference/operators.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,10 @@ operators:
description: 'Sends events to an OpenSearch-compatible Bulk API.'
example: 'to_opensearch "localhost:9200", …'
path: 'reference/operators/to_opensearch'
- name: 'to_prometheus'
description: 'Sends metric events to a Prometheus Remote Write receiver.'
example: 'to_prometheus "https://prometheus.example/api/v1/write"'
path: 'reference/operators/to_prometheus'
- name: 'to_s3'
description: 'Writes events to one or multiple objects in Amazon S3.'
example: 'to_s3 "s3://my-bucket/data/{uuid}.json" { write_ndjson }'
Expand Down Expand Up @@ -2050,6 +2054,14 @@ to_opensearch "localhost:9200", …

</ReferenceCard>

<ReferenceCard title="to_prometheus" description="Sends metric events to a Prometheus Remote Write receiver." href="/reference/operators/to_prometheus">

```tql
to_prometheus "https://prometheus.example/api/v1/write"
```

</ReferenceCard>

<ReferenceCard title="to_s3" description="Writes events to one or multiple objects in Amazon S3." href="/reference/operators/to_s3">

```tql
Expand Down
13 changes: 12 additions & 1 deletion src/content/docs/reference/operators/metrics.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ Controls the output shape. The default is `"raw"`, which preserves the native
`tenzir.metrics.*` schemas listed below.

Set `shape="prometheus"` to transform metrics into canonical records that are
compatible with Prometheus-oriented pipelines:
compatible with Prometheus-oriented pipelines. You can send this shape directly
to <Op>to_prometheus</Op>.

```tql
{
Expand Down Expand Up @@ -725,6 +726,13 @@ select timestamp, used_bytes
{timestamp: 2023-12-21T12:55:32.916200, used_bytes: 461842751488}
```

### Send metrics to Prometheus

```tql
metrics live=true, shape="prometheus"
to_prometheus "https://prometheus.example/api/v1/write"
```

### Get the memory usage over time

```tql
Expand Down Expand Up @@ -782,4 +790,7 @@ select timestamp, port, handle, reads, bytes
## See Also

- <Op>diagnostics</Op>
- <Op>to_prometheus</Op>
- <Guide>analytics/collect-metrics</Guide>
- <Tutorial>plot-data-with-charts</Tutorial>
- <Integration>prometheus</Integration>
Loading
Loading