New Relic メモ 〜Apache Integration〜


やりたいこと

  • New Relic InfrastructureのThird-Party IntegrationからApacheを追加したい
  • デフォルトで取れるメトリクスを確認したい

参考ドキュメント

事前準備

  • 以前作ったCentOS+Node.js+MySQLの環境の前段にApacheを配置する
  • ApacheはHTTPS(443)をListenし、Express.js(3000)にプロキシさせる
Client -443-> Apache -3000-> Express.js + MySQL

Apacheは以下の設定をconf.dに突っ込んでおく
/server-statusの除外設定は後述。

proxy.conf
SSLProxyEngine on
RewriteCond %{REQUEST_URI} !=/server-status
RewriteRule ^/(.*) http://localhost:3000/$1 [P,L]

前提条件確認

Apache Integrationの有効化には以下の条件がある模様

  • Apache 2.2か2.4であること
    • 今回は2.4を使う
  • mod_status.soがLoadModuleされていて、/server-statusのエンドポイントをローカルから叩けること
    • デフォルトでLoadModuleされている
    • また、以下の設定をconf.dに突っ込んでおく
status.conf
<Location /server-status>
SetHandler server-status
Require host localhost
</Location>
ExtendedStatus On

Apache有効化手順

nri-apacheモジュールをインストールする。

# yum install nri-apache

設定ファイルのディレクトリに移動し、ファイル名を変更する。

# cd /etc/newrelic-infra/integrations.d
# cp apache-config.yml.sample apache-config.yml

ファイルの中身は以下の通り。変更する場合はこちらを参照のこと。

apache-config.yml
integration_name: com.newrelic.apache
instances:
    - name: apache-server-metrics
      command: metrics
      arguments:
          status_url: http://127.0.0.1/server-status?auto
          remote_monitoring: true
      labels:
          env: production
          role: load_balancer
    - name: apache-server-inventory
      command: inventory
      arguments:
          remote_monitoring: true
      labels:
          env: production
          role: load_balancer

newrelic-infraを再起動する。

# systemctl restart newrelic-infra

動作確認

InfrastructureからThird-party Servicesに行くと、Apacheが追加されている。

中を覗くと、ダッシュボードみたいなのが表示されている。

この後確認したいこと

  • パスごとのアクセス分析ができるか
  • 並列に複数台並べた時に横串でアクセス分析ができるか

このへんはNRQLで対応するのかな?