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

Collector to support adding common columns to logs #73

Closed
wants to merge 3 commits into from

Conversation

jessejlt
Copy link
Member

@jessejlt jessejlt commented Aug 3, 2023

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

Jesse Thompson and others added 2 commits August 3, 2023 14:34
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.
cmd/collector/main.go Outdated Show resolved Hide resolved
@jessejlt jessejlt closed this Aug 15, 2023
@jessejlt jessejlt deleted the jesse/add-columns branch August 15, 2023 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants