在Influxdb中只有字符串

时间:2017-03-16 17:53:19

标签: redis logstash 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

一切正常,但涌入中的每个字段都被定义为字符串而不管值。

有人知道如何解决这个问题吗?

1 个答案:

答案 0 :(得分:1)

The mutate filter可能就是您在这里寻找的内容。

filter {
  mutate {
    convert => {
      "value"   => "integer"
      "average" => "float"
    }
  }
}

这意味着您需要先知道您的字段是什么,但它会将它们转换为正确的数据类型。