Skip to content
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

New otelcol.exporter.debug component #1043

Merged
merged 5 commits into from
Jul 31, 2024
Merged
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ Main (unreleased)

- Added community components support, enabling community members to implement and maintain components. (@wildum)

- A new `otelcol.exporter.debug` component for printing OTel telemetry from
other `otelcol` components to the console. (@BarunKGP)

### Enhancements

- Added a success rate panel on the Prometheus Components dashboard. (@thampiotr)
Expand Down
1 change: 1 addition & 0 deletions docs/sources/reference/compatibility/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ The following components, grouped by namespace, _export_ OpenTelemetry `otelcol.
- [otelcol.connector.spanlogs](../components/otelcol/otelcol.connector.spanlogs)
- [otelcol.connector.spanmetrics](../components/otelcol/otelcol.connector.spanmetrics)
- [otelcol.exporter.awss3](../components/otelcol/otelcol.exporter.awss3)
- [otelcol.exporter.debug](../components/otelcol/otelcol.exporter.debug)
- [otelcol.exporter.kafka](../components/otelcol/otelcol.exporter.kafka)
- [otelcol.exporter.loadbalancing](../components/otelcol/otelcol.exporter.loadbalancing)
- [otelcol.exporter.logging](../components/otelcol/otelcol.exporter.logging)
Expand Down
165 changes: 165 additions & 0 deletions docs/sources/reference/components/otelcol/otelcol.exporter.debug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
---
canonical: https://grafana.com/docs/alloy/latest/reference/components/otelcol.exporter.debug/
description: Learn about otelcol.exporter.debug
title: otelcol.exporter.debug
---

<span class="badge docs-labels__stage docs-labels__item">Experimental</span>

# otelcol.exporter.debug

`otelcol.exporter.debug` accepts telemetry data from other `otelcol` components and writes them to the console (stderr).
You can control the verbosity of the logs.

{{< admonition type="note" >}}
`otelcol.exporter.debug` is a wrapper over the upstream OpenTelemetry Collector `debug` exporter.
If necessary, bug reports or feature requests are redirected to the upstream repository.
{{< /admonition >}}

You can specify multiple `otelcol.exporter.debug` components by giving them different labels.

## Usage

```river
otelcol.exporter.debug "LABEL" { }
```

## Arguments

`otelcol.exporter.debug` supports the following arguments:

Name | Type | Description | Default | Required
---- | ---- | ----------- | ------- | --------
`verbosity` | `string` | Verbosity of the generated logs. | `"basic"` | no
`sampling_initial` | `int` | Number of messages initially logged each second. | `2` | no
`sampling_thereafter` | `int` | Sampling rate after the initial messages are logged. | `1` | no
`use_internal_logger` | `bool` | Whether to use the internal logger or print directly to `stdout`. | `true` | no

The `verbosity` argument must be one of:
* `"basic"`: A single-line summary of received data is logged to stderr, with a total count of telemetry records for every batch of received logs, metrics, or traces.
* `"normal"`: Produces the same output as `"basic"` verbosity.
* `"detailed"`: All details of every telemetry record are logged to stderr, typically writing multiple lines for every telemetry record.

The following example shows `"basic"` and `"normal"` output:
```
ts=2024-06-13T11:24:13.782957Z level=info msg=TracesExporter component_path=/ component_id=otelcol.exporter.debug.default "resource spans": 1, spans: 2
```

The following example shows `"detailed"` output:
```
ts=2024-06-13T11:24:13.782957Z level=info msg=TracesExporter component_path=/ component_id=otelcol.exporter.debug.default "resource spans"=1 spans=2
ts=2024-06-13T11:24:13.783101Z level=info msg="ResourceSpans #0
Resource SchemaURL: https://opentelemetry.io/schemas/1.4.0
Resource attributes:
-> service.name: Str(telemetrygen)
ScopeSpans #0
ScopeSpans SchemaURL:
InstrumentationScope telemetrygen
Span #0
Trace ID : 3bde5d3ee82303571bba6e1136781fe4
Parent ID : 5e9dcf9bac4acc1f
ID : 2cf3ef2899aba35c
Name : okey-dokey
Kind : Server
Start time : 2023-11-11 04:49:03.509369393 +0000 UTC
End time : 2023-11-11 04:49:03.50949377 +0000 UTC
Status code : Unset
Status message :
Attributes:
-> net.peer.ip: Str(1.2.3.4)
-> peer.service: Str(telemetrygen-client)
Span #1
Trace ID : 3bde5d3ee82303571bba6e1136781fe4
Parent ID :
ID : 5e9dcf9bac4acc1f
Name : lets-go
Kind : Client
Start time : 2023-11-11 04:49:03.50935117 +0000 UTC
End time : 2023-11-11 04:49:03.50949377 +0000 UTC
Status code : Unset
Status message :
Attributes:
-> net.peer.ip: Str(1.2.3.4)
-> peer.service: Str(telemetrygen-server)
{"kind": "exporter", "data_type": "traces", "name": "debug"}"
```

{{< admonition type="note" >}}
All instances of `\n` in the `"detailed"` example have been replaced with new lines.
{{< /admonition >}}

Setting `use_internal_logger` to `false` is useful if you would like to see actual new lines instead of `\n` in the collector logs.
However, by not using the internal logger you wouldn't see metadata in the log line such as `component_id=otelcol.exporter.debug.default`.
Multiline logs may also be harder to parse.

## Blocks

The following blocks are supported inside the definition of
`otelcol.exporter.debug`:

Hierarchy | Block | Description | Required
--------------|-------------------|----------------------------------------------------------------------------|---------
debug_metrics | [debug_metrics][] | Configures the metrics that this component generates to monitor its state. | no

The `>` symbol indicates deeper levels of nesting. For example, `client > tls`
refers to a `tls` block defined inside a `client` block.

[debug_metrics]: #debug_metrics-block

### debug_metrics block

{{< docs/shared lookup="reference/components/otelcol-debug-metrics-block.md" source="alloy" version="<ALLOY_VERSION>" >}}

## Exported fields

The following fields are exported and can be referenced by other components:

Name | Type | Description
---- | ---- | -----------
`input` | `otelcol.Consumer` | A value that other components can use to send telemetry data to.

`input` accepts `otelcol.Consumer` data for any telemetry signal (metrics,
logs, or traces).

## Component health

`otelcol.exporter.debug` is only reported as unhealthy if given an invalid
configuration.

## Debug information

`otelcol.exporter.debug` does not expose any component-specific debug
information.

## Example

This example receives OTLP metrics, logs, and traces and writes them to the console:

```alloy
otelcol.receiver.otlp "default" {
grpc {}
http {}

output {
metrics = [otelcol.exporter.debug.default.input]
logs = [otelcol.exporter.debug.default.input]
traces = [otelcol.exporter.debug.default.input]
}
}

otelcol.exporter.debug "default" {}
```
ptodev marked this conversation as resolved.
Show resolved Hide resolved
<!-- START GENERATED COMPATIBLE COMPONENTS -->

## Compatible components

`otelcol.exporter.debug` has exports that can be consumed by the following components:

- Components that consume [OpenTelemetry `otelcol.Consumer`](../../../compatibility/#opentelemetry-otelcolconsumer-consumers)

{{< admonition type="note" >}}
Connecting some components may not be sensible or components may require further configuration to make the connection work correctly.
Refer to the linked documentation for more details.
{{< /admonition >}}

<!-- END GENERATED COMPATIBLE COMPONENTS -->
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ title: otelcol.exporter.logging

# otelcol.exporter.logging

{{< admonition type="warning" >}}
The OpenTelemetry Collector `logging` exporter is deprecated.
It will be removed from the upstream Collector repository in September 2024.
`otelcol.exporter.logging` may also be removed in a future Alloy version.
Use `otelcol.exporter.debug` instead.
{{< /admonition >}}

`otelcol.exporter.logging` accepts telemetry data from other `otelcol` components
and writes them to the console.

Expand Down Expand Up @@ -83,27 +90,21 @@ information.

## Example

This example scrapes prometheus unix metrics and writes them to the console:
This example receives OTLP metrics, logs, and traces and writes them to the console:

```alloy
prometheus.exporter.unix "default" { }
otelcol.receiver.otlp "default" {
grpc {}
http {}

prometheus.scrape "default" {
targets = prometheus.exporter.unix.default.targets
forward_to = [otelcol.receiver.prometheus.default.receiver]
}

otelcol.receiver.prometheus "default" {
output {
metrics = [otelcol.exporter.logging.default.input]
logs = [otelcol.exporter.logging.default.input]
traces = [otelcol.exporter.logging.default.input]
}
}

otelcol.exporter.logging "default" {
verbosity = "detailed"
sampling_initial = 1
sampling_thereafter = 1
}
otelcol.exporter.logging "default" {}
```
<!-- START GENERATED COMPATIBLE COMPONENTS -->

Expand Down
7 changes: 4 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -198,17 +198,18 @@ require (
go.opentelemetry.io/collector/connector v0.105.0
go.opentelemetry.io/collector/consumer v0.105.0
go.opentelemetry.io/collector/exporter v0.105.0
go.opentelemetry.io/collector/exporter/debugexporter v0.105.0
go.opentelemetry.io/collector/exporter/loggingexporter v0.102.1
go.opentelemetry.io/collector/exporter/otlpexporter v0.105.0
go.opentelemetry.io/collector/exporter/otlphttpexporter v0.104.0
go.opentelemetry.io/collector/exporter/otlphttpexporter v0.105.0
go.opentelemetry.io/collector/extension v0.105.0
go.opentelemetry.io/collector/extension/auth v0.105.0
go.opentelemetry.io/collector/featuregate v1.12.0
go.opentelemetry.io/collector/otelcol v0.105.0
go.opentelemetry.io/collector/pdata v1.12.0
go.opentelemetry.io/collector/processor v0.105.0
go.opentelemetry.io/collector/processor/batchprocessor v0.104.0
go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.104.0
go.opentelemetry.io/collector/processor/batchprocessor v0.105.0
go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.105.0
go.opentelemetry.io/collector/receiver v0.105.0
go.opentelemetry.io/collector/receiver/otlpreceiver v0.105.0
go.opentelemetry.io/collector/semconv v0.105.0
Expand Down
14 changes: 8 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2333,12 +2333,14 @@ go.opentelemetry.io/collector/consumer v0.105.0 h1:pO5Tspoz7yvEs81+904HfDjByP8Z7
go.opentelemetry.io/collector/consumer v0.105.0/go.mod h1:tnaPDHUfKBJ01OnsJNRecniG9iciE+xHYLqamYwFQOQ=
go.opentelemetry.io/collector/exporter v0.105.0 h1:O2xmjfaRbkbpo3XkwEcnuBHCoXc5kS9CjYO8geu+3vo=
go.opentelemetry.io/collector/exporter v0.105.0/go.mod h1:5ulGEHRZyGbX4DWHJa2Br6Fr/W1Lay8ayf++1WrVvgk=
go.opentelemetry.io/collector/exporter/debugexporter v0.105.0 h1:Osqo7+pr1vZbt+12KMzZrst6uMv1r8UJZjTgI6vwqL4=
go.opentelemetry.io/collector/exporter/debugexporter v0.105.0/go.mod h1:rqjWoduh/qj6OlttzdbB8Ji6Vp4SoHJRnZHNuS/Mkp0=
go.opentelemetry.io/collector/exporter/loggingexporter v0.102.1 h1:LblufdV22DxB5NZa66CGCQZjadYTVxT+O5NR9YjNQ9Y=
go.opentelemetry.io/collector/exporter/loggingexporter v0.102.1/go.mod h1:zmOEwiQlfvEHnakWNO1YFNubgWZvZee+5Wshuck5lZk=
go.opentelemetry.io/collector/exporter/otlpexporter v0.105.0 h1:JWAlh7A1oNm4LqUrrtPjAmUdvcE11VZCeJhMk0lShYg=
go.opentelemetry.io/collector/exporter/otlpexporter v0.105.0/go.mod h1:aA2E+t2giwUoJ2RmDw+2dVox64J2zHpTT2m/mi7zOIM=
go.opentelemetry.io/collector/exporter/otlphttpexporter v0.104.0 h1:JkNCOj7DdyJhcYIaRqtS/X+YtAPRjE4pcruyY6LoM7c=
go.opentelemetry.io/collector/exporter/otlphttpexporter v0.104.0/go.mod h1:6rs4Xugs7tIC3IFbAC+fj56zLiVc7osXC5UTjk/Mkw4=
go.opentelemetry.io/collector/exporter/otlphttpexporter v0.105.0 h1:ciJvNlC9ztoeyIi23TCpZ6PN7l75tl/yvKqBo0Cmajw=
go.opentelemetry.io/collector/exporter/otlphttpexporter v0.105.0/go.mod h1:e+PdCkQkP+1cj0+cijRfmE4/VjofxeeWoS1cvvu39HI=
go.opentelemetry.io/collector/extension v0.105.0 h1:R8i4HMvuSm20Nt3onyrLk19KKhjCNAsgS8FGh60rcZU=
go.opentelemetry.io/collector/extension v0.105.0/go.mod h1:oyX960URG27esNKitf3o2rqcBj0ajcx+dxkCxwRz34U=
go.opentelemetry.io/collector/extension/auth v0.105.0 h1:5gzRSHU0obVtZDzLLJQ/p4sIkacUsyEEpBiBRDs82Hk=
Expand All @@ -2359,10 +2361,10 @@ go.opentelemetry.io/collector/pdata/testdata v0.105.0 h1:5sPZzanR4nJR3sNQk3MTdAr
go.opentelemetry.io/collector/pdata/testdata v0.105.0/go.mod h1:NIfgaclQp/M1BZhgyc/7hDWD+/DumC/OMBQVI2KW+N0=
go.opentelemetry.io/collector/processor v0.105.0 h1:LE6wEMWNa3h7eOJLMBm2lA0v6sc2j6Geqv1e3pIWS8Y=
go.opentelemetry.io/collector/processor v0.105.0/go.mod h1:QAvMEtd3k+YhRrnaEgs/8e0UueYonuT8Hg4udQOht60=
go.opentelemetry.io/collector/processor/batchprocessor v0.104.0 h1:6xXvHYkPjwM1zdzliDM2H/omTGgIOkY96JTCln7CFZQ=
go.opentelemetry.io/collector/processor/batchprocessor v0.104.0/go.mod h1:f1VfVdiOlqtJDAvQy8YONEee19nJ3haxNeiMPy59w8M=
go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.104.0 h1:bfxUNxP2i41Dpdp5cXwVuh4ZIQ8g6e4NDnu5HakWQw4=
go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.104.0/go.mod h1:2HtP0f+EBu99Uq07JF20fa2FKAsjnIieOZ4f9Jysfpc=
go.opentelemetry.io/collector/processor/batchprocessor v0.105.0 h1:j9f7EWmaR6kaQubKE0L3lvZxoIEppRyTAvqLDmp2Jig=
go.opentelemetry.io/collector/processor/batchprocessor v0.105.0/go.mod h1:klVt/0Egd7LSgWyxlSpgNvLMQRaqfUJg7Nv4qdpQOHA=
go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.105.0 h1:qPjFg7uWmsVvf0Kk11WzM6Zy//zNZFC5uFwYKFXlEn8=
go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.105.0/go.mod h1:0pgvBY04E2bRq5dY3Qfj66mKpkFnu252FNm7iiFEiAU=
go.opentelemetry.io/collector/receiver v0.105.0 h1:eZF97kMUnKJ20Uc4PaDlgLIGmaA8kyLqhH+vMXjh92U=
go.opentelemetry.io/collector/receiver v0.105.0/go.mod h1:nGKDXLUGVHxMBJ5QLfsJ/bIhGvoMGqsN0pZtD5SC8sE=
go.opentelemetry.io/collector/receiver/otlpreceiver v0.105.0 h1:1qjnvrnDcEaj93WgyrWRWTTAGNODaxi98wNcXiHDwfM=
Expand Down
1 change: 1 addition & 0 deletions internal/component/all/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ import (
_ "github.com/grafana/alloy/internal/component/otelcol/connector/spanlogs" // Import otelcol.connector.spanlogs
_ "github.com/grafana/alloy/internal/component/otelcol/connector/spanmetrics" // Import otelcol.connector.spanmetrics
_ "github.com/grafana/alloy/internal/component/otelcol/exporter/awss3" // Import otelcol.exporter.awss3exporter
_ "github.com/grafana/alloy/internal/component/otelcol/exporter/debug" // Import otelcol.exporter.debug
_ "github.com/grafana/alloy/internal/component/otelcol/exporter/kafka" // Import otelcol.exporter.kafka
_ "github.com/grafana/alloy/internal/component/otelcol/exporter/loadbalancing" // Import otelcol.exporter.loadbalancing
_ "github.com/grafana/alloy/internal/component/otelcol/exporter/logging" // Import otelcol.exporter.logging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func (Arguments) ConnectorType() int {
return connector.ConnectorTracesToMetrics
}

// DebugMetricsConfig implements receiver.Arguments.
// DebugMetricsConfig implements connector.Arguments.
func (args Arguments) DebugMetricsConfig() otelcolCfg.DebugMetricsArguments {
return args.DebugMetrics
}
Loading
Loading