New Relic メモ 〜Logs(Apache Log)〜


はじめに

  • 前回は、Apache Integrationを設定した
  • ただ、Apacheのログに書かれているような内容は取れず、あくまでmod_statusで取れるような内容のみだった
  • なので、ログはLogsで取り込みをすることに

事前確認

  • OSの対応バージョンを確認する
  • Infrastructure Agentのバージョンを確認する(2020/9/1時点で1.11.4以上であること)
# rpm -qa | grep newrelic
newrelic-infra-1.12.2-1.el7.x86_64

Logsの設定

New RelicのLogsの画面から設定ウィザードを立ち上げる。Agentの種類が選べるので、既にインストール済みのNew Relic Infrastructure Agentをクリック

手順が上がってくるので3. Configure your log sources and other parameters in the logging.d directory.から実施する。まず、サンプルの設定ファイルの所在を確認。

# ls -ltr /etc/newrelic-infra/logging.d/
合計 20
-rw-r--r--. 1 root root 1097  8月  7 23:18 tcp.yml.example
-rw-r--r--. 1 root root  930  8月  7 23:18 systemd.yml.example
-rw-r--r--. 1 root root 2762  8月  7 23:18 syslog.yml.example
-rw-r--r--. 1 root root 1173  8月  7 23:18 fluentbit.yml.example
-rw-r--r--. 1 root root 1664  8月  7 23:18 file.yml.example

色々パターンが提供されているものの、まずは転送することを優先。以下のファイルを作成する。

apache_access
logs:
  - name: "test_log"
    file: /var/log/httpd/ssl_request_log

Infrastructure Agentを再起動する

# systemclt restart newrelic-infra

New Relic Logsの画面を確認すると、ログが転送できていることが確認できる。

Logsでやりたいこと

  • 送信元IPやUser-Agentの統計を取ったり
  • URIごとのレスポンスを計測したり(静的コンテンツ含む)
  • そもそものアクセス数のタイムチャート取ったり

これらを作るにあたって、Queryを記載していくのだが、そもそものParsingがどうなっているかが不明。

Parsing

メニューがあったので、覗き見。

Grok filter形式で記述することで、簡単にエイリアス張れそう。よかったよかった。