-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
feat(opentelemetry sink): new sink #21866
Conversation
Datadog ReportBranch report: ✅ 0 Failed, 7 Passed, 0 Skipped, 25.49s Total Time |
Co-authored-by: Esther Kim <esthercodes2019@gmail.com>
Co-authored-by: Esther Kim <esthercodes2019@gmail.com>
Co-authored-by: Esther Kim <esthercodes2019@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good for v1. Can merge when PR checks all green.
I am using this to send to from vector to otel with the following config. I set the batch sizes in a way I can see in the console what is produced by vector and what is received by otel. If vector sends one event every second everything is fine, however when sending two events in one second only one is logged by otel. Sending this then to Kafka and elasticsearch I only see 60 events per minute, so somewhere only one event per second is forwarded. Any idea what the problem might be? vector.yaml sources:
docker:
# Reads logs from Docker containers via the Docker socket
type: docker_logs
# endpoint: "unix:///var/run/docker.sock"
# include_containers:
# - "my_container_name"
exclude_containers:
- otel-otel-collector
transforms:
enrich:
type: remap
inputs: ["docker"]
source: |
# Log ID
.logId = uuid_v4()
# Severity
.severity = "UNKNOWN"
if contains(string!(.message), "info", case_sensitive: false) {
.severity = "INFO"
.severityNumber = 9
} else if contains(string!(.message), "trace", case_sensitive: false) {
.severity = "TRACE"
.severityNumber = 1
} else if contains(string!(.message), "debug", case_sensitive: false) {
.severity = "DEBUG"
.severityNumber = 5
} else if contains(string!(.message), "warn", case_sensitive: false) {
.severity = "WARN"
.severityNumber = 13
} else if contains(string!(.message), "error", case_sensitive: false) {
.severity = "ERROR"
.severityNumber = 17
} else if contains(string!(.message), "fatal", case_sensitive: false) {
.severity = "FATAL"
.severityNumber = 21
}
otel_remap:
# https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/data-model.md
# https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/file-exporter.md#examples
inputs: ["enrich"]
type: "remap"
source: |
.resourceLogs = [
{
"resource": {
"attributes": [
{ "key": "host.hostname", "value": { "stringValue": .host.hostname } },
{ "key": "service.name", "value": { "stringValue": .container_name} },
{ "key": "source_type", "value": { "stringValue": .source_type } }
]
},
"scopeLogs": [
{
"scope": {},
"logRecords": [
{
"timeUnixNano": to_unix_timestamp!(.timestamp, unit: "nanoseconds"),
"body": { "stringValue": .message },
"severityText": .severity,
"severityNumber": .severityNumber,
"attributes": [
{ "key": "container_created_at", "value": { "stringValue": to_string!(.container_created_at) } },
{ "key": "log_id", "value": { "stringValue": .logId } },
{ "key": "container_id", "value": { "stringValue": .container_id } },
{ "key": "container_name", "value": { "stringValue": .container_name } },
{ "key": "host", "value": { "stringValue": "${HOST_HOSTNAME}" } },
{ "key": "image", "value": { "stringValue": .image } },
# Optionally include other fields like .stream, .message, etc.
{ "key": "stream", "value": { "stringValue": .stream } }
]
}
]
}
]
}
]
.
sinks:
console:
inputs:
- otel_remap
target: stdout
type: console
encoding:
codec: json
otel:
type: opentelemetry
inputs:
- otel_remap
protocol:
type: http
uri: "http://otel-collector:4318/v1/logs"
method: post
batch:
timeout_secs: 1
encoding:
codec: json
framing:
method: newline_delimited
request:
headers:
content-type: application/json otel config receivers:
otlp:
protocols:
http:
endpoint: 0.0.0.0:4318
processors:
batch:
timeout: 1s
send_batch_size: 1
exporters:
debug:
verbosity: detailed
service:
pipelines:
logs:
receivers: [otlp]
processors: []
exporters: [debug,kafka] services:
otel-collector:
image: otel/opentelemetry-collector-contrib:0.119.0
restart: always
user: "0"
env_file:
- .env
environment:
- OTEL_LOG_LEVEL=debug
volumes:
- ./otel-collector-config.yaml:/etc/otelcol-contrib/config.yaml
- /var/lib/docker/containers:/var/lib/docker/containers:ro
ports:
- 1888:1888 # pprof extension
- 8888:8888 # Prometheus metrics exposed by the Collector
- 8889:8889 # Prometheus exporter metrics
- 13133:13133 # health_check extension
- 4317:4317 # OTLP gRPC receiver
- 4318:4318 # OTLP http receiver
- 55679:55679 # zpages extension
vector:
image: timberio/vector:0.44.0-alpine
restart: always
user: "0"
environment:
- VECTOR_LOG=info
- HOST_HOSTNAME=fetcher1
depends_on:
- otel-collector
volumes:
# Mount Docker socket read-only so Vector can read logs directly
- /var/run/docker.sock:/var/run/docker.sock:ro
# Mount your Vector config file
- ./vector.yaml:/etc/vector/vector.yaml:ro
command: ["--config", "/etc/vector/vector.yaml"]
# Optionally expose or publish ports for Vector's own internal metrics
# ports:
# - 8686:8686 |
Summary
This PR introduces basic support for pushing data to OTEL.
There are numerous potential improvements:
Which will be tackled in future releases.
Change Type
Is this a breaking change?
How did you test this PR?
Vector Config
Run Vector:
OTEL config:
Run OTEL collector:
Sample output:
Does this PR include user facing changes?
Checklist
Cargo.lock
), pleaserun
dd-rust-license-tool write
to regenerate the license inventory and commit the changes (if any). More details here.References
opentelemetry
source and sink #1444