gpt4 book ai didi

elasticsearch - 在LogStash中写入@timestamp

转载 作者:行者123 更新时间:2023-12-03 00:57:31 25 4
gpt4 key购买 nike

我需要将UNIX timestamp字段的值写入@timestamp,以便可以正确索引流经logstash的数据,而这部分正在工作。但是,我还要求@timestamp的值应该是插入时间。为此,我创建了一个临时字段来保存@timestamp的原始值。

这是我正在使用的:

filter {
csv {
separator => " " # <- this white space is actually a tab, don't change it, it's already perfect
skip_empty_columns => true
columns => ["timestamp", ...]
}
# works just fine
mutate {
add_field => {
"tmp" => "%{@timestamp}"
}
}
# works just fine
date {
match => ["timestamp", "UNIX"]
target => "@timestamp"
}
# this works too
mutate {
add_field => {
"[@metadata][indexDate]" => "%{+YYYY-MM-dd}"
}
}
# @timestamp is not being set back to its original value
date {
match => ["tmp", "UNIX"]
target => "@timestamp"
}
# works just fine
mutate {
remove_field => ["tmp"]
}
}

output {
elasticsearch {
hosts => "elasticsearch:9200"
# this works
index => "indexname-%{[@metadata][indexDate]}"
}
}

问题在这里:
date {
match => ["tmp", "UNIX"]
target => "@timestamp"
}
@timestamp未设置回其原始值。当我检查数据时,它具有与 timestamp字段相同的值。

最佳答案

当您将日期添加到tmp时,它以ISO8601格式添加,因此您需要使用:

date {
match => ["tmp", "ISO8601"]
target => "@timestamp"
}

关于elasticsearch - 在LogStash中写入@timestamp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42275088/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com