LoongCollector

1804
下载
LoongCollector 是阿里云可观测性团队所开源的项目,是一款集卓越性能、超强稳定性和灵活可编程性于一身的数据采集器,专为构建下一代可观测 Pipeline 设计。它继承了 iLogtail 强大的日志采集与处理能力,从原来单一日志场景,逐步扩展为可观测数据采集、本地计算、服务发现的统一体。愿景是:打造业界领先的“统一可观测 Agent”与“端到端可观测”

otel Trace格式转换



processor_otel_trace插件

版本

Stable

配置参数

下面是修复后的表格:

参数类型是否必选说明
SourceKeyString原始字段名。
FormatString转换后的格式(枚举类型)。共有三类:protobuf, json, protojson
NoKeyErrorBoolean当没有对应字段时,是否报错。默认值为false
TraceIDNeedDecodeBoolean是否对TraceID做一次Base64 Encode。默认值为false,当Format为protojson时,需要考虑将当前值改为True。具体原因如下:protojson转换时将TraceID数据Base64 Decode转码,而ProtoJson格式存在没有对TraceID做Base64 Encode转码的情况,这样会导致转换失败。
SpanIDNeedDecodeBoolean是否对SpanID做一次Base64 Encode。默认值为false,当Format为protojson时,需要考虑将当前值改为True。具体原因如下:protojson转换时将SpanID数据Base64 Decode转码,而ProtoJson格式存在没有对TraceID做Base64 Encode转码的情况,这样会导致转换失败。
ParentSpanIDNeedDecodeBoolean是否对ParentSpanID做一次Base64 Encode。默认值为false,当Format为protojson时,需要考虑将当前值改为True。具体原因如下:protojson转换时将ParentSpanID数据Base64 Decode转码,而ProtoJson格式存在没有对TraceID做Base64 Encode转码的情况,这样会导致转换失败。

样例

采集/home/test-log目录下的simple.log文件,根据指定的配置选项提取日志信息。

enable: true
inputs:
- Type: input_file
FilePaths:
- /home/test-log/*.log
processors:
- Type: processor_otel_trace
SourceKey: "content"
Format: protojson
TraceIDNeedDecode: true
SpanIDNeedDecode: true
ParentSpanIDNeedDecode: true
flushers:
- Type: flusher_stdout
OnlyStdout: true
  • 输入
Terminal window
echo '{ "resource": {}, "scopeSpans": [ { "scope": { "name": "com.alibaba.cloud", "attributes": [] }, "spans": [ { "traceId": "31646461386336653337343330356530", "spanId": "0108b2d29b652107", "parentSpanId": "468e99f19f43d0db", "name": "QueryExecutor::localQuery()", "kind": 1, "startTimeUnixNano": "1689831889338531120", "endTimeUnixNano": "1689831889338737020", "attributes": [ { "key": "query.early_stop.pe_query_cnt", "value": { "stringValue": "1" } }, { "key": "query.early_stop.rt_query_cnt", "value": { "stringValue": "0" } }, { "key": "query.visit_pe_num", "value": { "stringValue": "1" } }, { "key": "query.early_stop.total_limit", "value": { "stringValue": "2" } }, { "key": "query.early_stop.hits", "value": { "stringValue": "2" } } ], "events": [], "links": [], "status": {} } ] } ], "schemaUrl": "https://opentelemetry.io/schemas/1.20.0" }' >> simple.log
  • 输出
{
"resource": {},
"scopeSpans": [
{
"scope": {
"name": "com.alibaba.cloud",
"attributes": []
},
"spans": [
{
"traceId": "31646461386336653337343330356530",
"spanId": "0108b2d29b652107",
"parentSpanId": "468e99f19f43d0db",
"name": "QueryExecutor::localQuery()",
"kind": 1,
"startTimeUnixNano": "1689831889338531120",
"endTimeUnixNano": "1689831889338737020",
"attributes": [
{
"key": "query.early_stop.pe_query_cnt",
"value": {
"stringValue": "1"
}
},
{
"key": "query.early_stop.rt_query_cnt",
"value": {
"stringValue": "0"
}
},
{
"key": "query.visit_pe_num",
"value": {
"stringValue": "1"
}
},
{
"key": "query.early_stop.total_limit",
"value": {
"stringValue": "2"
}
},
{
"key": "query.early_stop.hits",
"value": {
"stringValue": "2"
}
}
],
"events": [],
"links": [],
"status": {}
}
]
}
],
"schemaUrl": "https://opentelemetry.io/schemas/1.20.0"
}

observability.cn Authors 2024 | Documentation Distributed under CC-BY-4.0
Copyright © 2017-2024, Alibaba. All rights reserved. Alibaba has registered trademarks and uses trademarks.
浙ICP备2021005855号-32