-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[receiver/filelog] Add docs for offset tracking (#30914)
**Description:** <Describe what has changed.> <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> This PR adds documentation notes on how to achieve fault tolerance on `filelog`'s receiver offset tracking. The need for this is obvious but was also explained at #20552 (comment). **Link to tracking Issue:** <Issue number if applicable> **Testing:** <Describe what testing was performed and which tests were added.> **Documentation:** <Describe the documentation added.> --------- Signed-off-by: ChrsMark <chrismarkou92@gmail.com>
- Loading branch information
Showing
4 changed files
with
102 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
## Fault tolerant log collection example | ||
|
||
Filelog receiver's persistence can be covered by the usage of the following extensions: | ||
- [filestorage](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/extension/storage/filestorage) extension, | ||
to ensure that Collector's restarts do not affect the log collection and offset tracking. | ||
- [exporterhelper persistent-queue](https://github.com/open-telemetry/opentelemetry-collector/blob/main/exporter/exporterhelper/README.md#persistent-queue), | ||
to ensure that Collector's restarts do not affect the delivery of the already collected logs. | ||
|
||
A full configuration example is provided in [example config](./otel-col-config.yaml) |
24 changes: 24 additions & 0 deletions
24
examples/fault-tolerant-logs-collection/otel-col-config.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
receivers: | ||
filelog: | ||
include: [/var/log/busybox/simple.log] | ||
storage: file_storage/filelogreceiver | ||
|
||
extensions: | ||
file_storage/filelogreceiver: | ||
directory: /var/lib/otelcol/file_storage/receiver | ||
file_storage/otlpoutput: | ||
directory: /var/lib/otelcol/file_storage/output | ||
|
||
service: | ||
extensions: [file_storage/filelogreceiver, file_storage/otlpoutput] | ||
pipelines: | ||
logs: | ||
receivers: [filelog] | ||
exporters: [otlp/custom] | ||
processors: [] | ||
|
||
exporters: | ||
otlp/custom: | ||
endpoint: http://0.0.0.0:4242 | ||
sending_queue: | ||
storage: file_storage/otlpoutput |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
receivers: | ||
filelog: | ||
include: | ||
#- /var/log/busybox/*.log | ||
- /var/lib/docker/containers/cf79f880f414937e7befa0e4d2770590a19d83058b4f5df0e1cd22d819c836b3/cf79f880f414937e7befa0e4d2770590a19d83058b4f5df0e1cd22d819c836b3-json.log | ||
#storage: file_storage/filelogreceiver | ||
#start_at: beginning | ||
operators: | ||
- id: get-format | ||
routes: | ||
- expr: body matches "^\\{" | ||
output: parser-docker | ||
type: router | ||
- id: parser-docker | ||
timestamp: | ||
layout: '%Y-%m-%dT%H:%M:%S.%LZ' | ||
parse_from: attributes.time | ||
type: json_parser | ||
- from: attributes.log | ||
to: body | ||
type: move | ||
|
||
processors: | ||
transform: | ||
error_mode: ignore | ||
log_statements: | ||
- context: log | ||
statements: | ||
# Parse body as JSON and merge the resulting map with the cache map, ignoring non-json bodies. | ||
# cache is a field exposed by OTTL that is a temporary storage place for complex operations. | ||
- merge_maps(cache, ParseJSON(body), "upsert") where IsMatch(body, "^\\{") | ||
|
||
# Set attributes using the values merged into cache. | ||
# If the attribute doesn't exist in cache then nothing happens. | ||
- set(attributes["message"], cache["message"]) | ||
- set(attributes["severity"], cache["log.level"]) | ||
- merge_maps(attributes, cache, "upsert") | ||
|
||
extensions: | ||
file_storage/filelogreceiver: | ||
directory: /home/chrismark/otelcol/file_storage/freceiver | ||
file_storage/otcouput: | ||
directory: /home/chrismark/otelcol/file_storage/output | ||
|
||
service: | ||
extensions: [file_storage/filelogreceiver, file_storage/otcouput] | ||
pipelines: | ||
logs: | ||
receivers: [filelog] | ||
exporters: [otlp/elastic] | ||
processors: [transform] | ||
# telemetry: | ||
# logs: | ||
# level: "debug" | ||
|
||
exporters: | ||
otlp/elastic: | ||
endpoint: http://0.0.0.0:8200 | ||
sending_queue: | ||
storage: file_storage/otcouput | ||
tls: | ||
insecure: true | ||
insecure_skip_verify: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters