Collectd Tail插件如何处理日志文件轮换?

时间:2017-08-23 05:34:11

标签: nginx plugins tail collectd

我已在Nginx实例上安装了Collectd,并且我使用它来计算HTTP状态代码。当前的Collectd配置如下所示:

Hostname "localhost"
FQDNLookup false
BaseDir "/var/lib/collectd"
PluginDir "/usr/lib/collectd"
TypesDB "/usr/share/collectd/types.db"

AutoLoadPlugin true

Interval 30

MaxReadInterval 86400
Timeout 2
ReadThreads 5
WriteThreads 5

<Plugin "logfile">
  LogLevel "info"
  File "/var/log/collectd.log"
  Timestamp true
</Plugin>

<Plugin "tail">
    <File "/var/log/nginx/access.log">
      Instance "prod1_nginx"
      <Match>
        Regex "HTTP/1..\" 2[0-9]{2}"
        DSType "CounterInc"
        Type "counter"
        Instance "prod1_nginx_2xx"
      </Match>
      <Match>
        Regex "HTTP/1..\" 3[0-9]{2}"
        DSType "CounterInc"
        Type "counter"
        Instance "prod1_nginx_3xx"
      </Match>
      <Match>
        Regex "HTTP/1..\" 4[0-9]{2}"
        DSType "CounterInc"
        Type "counter"
        Instance "prod1_nginx_4xx"
      </Match>
      <Match>
        Regex "HTTP/1..\" 5[0-9]{2}"
        DSType "CounterInc"
        Type "counter"
        Instance "prod1_nginx_5xx"
      </Match>
    </File>
</Plugin>

<Plugin "network">
  Server "INFLUX_DB_IP" "25826"
</Plugin>

这个配置并不完美,我还在诊断其他问题,但是现在我想了解当Nginx日志文件轮换时Collectd将如何工作。

现在发生的事情是,当文件被旋转时,Nginx会将数据写入旋转的文件,直到重新加载Nginx,这是正常的行为。但在那段时间,Collectd将指标报告为0.如何识别Collectd文件轮换?

0 个答案:

没有答案