Kubernetes集群中Jaeger写入Elasticsearch报duration字段解析错误求助
问题:Jaeger Collector推送数据至Elasticsearch时出现类型解析错误
在Kubernetes集群中,直接将Jaeger-Tracing数据推送至Elasticsearch(未经过Logstash/Filebeat等过滤组件)时,Jaeger-Tracing-Collector出现字段解析失败错误。
错误详情
{ "level": "error", "ts": 1656982524.1294773, "caller": "config/config.go:137", "msg": "Elasticsearch part of bulk request failed", "map-key": "index", "response": { "_index": "jaeger-span-2022-07-05", "_type": "_doc", "_id": "9EHay4EBv4T2qdA80Ei7", "status": 400, "error": { "type": "mapper_parsing_exception", "reason": "failed to parse field [duration] of type [long] in document with id '9EHay4EBv4T2qdA80Ei7'. Preview of field's value: '18446744073709550616'", "caused_by": { "reason": "Numeric value (18446744073709550616) out of range of long (-9223372036854775808 - 9223372036854775807)\n at [Source: (ByteArrayInputStream); line: 1, column: 199]", "type": "i_o_exception" } } }, "stacktrace": "github.com/jaegertracing/jaeger/pkg/es/config.(*Configuration).NewClient.func2\n\tgithub.com/jaegertracing/jaeger/pkg/es/config/config.go:137\ngithub.com/olivere/elastic.(*bulkWorker).commit\n\tgithub.com/olivere/elastic@v6.2.27+incompatible/bulk_processor.go:588\ngithub.com/olivere/elastic.(*bulkWorker).work\n\tgithub.com/olivere/elastic@v6.2.27+incompatible/bulk_processor.go:501" }
环境版本
- Jaeger版本:1.21.0
- Elasticsearch版本:7.17.5
解决方法
1. 升级Jaeger版本
Jaeger 1.21.0属于较旧版本,存在uint64类型的duration字段转int64时溢出的bug(错误值18446744073709550616是uint64下0的补码表示)。建议升级至1.30及以上的稳定版本,该问题已在后续版本中修复。
2. 修改Elasticsearch索引映射(临时方案)
若无法立即升级Jaeger,可将Elasticsearch中jaeger-span-*索引的duration字段类型改为unsigned_long(ES 7.x支持该类型,范围覆盖0到18446744073709551615):
- 创建索引模板,确保新生成的索引自动应用正确映射:
PUT _index_template/jaeger-span-template { "index_patterns": ["jaeger-span-*"], "template": { "mappings": { "properties": { "duration": { "type": "unsigned_long" } } } }, "priority": 100, "version": 1 }
- 对于已存在的异常索引(如
jaeger-span-2022-07-05):- 若数据无保留价值,直接删除该索引,后续新索引会自动使用模板映射;
- 若需保留数据,需通过
reindex将数据迁移至使用新映射的索引(ES无法直接修改已有字段类型)。
3. 检查业务追踪逻辑
排查业务代码中生成Jaeger Span的逻辑,确认是否存在duration计算异常(如溢出、赋值错误),避免生成不符合预期的span数据。
内容的提问来源于stack exchange,提问作者K Akshay
相关产品推荐
相关产品推荐

