Skip to content

为 ElasticSearch 添加动态索引遇到 unsupported field 错误 #974

Answered by shalousun
liangry asked this question in Help
Discussion options

You must be logged in to vote

fmtstr.FormatIndex是在 flusher_elasticsearch后面开发的,所以保留了TODO

// Obtain index keys from dynamic index expression
indexKeys, err := fmtstr.CompileKeys(f.Index) 这里解析index的动态表达式,对%{+yyyyMMdd}解析成一个key,返回是+yyyyMMdd
这个地方拿到可以遍历下indexKeys,检查到indexKeys中的key是+号开始的字符串直接丢弃,下面就不会报错了
// 下面代码那这个特殊的key去查询了字段,在设计fmtstr.FormatIndex时+开始的属于动态时间表达式,和数据字段无关,可以直接丢弃掉
serializedLogs, values, err := f.converter.ToByteStreamWithSelectedFields(logGroup, f.indexKeys) 

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by liangry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants