Collector to support adding common columns to logs #73
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A common use-case is for all logs on a host to contain metadata, or columns, about their environment. By adding a new command-line parameter, --add-columns, much like our parameter --add-labels, collector will add common metadata to each OTLP log event it receives.
By running the integration test
docker compose -f tools/otlp/logs/compose.yaml up
, we can see columns being added to our OTLP logging events.logs-otel-1 | 2023-08-03T14:29:32.212Z info LogsExporter {"kind": "exporter", "data_type": "logs", "name": "logging", "resource logs": 1, "log records": 1} logs-otel-1 | 2023-08-03T14:29:32.212Z info ResourceLog #0 logs-otel-1 | Resource SchemaURL: logs-otel-1 | Resource attributes: + logs-otel-1 | -> Environment: Str(dev) logs-otel-1 | ScopeLogs #0 logs-otel-1 | ScopeLogs SchemaURL: logs-otel-1 | InstrumentationScope logs-otel-1 | LogRecord #0 logs-otel-1 | ObservedTimestamp: 1970-01-01 00:00:00 +0000 UTC logs-otel-1 | Timestamp: 2023-08-03 14:29:31.1994291 +0000 UTC logs-otel-1 | SeverityText: logs-otel-1 | SeverityNumber: Unspecified(0) logs-otel-1 | Body: Map({"message":"dummy"}) logs-otel-1 | Trace ID: logs-otel-1 | Span ID: logs-otel-1 | Flags: 0 logs-otel-1 | {"kind": "exporter", "data_type": "logs", "name": "logging"}
When specified by
--add-columns
collector: build: dockerfile: tools/otlp/logs/Dockerfile context: ../../.. volumes: - ~/.kube/config:/root/.kube/config ports: - 8080:8080 # While the _endpoints_ URI doesn't match the expected OTLP syntax, keep in # mind that _Collector_ is currently configured to connect to _Ingestor_, so we # just modify the _endpoints_ in pkg/otlp/proxy to be OTLP compliant. command: --kubeconfig /root/.kube/config \ --endpoints http://otel:4317/receive \ --insecure-skip-verify \ + --add-columns Environment=dev depends_on: - otel environment: - LOG_LEVEL=DEBUG