首页 > logstash的配置问题

logstash的配置问题

有这样一个需求

1.分析tomcat的accesslog,根据日志对某个API接口的请求进行监控
2.如果发现这个接口在单位时间内的请求频率过高,则进行报警

我整个架构是采用ELK进行的,提供filebeat进行日志采集,logstash进行日志清洗和频率识别

其中logstash的filter配置是

if [url_M] == "isOldPasswordCorrect" {

        metrics {
           meter => [ "passauth" ]
           add_tag => "metric"
          }

          if "metric" in [tags] {

                ruby {

                        code => "event.cancel if event['passauth.rate_1m']*60 < 100"

              }
                }

        }

这个是借助logstash filter插件metrics进行频率控制的

但是

系统会报错

Ruby exception occurred: undefined method `*' for nil:NilClass {:level=>:error}

看样子是没有获取到event['passauth.rate_1m']的值,无法进行数值运算?

求教

并且对logstash的event也没看懂。


这个问题最后怎么解决的啊


改成

code => "event.cancel if event['passauth']['rate_1m']*60 < 20"

就可以。


我今天做实验时也遇到了此问题,后面看了官网https://www.elastic.co/guide/en/logstash/current/plugins-filters-metrics.html才解决。
确认下你的logstash版本
Elasticsearch 2.0 no longer allows field names with dots
[thing][rate_1m] - the 1-minute rate of events (sliding)

【热门文章】
【热门文章】