|
| 1 | +--- |
| 2 | +canonical: https://grafana.com/docs/alloy/latest/reference/components/prometheus/prometheus.echo/ |
| 3 | +description: Learn about prometheus.echo |
| 4 | +labels: |
| 5 | + stage: general-availability |
| 6 | + products: |
| 7 | + - oss |
| 8 | +title: prometheus.echo |
| 9 | +--- |
| 10 | + |
| 11 | +# `prometheus.echo` |
| 12 | + |
| 13 | +The `prometheus.echo` component receives Prometheus metrics and writes them to stdout in Prometheus exposition format. |
| 14 | +This component is useful for debugging and testing the flow of metrics through a pipeline, allowing you to see exactly what metrics are being received at a particular point in your configuration. |
| 15 | + |
| 16 | +## Usage |
| 17 | + |
| 18 | +```alloy |
| 19 | +prometheus.echo "<LABEL>" { |
| 20 | +} |
| 21 | +``` |
| 22 | + |
| 23 | +## Arguments |
| 24 | + |
| 25 | +You can use the following arguments with `prometheus.echo`: |
| 26 | + |
| 27 | +| Name | Type | Description | Default | Required | |
| 28 | +| -------- | -------- | --------------------------------------------------------------- | ------- | -------- | |
| 29 | +| `format` | `string` | The output format for metrics. Must be `text` or `openmetrics`. | `text` | no | |
| 30 | + |
| 31 | +The `format` argument controls how metrics are encoded when written to stdout: |
| 32 | + |
| 33 | +* `text` - Uses the Prometheus text exposition format (default). |
| 34 | +* `openmetrics` - Uses the OpenMetrics text format. |
| 35 | + |
| 36 | +## Blocks |
| 37 | + |
| 38 | +The `prometheus.echo` component doesn't support any blocks. You can configure this component with arguments. |
| 39 | + |
| 40 | +## Exported fields |
| 41 | + |
| 42 | +The following fields are exported and can be referenced by other components: |
| 43 | + |
| 44 | +| Name | Type | Description | |
| 45 | +| ---------- | ----------------- | --------------------------------------------------------- | |
| 46 | +| `receiver` | `MetricsReceiver` | A value that other components can use to send metrics to. | |
| 47 | + |
| 48 | +## Component health |
| 49 | + |
| 50 | +`prometheus.echo` is only reported as unhealthy if given an invalid configuration. |
| 51 | +In those cases, exported fields retain their last healthy values. |
| 52 | + |
| 53 | +## Debug information |
| 54 | + |
| 55 | +`prometheus.echo` doesn't expose any component-specific debug information. |
| 56 | + |
| 57 | +## Debug metrics |
| 58 | + |
| 59 | +`prometheus.echo` doesn't expose any component-specific debug metrics. |
| 60 | + |
| 61 | +## Example |
| 62 | + |
| 63 | +This example creates a metrics generation and inspection pipeline: |
| 64 | + |
| 65 | +```alloy |
| 66 | +prometheus.exporter.unix "default" { |
| 67 | +} |
| 68 | +
|
| 69 | +prometheus.scrape "demo" { |
| 70 | + targets = prometheus.exporter.unix.default.targets |
| 71 | + forward_to = [prometheus.echo.debug.receiver] |
| 72 | +} |
| 73 | +
|
| 74 | +prometheus.echo "debug" { |
| 75 | + format = "text" |
| 76 | +} |
| 77 | +``` |
| 78 | + |
| 79 | +In this example: |
| 80 | + |
| 81 | +1. The `prometheus.exporter.unix` component exposes system metrics. |
| 82 | +1. The `prometheus.scrape` component scrapes those metrics. |
| 83 | +1. The `prometheus.echo` component receives the scraped metrics and writes them to stdout in Prometheus text format. |
| 84 | + |
| 85 | +When you run this configuration, you'll see the metrics being written to stdout, which is useful to: |
| 86 | + |
| 87 | +* Debug metric collection issues |
| 88 | +* Verify metric labels and values |
| 89 | +* Test metric transformations |
| 90 | +* Understand the structure of metrics in your pipeline |
| 91 | + |
| 92 | +### Example with OpenMetrics format |
| 93 | + |
| 94 | +```alloy |
| 95 | +prometheus.scrape "demo" { |
| 96 | + targets = [ |
| 97 | + {"__address__" = "localhost:9090"}, |
| 98 | + ] |
| 99 | + forward_to = [prometheus.echo.debug.receiver] |
| 100 | +} |
| 101 | +
|
| 102 | +prometheus.echo "debug" { |
| 103 | + format = "openmetrics" |
| 104 | +} |
| 105 | +``` |
| 106 | + |
| 107 | +This example outputs metrics using the OpenMetrics format instead of the traditional Prometheus text format. |
| 108 | + |
| 109 | +<!-- START GENERATED COMPATIBLE COMPONENTS --> |
| 110 | + |
| 111 | +## Compatible components |
| 112 | + |
| 113 | +`prometheus.echo` has exports that can be consumed by the following components: |
| 114 | + |
| 115 | +- Components that consume [Prometheus `MetricsReceiver`](../../../compatibility/#prometheus-metricsreceiver-consumers) |
| 116 | + |
| 117 | +{{< admonition type="note" >}} |
| 118 | +Connecting some components may not be sensible or components may require further configuration to make the connection work correctly. |
| 119 | +Refer to the linked documentation for more details. |
| 120 | +{{< /admonition >}} |
| 121 | + |
| 122 | +<!-- END GENERATED COMPATIBLE COMPONENTS --> |
0 commit comments