Skip to content

Commit

Permalink
Update Collector configuration telemetry section (#3483)
Browse files Browse the repository at this point in the history
  • Loading branch information
brightzheng100 authored Dec 7, 2023
1 parent 839cb22 commit 4750f0f
Showing 1 changed file with 87 additions and 26 deletions.
113 changes: 87 additions & 26 deletions content/en/docs/collector/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -496,10 +496,10 @@ extensions:

## Service section {#service}

The service section is used to configure what components are enabled in the
The `service` section is used to configure what components are enabled in the
Collector based on the configuration found in the receivers, processors,
exporters, and extensions sections. If a component is configured, but not
defined within the service section, then it's not enabled.
defined within the `service` section, then it's not enabled.

The service section consists of three subsections:

Expand All @@ -509,8 +509,8 @@ The service section consists of three subsections:

### Extensions {#service-extensions}

The `extensions` subsection consists of a list of all extensions to enable. For
example:
The `extensions` subsection consists of a list of desired extensions to be
enabled. For example:

```yaml
service:
Expand All @@ -519,8 +519,8 @@ service:

### Pipelines

Pipelines are defined in the `pipelines` subsection and can be of the following
types:
The `pipelines` subsection is where the pipelines are configured, which can be
of the following types:

- `traces` collect and processes trace data.
- `metrics` collect and processes metric data.
Expand Down Expand Up @@ -552,38 +552,99 @@ service:

### Telemetry

You can configure telemetry for the Collector itself in the `telemetry`
subsection inside the `service` section. Collector telemetry can be useful when
troubleshooting Collector issues.

The `logs` subsection lets you configure logs generated by the Collector. By
default, the Collector writes its logs to stderr with a log level of `INFO`. You
can also add static key-value pairs to all logs using the `initial_fields`
section. See the full list of `logs` options
[here.](https://github.com/open-telemetry/opentelemetry-collector/blob/7666eb04c30e5cfd750db9969fe507562598f0ae/config/service.go#L41-L97)

The `metrics` subsection lets you configure metrics generated by the Collector.
By default, the Collector generates basic metrics about itself and expose them
for scraping at <http://localhost:8888/metrics>. For the full list of options
for the `metrics` subsection, see the
[`ServiceTelemetryMetrics struct`](https://github.com/open-telemetry/opentelemetry-collector/blob/7666eb04c30e5cfd750db9969fe507562598f0ae/config/service.go#L99-L111)
comments.

The following example shows Collector telemetry configuration:
The `telemetry` is where the telemetry for the Collector itself can be
configured. Collector's own telemetry can be useful when troubleshooting
Collector issues. It consists of two subsections: `logs` and `metrics`.

The `logs` subsection lets you configure how the logs can be generated by the
Collector. By default, the Collector writes its logs to `stderr` with a log
level of `INFO`. You can also add static key-value pairs to all log entries with
the `initial_fields` to enrich the logging context. As per the `LogsConfig`
defined in v{{%
param vers %}} [here](https://github.com/open-telemetry/opentelemetry-collector/blob/v{{%
param vers %}}/service/telemetry/config.go), the `logs` configuration options are:

- `level`: sets the minimum enabled logging level, default `INFO`.
- `development`: puts the logger in development mode, default `false`.
- `encoding`: sets the logger's encoding, default `console`. Example values are
`json`, `console`.
- `disable_caller`: stops annotating logs with the calling function's file name
and line number. By default `false`, all logs are annotated.
- `disable_stacktrace`: disables automatic stacktrace capturing, default
`false`. By default, stacktraces are captured for `WARN` level and above logs
in development and `ERROR` level and above in production.
- `sampling`: sets a sampling policy.
- `output_paths`: a list of URLs or file paths to write logging output to,
default `["stderr"]`.
- `error_output_paths`: a list of URLs or file paths to write logger errors to,
default `["stderr"]`.
- `initial_fields`: a collection of fields to add to the root logger. By
default, there is no initial field.

The `metrics` subsection lets you configure how the metrics can be generated and
exposed by the Collector. By default, the Collector generates basic metrics
about itself and expose them for scraping at <http://127.0.0.1:8888/metrics>.
You can expose the endpoint to a specific or even all network interfaces when
needed. As per the `MetricsConfig` defined in v{{%
param vers %}} [here](https://github.com/open-telemetry/opentelemetry-collector/blob/v{{%
param vers %}}/service/telemetry/config.go), the `metrics` configuration options
are:

- `level`: the level of telemetry metrics, default `basic`. The possible values
are:
- "none" indicates that no telemetry data should be collected.
- "basic" is the recommended and covers the basics of the service telemetry.
- "normal" adds some other indicators on top of basic.
- "detailed" adds dimensions and views to the previous levels.
- `address`: the `[address]:port` formatted URL that metrics exposition should
be bound to. Default `127.0.0.1:8888`.

The following example shows the Collector telemetry configuration:

```yaml
service:
telemetry:
logs:
level: debug
level: DEBUG
initial_fields:
service: my-instance
metrics:
level: detailed
address: 0.0.0.0:8888
```

## Additional information
Note that it's possible to scrape the metrics by using a
[Prometheus receiver](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/prometheusreceiver)
within the Collector configuration so that we can consume the Collector's
metrics at the backend. For example:

```yaml
receivers:
prometheus:
trim_metric_suffixes: true
use_start_time_metric: true
start_time_metric_regex: .*
config:
scrape_configs:
- job_name: 'otel-collector'
scrape_interval: 5s
static_configs:
- targets: ['127.0.0.1:8888']
exporters:
otlp:
endpoint: my.company.com:4317
tls:
insecure: true
service:
pipelines:
metrics:
receivers: [prometheus]
exporters: [otlp]
```

## Other Information

### Environment variables

Expand Down

0 comments on commit 4750f0f

Please sign in to comment.