influxdb 中只有字符串
only strings in influxdb
我在 logstash 中有这个配置文件
input {
redis{
host => "localhost"
data_type => "list"
key => "vortex"
threads => 4
type => "testrecord"
codec => "plain"
}
}
filter {
kv {
add_field => {
"test1" => "yellow"
"test" => "ife"
"feild" => "pink"
}
}
}
output {
stdout { codec => rubydebug }
influxdb {
db => "toast"
host => "localhost"
measurement => "myseries"
allow_time_override => true
use_event_fields_for_data_points => true
exclude_fields => ["@version", "@timestamp", "sequence", "message", "type", "host"]
send_as_tags => ["bar", "feild", "test1", "test"]
}
}
以及包含以下数据的 redis 列表:
foo=10207 bar=1 sensor2=1 sensor3=33.3 time=1489686662
一切正常,但无论值如何,influx 中的每个字段都被定义为字符串。
有人知道如何解决这个问题吗?
The mutate
filter 可能就是您要找的。
filter {
mutate {
convert => {
"value" => "integer"
"average" => "float"
}
}
}
这意味着您需要事先知道您的字段是什么,但它会将它们转换为正确的数据类型。
我在 logstash 中有这个配置文件
input {
redis{
host => "localhost"
data_type => "list"
key => "vortex"
threads => 4
type => "testrecord"
codec => "plain"
}
}
filter {
kv {
add_field => {
"test1" => "yellow"
"test" => "ife"
"feild" => "pink"
}
}
}
output {
stdout { codec => rubydebug }
influxdb {
db => "toast"
host => "localhost"
measurement => "myseries"
allow_time_override => true
use_event_fields_for_data_points => true
exclude_fields => ["@version", "@timestamp", "sequence", "message", "type", "host"]
send_as_tags => ["bar", "feild", "test1", "test"]
}
}
以及包含以下数据的 redis 列表:
foo=10207 bar=1 sensor2=1 sensor3=33.3 time=1489686662
一切正常,但无论值如何,influx 中的每个字段都被定义为字符串。
有人知道如何解决这个问题吗?
The mutate
filter 可能就是您要找的。
filter {
mutate {
convert => {
"value" => "integer"
"average" => "float"
}
}
}
这意味着您需要事先知道您的字段是什么,但它会将它们转换为正确的数据类型。