跳到主內容

Apache log 傳到 Graylog

  因為公司有的服務還是採用 Apache 服務,本篇是但是差在於 error 可能要在研究一下要怎麼設定了,我在網路找到一個簡單的設定。

  • 進到 Apache 設定
vim /etc/httpd/conf/httpd.conf
  • 找尋 LogFormat 這個在下面增加一行下面的設定
LogFormat "{ \"version\": \"1.1\", \"host\": \"%V\", \"short_message\": \"%r\", \"timestamp\": %{%s}t, \"level\": 6, \"_user_agent\": \"%{User-Agent}i\", \"_source_ip\": \"%h\", \"_duration_usec\": %D, \"_duration_sec\": %T, \"_request_size_byte\": %O, \"_http_status_orig\": %s, \"_http_status\": %>s, \"_http_request_path\": \"%U\", \"_http_request\": \"%U%q\", \"_http_method\": \"%m\", \"_http_referer\": \"%{Referer}i\", \"_from_apache\": \"true\" }" graylog_access
  • 指向 Graylog 主機
CustomLog "|/usr/bin/nc -u graylog.example.com 12201" graylog_access
  • 將中間的 graylog.example.com 修改成 graylog 主機所在位置,後面 12201 是 port 號可自定

  • 設定完之後再重啟 httpd 服務

systemctl restart httpd

or

systemctl reload httpd
  • Error 等我有找到適合的設定方式在增加



參考相關網頁