使用 OTEL Collector
如果您已经有自己的 OpenTelemetry Collector 并希望将跟踪数据导出到 Quickwit,您需要在 config.yaml
中添加一个新的 OTLP gRPC 导出器:
- macOS/Windows
- Linux
otel-collector-config.yaml
receivers:
otlp:
protocols:
grpc:
http:
processors:
batch:
exporters:
otlp/quickwit:
endpoint: host.docker.internal:7281
tls:
insecure: true
# By default, traces are sent to the otel-traces-v0_7.
# You can customize the index ID By setting this header.
# headers:
# qw-otel-traces-index: otel-traces-v0_7
service:
pipelines:
traces:
receivers: [otlp]
processors: [batch]
exporters: [otlp/quickwit]
otel-collector-config.yaml
receivers:
otlp:
protocols:
grpc:
http:
processors:
batch:
exporters:
otlp/quickwit:
endpoint: 127.0.0.1:7281
tls:
insecure: true
service:
pipelines:
traces:
receivers: [otlp]
processors: [batch]
exporters: [otlp/quickwit]
测试您的 OTEL 配置
- 安装 并启动一个 Quickwit 服务器:
./quickwit run
- 使用之前的配置启动一个收集器:
- macOS/Windows
- Linux
docker run -v ${PWD}/otel-collector-config.yaml:/etc/otelcol/config.yaml -p 4317:4317 -p 4318:4318 -p 7281:7281 otel/opentelemetry-collector
docker run -v ${PWD}/otel-collector-config.yaml:/etc/otelcol/config.yaml --network=host -p 4317:4317 -p 4318:4318 -p 7281:7281 otel/opentelemetry-collector
- 使用 cURL 向收集器发送一个跟踪:
curl -XPOST "http://localhost:4318/v1/traces" -H "Content-Type: application/json" \
--data-binary @- << EOF
{
"resource_spans": [
{
"resource": {
"attributes": [
{
"key": "service.name",
"value": {
"string_value": "test-with-curl"
}
}
]
},
"scope_spans": [
{
"scope": {
"name": "manual-test"
},
"spans": [
{
"time_unix_nano": "1678974011000000000",
"observed_time_unix_nano": "1678974011000000000",
"start_time_unix_nano": "1678974011000000000",
"end_time_unix_nano": "1678974021000000000",
"trace_id": "3c191d03fa8be0653c191d03fa8be065",
"span_id": "3c191d03fa8be065",
"kind": 2,
"events": [],
"status": {
"code": 1
}
}
]
}
]
}
]
}
EOF
您应该会在 Quickwit 服务器上看到类似于以下的日志:
2023-03-16T13:44:09.369Z INFO quickwit_indexing::actors::indexer: new-split split_id="01GVNAKT5TQW0T2QGA245XCMTJ" partition_id=6444214793425557444
这意味着 Quickwit 已经接收到跟踪并创建了一个新的分片。在搜索跟踪之前,请等待分片发布。
下一步
按照我们的教程 如何从您的 Python 应用程序发送跟踪 进行操作。