fluent-plugin-mackerelでhttpdのステータスコードを送信
td-agent、mackerelエージェントインストール済みとします
やりたいこと
httpdのlogからstatus codeの数をカウントしてmackerelのダッシュボードに表示
手順
fluent-plugin-datacounterの導入
# /usr/lib64/fluent/ruby/bin/fluent-gem install fluent-plugin-datacounter
fluent-plugin-mackerelの導入
# /usr/lib64/fluent/ruby/bin/fluent-gem install fluent-plugin-mackerel
td-agent.conf
<source>
type tail
format apache2
path /var/log/httpd/access.log
pos_file /var/log/td-agent/access.log.pos
tag data.httpd.accesslog
</source>
<match data.httpd.accesslog>
type datacounter
count_interval 1m
count_key code
tag mackerel.httpd.accesslog
outcast_unmatched yes
pattern1 2xx ^2\d\d$
pattern2 3xx ^3\d\d$
pattern3 404 ^404$
pattern4 4xx ^4\d\d$
pattern5 5xx ^5\d\d$
</match>
<match mackerel.httpd.accesslog>
type mackerel
api_key YOUR_API_KEY
service YOUR_SERVICE_NAME
metrics_name http_status.${out_key}
out_keys data.httpd.accesslog_2xx_count,data.httpd.accesslog_3xx_count,data.httpd.accesslog_404_count,data.httpd.accesslog_4xx_count,data.httpd.accesslog_5xx_count
</match>
td-agentのリロード
# service td-agent reload
画面で確認
# /usr/lib64/fluent/ruby/bin/fluent-gem install fluent-plugin-datacounter
# /usr/lib64/fluent/ruby/bin/fluent-gem install fluent-plugin-mackerel
<source>
type tail
format apache2
path /var/log/httpd/access.log
pos_file /var/log/td-agent/access.log.pos
tag data.httpd.accesslog
</source>
<match data.httpd.accesslog>
type datacounter
count_interval 1m
count_key code
tag mackerel.httpd.accesslog
outcast_unmatched yes
pattern1 2xx ^2\d\d$
pattern2 3xx ^3\d\d$
pattern3 404 ^404$
pattern4 4xx ^4\d\d$
pattern5 5xx ^5\d\d$
</match>
<match mackerel.httpd.accesslog>
type mackerel
api_key YOUR_API_KEY
service YOUR_SERVICE_NAME
metrics_name http_status.${out_key}
out_keys data.httpd.accesslog_2xx_count,data.httpd.accesslog_3xx_count,data.httpd.accesslog_404_count,data.httpd.accesslog_4xx_count,data.httpd.accesslog_5xx_count
</match>
# service td-agent reload
画面で確認
出来ました。
Author And Source
この問題について(fluent-plugin-mackerelでhttpdのステータスコードを送信), 我々は、より多くの情報をここで見つけました https://qiita.com/okisanjp/items/9da6220e2230b06eb76a著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .