带有geoip过滤器的Logstash influxdb输出

问题描述

我正在尝试使用logstash geoip过滤器通过InfluxDB输出插件将有关IP地址位置的数据发送到InfluxDB。

我的logstash conf文件是:

input {
  file {
    path => "/root/geoip_test.txt"
    start_position => "beginning"
  }
}

filter {
  geoip {
    source => "message"
    fields => ["latitude","longitude"]
  }
}

output {
  stdout {codec => rubydebug}
  influxdb {
    host => "localhost"
    port => 8086
    db => "metrics"
    measurement => "geoip_test"
    codec => "json"
    use_event_fields_for_data_points => true
  }
}

geoip_test.txt文件仅包含一个IP地址:

14.143.35.10

我收到错误输出是:

[2020-09-07T12:26:26,696][INFO ][logstash.agent           ] Successfully started Logstash API endpoint {:port=>9600}
{
         "geoip" => {
         "latitude" => 12.9771,"longitude" => 77.5871
    },"message" => "14.143.35.10","path" => "/root/geoip_test.txt","@timestamp" => 2020-09-07T10:26:33.963Z,"host" => "test","@version" => "1"
}
[2020-09-07T12:26:34,942][WARN ][logstash.outputs.influxdb][main][941178b6897abb80f9a5f7654e5e62ba752d5e20b68781bc62b466e489c2ce56] Non recoverable exception while writing to InfluxDB {:exception=>#<InfluxDB::Error: {"error":"unable to parse 'geoip_test,host=test geoip={\"latitude\"=\u003e12.9771,\"longitude\"=\u003e77.5871},path=\"/root/geoip_test.txt\" 1599474393963': invalid boolean"}
>}

我认为geoip过滤器会生成一些InfluxDB无法使用的布尔字段。

有人知道该怎么做吗?是否可以通过某种方式设置geoip过滤器,以便除了lon和lat字段之外什么都不会生成

我们非常感谢您的帮助!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)