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

화면에서 확인





할 수 있었습니다.

좋은 웹페이지 즐겨찾기