Skip to content

Commit abfccdb

Browse files
committed
In configure-logs.md, added sections for Output to OTLP-compatible network collectors and Set OTLP.
In logging-use-cases.md, modified example for Network logging with log buffering to use OTLP instead of Fluentd.
1 parent e68493c commit abfccdb

File tree

2 files changed

+81
-13
lines changed

2 files changed

+81
-13
lines changed

src/current/v25.4/configure-logs.md

Lines changed: 74 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,12 @@ For clarity, this article uses the block format to describe the YAML payload, wh
5959
file-defaults: ... # defaults inherited by file sinks
6060
fluent-defaults: ... # defaults inherited by Fluentd sinks
6161
http-defaults: ... # defaults inherited by HTTP sinks
62+
otlp-defaults: ... # defaults inherited by OTLP sinks
6263
sinks:
6364
file-groups: ... # file sink definitions
6465
fluent-servers: ... # Fluentd sink definitions
6566
http-servers: ... # HTTP sink definitions
67+
otlp-servers: ... # OTLP sink definitions
6668
stderr: ... # stderr sink definitions
6769
capture-stray-errors: ... # parameters for the stray error capture system
6870
~~~
@@ -75,14 +77,21 @@ You can view the default settings by running `cockroach debug check-log-config`,
7577

7678
## Configure log sinks
7779

78-
Log *sinks* route events from specified [logging channels]({% link {{ page.version.version }}/logging-overview.md %}#logging-channels) to destinations outside CockroachDB. These destinations currently include [log files](#output-to-files), [Fluentd](https://www.fluentd.org/)-compatible [servers](#output-to-fluentd-compatible-network-collectors), [HTTP servers](#output-to-http-network-collectors), and the [standard error stream (`stderr`)](#output-to-stderr).
80+
Log *sinks* route events from specified [logging channels]({% link {{ page.version.version }}/logging-overview.md %}#logging-channels) to destinations outside CockroachDB. These destinations include:
81+
82+
- [log files](#output-to-files)
83+
- [Fluentd](https://www.fluentd.org/)-compatible [servers](#output-to-fluentd-compatible-network-collectors)
84+
- [HTTP servers](#output-to-http-network-collectors)
85+
- [OTLP](https://opentelemetry.io/)-compatible [servers](#output-to-otlp-compatible-network-collectors)
86+
- the [standard error stream (`stderr`)](#output-to-stderr)
7987

8088
All supported output destinations are configured under `sinks`:
8189

8290
~~~ yaml
8391
file-defaults: ...
8492
fluent-defaults: ...
8593
http-defaults: ...
94+
otlp-defaults: ...
8695
sinks:
8796
file-groups:
8897
{file group name}:
@@ -96,6 +105,10 @@ sinks:
96105
{server name}:
97106
channels: {channels}
98107
...
108+
otlp-servers:
109+
{server name}:
110+
channels: {channels}
111+
...
99112
stderr:
100113
channels: {channels}
101114
...
@@ -108,14 +121,14 @@ All supported sink types use the following common sink parameters:
108121
| Parameter | Description |
109122
|-----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
110123
| `filter` | Minimum severity level at which logs enter the channels selected for the sink. Accepts one of the valid [severity levels]({% link {{ page.version.version }}/logging.md %}#logging-levels-severities) or `NONE`, which excludes all messages from the sink output. For details, see [Set logging levels](#set-logging-levels). |
111-
| `format` | Log message format to use for file or network sinks. Accepts one of the valid [log formats]({% link {{ page.version.version }}/log-formats.md %}). For details, see [file logging format](#file-logging-format), [Fluentd logging format](#fluentd-logging-format), and [HTTP logging format](#http-logging-format). |
124+
| `format` | Log message format to use for file or network sinks. Accepts one of the valid [log formats]({% link {{ page.version.version }}/log-formats.md %}). For details, see [file logging format](#file-logging-format), [Fluentd logging format](#fluentd-logging-format), [HTTP logging format](#http-logging-format), and [OTLP logging format](#otlp-logging-format). |
112125
|`format-options` | Customization options for specified `format`. For available options for each format, see [Log formats]({% link {{ page.version.version }}/log-formats.md %}). For an example use case, see [Set timezone](#set-timezone). |
113126
| `redact` | When `true`, enables automatic redaction of personally identifiable information (PII) from log messages. This ensures that sensitive data is not transmitted when collecting logs centrally or over a network. For details, see [Redact logs](#redact-logs). |
114127
| `redactable` | When `true`, preserves redaction markers around fields that are considered sensitive in the log messages. The markers are recognized by [`cockroach debug zip`]({% link {{ page.version.version }}/cockroach-debug-zip.md %}) and [`cockroach debug merge-logs`]({% link {{ page.version.version }}/cockroach-debug-merge-logs.md %}) but may not be compatible with external log collectors. For details on how the markers appear in each format, see [Log formats]({% link {{ page.version.version }}/log-formats.md %}). |
115128
| `exit-on-error` | When `true`, stops the Cockroach node if an error is encountered while writing to the sink. We recommend enabling this option on file sinks in order to avoid losing any log entries. When set to `false`, this can be used to mark certain sinks (such as `stderr`) as non-critical. |
116129
| <a id="auditable"></a>`auditable` | If `true`, enables `exit-on-error` on the sink. Also disables `buffered-writes` if the sink is under `file-groups`. This guarantees [non-repudiability](https://wikipedia.org/wiki/Non-repudiation) for any logs in the sink, but can incur a performance overhead and higher disk IOPS consumption. This setting is typically enabled for [security-related logs]({% link {{ page.version.version }}/logging-use-cases.md %}#security-and-audit-monitoring).<br><br>File-based audit logging cannot coexist with the buffering configuration, so disable either [`buffering`](#file-buffering) or `auditable`. |
117130

118-
If not specified for a given sink, these parameter values are inherited from [`file-defaults`](#set-file-defaults) (for file sinks), [`fluent-defaults`](#set-fluentd-defaults) (for Fluentd sinks), and [`http-defaults`](#set-http-defaults) (for HTTP sinks).
131+
If not specified for a given sink, these parameter values are inherited from [`file-defaults`](#set-file-defaults) (for file sinks), [`fluent-defaults`](#set-fluentd-defaults) (for Fluentd sinks), [`http-defaults`](#set-http-defaults) (for HTTP sinks), and [`otlp-defaults`](#set-otlp-defaults) (for OTLP sinks).
119132

120133
### Output to files
121134

@@ -127,6 +140,7 @@ CockroachDB can write messages to one or more log files.
127140
file-defaults: ...
128141
fluent-defaults: ...
129142
http-defaults: ...
143+
otlp-defaults: ...
130144
sinks:
131145
file-groups:
132146
default:
@@ -197,6 +211,7 @@ CockroachDB can send logs over the network to a [Fluentd](https://www.fluentd.or
197211
file-defaults: ...
198212
fluent-defaults: ...
199213
http-defaults: ...
214+
otlp-defaults: ...
200215
sinks:
201216
fluent-servers:
202217
health:
@@ -228,6 +243,7 @@ For an example network logging configuration, see [Logging use cases]({% link {{
228243
file-defaults: ...
229244
fluent-defaults: ...
230245
http-defaults: ...
246+
otlp-defaults: ...
231247
sinks:
232248
http-servers:
233249
health:
@@ -261,6 +277,38 @@ Along with the [common sink parameters](#common-sink-parameters), each HTTP serv
261277
262278
For an example network logging configuration, see [Logging use cases]({% link {{ page.version.version }}/logging-use-cases.md %}#network-logging). For an example that uses `compression`, `headers`, `file-based-headers`, and `buffering` parameters, see [Configure an HTTP network collector for Datadog]({% link {{ page.version.version }}/log-sql-activity-to-datadog.md %}#step-2-configure-an-http-network-collector-for-datadog).
263279
280+
### Output to OTLP-compatible network collectors
281+
282+
CockroachDB can send logs to an [OpenTelemetry](https://opentelemetry.io/)-compatible server using the OTLP protocol. Define `otlp-servers` to select channels and configure connection and protocol details. For example:
283+
284+
~~~ yaml
285+
file-defaults: ...
286+
fluent-defaults: ...
287+
http-defaults: ...
288+
otlp-defaults: ...
289+
sinks:
290+
otlp-servers:
291+
health:
292+
channels: [HEALTH]
293+
address: 127.0.0.1:4317
294+
mode: grpc
295+
compression: gzip
296+
...
297+
~~~
298+
299+
Along with the [common sink parameters](#common-sink-parameters), each OTLP server accepts the following additional parameters:
300+
301+
| Parameter | Description |
302+
|-----------|-------------|
303+
| `channels` | List of channels that output to this sink. Use a YAML array or string of [channel names]({% link {{ page.version.version }}/logging-overview.md %}#logging-channels), `ALL`, or `ALL EXCEPT {channels}`. See [Logging channel selection](#logging-channel-selection) for syntax. |
304+
| `address` | Network address of the OTLP collector endpoint for log ingestion, formatted as `{host}:{port}`. |
305+
| `mode` | Protocol used to export logs. Valid values `grpc` or `http`.<br><br>**Default:**`grpc` |
306+
| `headers` | Map of key-value string pairs which will be appended to every request as custom gRPC or HTTP headers depending on the `mode` selected. For example, `"x-api-key": "YOUR_API_KEY_HERE"`. |
307+
| `compression` | Compression for requests. Valid values `gzip` or `none`.<br><br>**Default:**`gzip` |
308+
| `buffering` | Configures buffering of log messages for the sink, with the following sub-parameters:<ul><li>`max-staleness`: The maximum time a log message will wait in the buffer before a flush is triggered. Set to `0` to disable flushing based on elapsed time. Default: `5s`</li><li>`flush-trigger-size`: The number of bytes that will trigger the buffer to flush. Set to `0` to disable flushing based on accumulated size. Default: `1MiB`</li><li>`max-buffer-size`: The maximum size of the buffer: new log messages received when the buffer is full cause older messages to be dropped. Default: `50MiB`</li></ul>When `max-staleness` and `flush-trigger-size` are used together, whichever is reached first will trigger the flush. `buffering` is enabled by default for OTLP log sinks. To explicitly disable log buffering, specify `buffering: NONE` instead. This setting is typically disabled for [security-related logs]({% link {{ page.version.version }}/logging-use-cases.md %}#security-and-audit-monitoring). See [Log buffering](#log-buffering-for-network-sinks) for more details and usage.|
309+
310+
For an example network logging configuration, see [Logging use cases]({% link {{ page.version.version }}/logging-use-cases.md %}#network-logging).
311+
264312
### Output to `stderr`
265313
266314
CockroachDB can output messages to the [standard error stream (`stderr`)](https://wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)), which prints them to the machine's terminal but does not store them. `stderr` specifies the channels that output to the stream. For example:
@@ -269,6 +317,7 @@ CockroachDB can output messages to the [standard error stream (`stderr`)](https:
269317
file-defaults: ...
270318
fluent-defaults: ...
271319
http-defaults: ...
320+
otlp-defaults: ...
272321
sinks:
273322
stderr:
274323
channels: [DEV]
@@ -354,7 +403,7 @@ channels: 'all except [ops, health]'
354403

355404
## Configure logging defaults
356405

357-
When setting up a logging configuration, it's simplest to define shared parameters in `file-defaults` and `fluent-defaults` and override specific values as needed in [`file-groups`](#output-to-files), [`fluent-servers`](#output-to-fluentd-compatible-network-collectors), [`http-servers`](#output-to-http-network-collectors), and [`stderr`](#output-to-stderr). For a complete example, see the [default configuration](#default-logging-configuration).
406+
When setting up a logging configuration, it's simplest to define shared parameters in `file-defaults`, `fluent-defaults`, `http-defaults`, and `otlp-defaults` and override specific values as needed in [`file-groups`](#output-to-files), [`fluent-servers`](#output-to-fluentd-compatible-network-collectors), [`http-servers`](#output-to-http-network-collectors), [`otlp-servers`](#output-to-otlp-compatible-network-collectors) and [`stderr`](#output-to-stderr). For a complete example, see the [default configuration](#default-logging-configuration).
358407
359408
{{site.data.alerts.callout_success}}
360409
You can view your current settings by running `cockroach debug check-log-config`, which returns the YAML definitions and a URL to a visualization of the current logging configuration.
@@ -428,7 +477,7 @@ fluent-defaults:
428477

429478
Defaults for HTTP sinks are set in `http-defaults`, which accepts all [common sink parameters](#common-sink-parameters).
430479

431-
Note that the [server parameters](#output-to-http-network-collectors) `address` and `method` are *not* specified in `fluent-defaults`:
480+
Note that the [server parameters](#output-to-http-network-collectors) `address` and `method` are *not* specified in `http-defaults`:
432481

433482
- `address` must be specified for each sink under `http-servers`.
434483
- `method` is not required and defaults to `POST`.
@@ -446,6 +495,25 @@ http-defaults:
446495
`format` refers to the envelope of the log message. This is separate from the event payload, which is structured according to [event type]({% link {{ page.version.version }}/eventlog.md %}).
447496
{{site.data.alerts.end}}
448497

498+
### Set OTLP defaults
499+
500+
Defaults for OTLP sinks are set in `otlp-defaults`, which accepts all [common sink parameters](#common-sink-parameters).
501+
502+
Note that the [server parameter](#output-to-otlp-compatible-network-collectors) `address`is *not* specified in `otlp-defaults`. The `address` must be specified for each sink under `otlp-servers`.
503+
504+
#### OTLP logging format
505+
506+
The default message format for OTLP output is [`json`]({% link {{ page.version.version }}/log-formats.md %}#format-json). Each log message is structured as a JSON payload that can be read programmatically. For details, see [Log formats]({% link {{ page.version.version }}/log-formats.md %}).
507+
508+
~~~ yaml
509+
otlp-defaults:
510+
format: json
511+
~~~
512+
513+
{{site.data.alerts.callout_info}}
514+
`format` refers to the envelope of the log message. This is separate from the event payload, which is structured according to [event type]({% link {{ page.version.version }}/eventlog.md %}).
515+
{{site.data.alerts.end}}
516+
449517
### Set logging levels
450518

451519
Log messages are associated with a [severity level]({% link {{ page.version.version }}/logging.md %}#logging-levels-severities) when they are generated.
@@ -612,7 +680,7 @@ To ensure that you are protecting sensitive information, also [redact your logs]
612680
613681
## Log buffering for network sinks
614682
615-
Both [Fluentd-compatible](#output-to-fluentd-compatible-network-collectors) and [HTTP](#output-to-http-network-collectors) log sinks support the buffering of log messages by default. Previous to version v22.2, log buffering was only available for the [log file](#output-to-files) log sink.
683+
The network ([Fluentd-compatible](#output-to-fluentd-compatible-network-collectors), [HTTP](#output-to-http-network-collectors), and [OTLP-compatible](#output-to-otlp-compatible-network-collectors)) log sinks support the buffering of log messages by default. Previous to version v22.2, log buffering was only available for the [log file](#output-to-files) log sink.
616684
617685
With log buffering configured, log messages are held in a buffer for a configurable time period or accumulated message size threshold before being written to the target log sink together as a batch. Log buffering helps to ensure consistent low-latency log message writes over the network even in high-traffic, high-contention scenarios.
618686

0 commit comments

Comments
 (0)