<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:wfw="http://wellformedweb.org/CommentAPI/">
<channel>
<title>dwt&#039;s life - filebeat</title>
<link>https://dwt.life/tag/filebeat/</link>
<atom:link href="https://dwt.life/feed/tag/filebeat/" rel="self" type="application/rss+xml" />
<language>zh-CN</language>
<description></description>
<lastBuildDate>Wed, 02 Feb 2022 02:29:00 +0800</lastBuildDate>
<pubDate>Wed, 02 Feb 2022 02:29:00 +0800</pubDate>
<item>
<title>filebeat+logstash钉钉监控PHP错误日志报警</title>
<link>https://dwt.life/archives/189/</link>
<guid>https://dwt.life/archives/189/</guid>
<pubDate>Wed, 02 Feb 2022 02:29:00 +0800</pubDate>
<dc:creator>Ricky</dc:creator>
<description><![CDATA[PHP的错误日志样式[2021-03-05T00:04:12+08:00] 175.167.136.244 POST api.51cto.cn/User/getUserInfo[ error ]...]]></description>
<content:encoded xml:lang="zh-CN"><![CDATA[
<p>PHP的错误日志样式</p><pre><code>[2021-03-05T00:04:12+08:00] 175.167.136.244 POST api.51cto.cn/User/getUserInfo
[ error ] [10]nologin[/var/www/html/api/application/common/controllers/BaseController.php:239]</code></pre><p>下载filebeat-7.10.2</p><pre><code>filebeat.inputs:
- type: log
  enabled: true
  paths:
    - /data/error/*.log
  multiline.pattern: &#039;^\[\d{4}\-\d{2}\-\d{2}&#039;
  multiline.negate: true
  multiline.match: after
- type: filestream
  enabled: false
  paths:
    - /var/log/*.log
filebeat.config.modules:
  path: ${path.config}/modules.d/*.yml
  reload.enabled: false
setup.template.settings:
  index.number_of_shards: 1
setup.kibana:
output.logstash:
  hosts: [&quot;192.168.0.1:5044&quot;]
processors:
  - add_host_metadata:
      when.not.contains.tags: forwarded
  - add_cloud_metadata: ~
  - add_docker_metadata: ~
  - add_kubernetes_metadata: ~</code></pre><p>logstash我用的docker</p><p>创建文件</p><p>/data/logstash/conf/logstash.yml</p><p><code>http.host: &quot;0.0.0.0&quot;</code></p><p>/data/logstash/pipeline/logstash.conf</p><pre><code>input {
  beats {
    port =&gt; 5044
  }
}
filter {
    if &quot;Allowed memory size&quot; in [message]{
        drop{}
     }
    if &quot;Maximum execution time&quot; in [message] {
        drop{}
     }
}
output {

  http {
    http_method =&gt; &quot;post&quot;
    url =&gt; &quot;http://api.xxx.cn/api/dingtalk/send&quot;
    format =&gt; &quot;json&quot;   #如果是表单就是form
    mapping =&gt; {
      &quot;access_token&quot; =&gt; &quot;297873a03c25bc202bf1264ca0e101847aed213213132131321&quot;
      &quot;msg_type&quot; =&gt; &quot;text&quot;
      &quot;content&quot; =&gt; &quot;报警: %{message}&quot;
    }
    }
}</code></pre><p>启动docker</p><pre><code>docker run -d -p 5044:5044 -p 9600:9600 -v /data/logstash/conf/logstash.yml:/usr/share/logstash/config/logstash.yml -v /data/logstash/pipeline:/usr/share/logstash/pipeline --restart=always logstash:7.10.1</code></pre><p>来源：<a href="https://blog.51cto.com/fengwan/2678093">https://blog.51cto.com/fengwan/2678093</a></p>
]]></content:encoded>
<slash:comments>0</slash:comments>
<comments>https://dwt.life/archives/189/#comments</comments>
<wfw:commentRss>https://dwt.life/feed/tag/filebeat/</wfw:commentRss>
</item>
</channel>
</rss>