1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

前提条件

  • NewRelicのアカウント取得済み
  • Laravel(6.x)の環境構築済み

docker-compose.ymlの設定

version: "3"
services:
  app:
    build:
      context: ./
      args:
        - NEW_RELIC_AGENT_VERSION=10.3.0.315
        - NEW_RELIC_LICENSE_KEY=${NRIA_LICENSE_KEY}
        - NEW_RELIC_APPNAME="${APP_NAME}"
    depends_on:
      - newrelic-php-daemon
    volumes:
      - ./:/var/www/html
  new-relic-agent:
    image: newrelic/infrastructure:latest
    hostname: newrelic-infra-${APP_NAME}
    network_mode: host
    cap_add:
      - SYS_PTRACE
    privileged: true
    pid: host
    volumes:
      - /:/host:ro
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - NRIA_LICENSE_KEY=${NRIA_LICENSE_KEY}
  newrelic-php-daemon:
    image: newrelic/php-daemon:10.3.0

Dockerfileの設定

FROM php:7.4-fpm

ARG NEW_RELIC_AGENT_VERSION
ARG NEW_RELIC_LICENSE_KEY
ARG NEW_RELIC_APPNAME

RUN curl -L https://download.newrelic.com/php_agent/archive/${NEW_RELIC_AGENT_VERSION}/newrelic-php5-${NEW_RELIC_AGENT_VERSION}-linux.tar.gz | tar -C /tmp -zx \
    && export NR_INSTALL_USE_CP_NOT_LN=1 \
    && export NR_INSTALL_SILENT=1 \
    && /tmp/newrelic-php5-${NEW_RELIC_AGENT_VERSION}-linux/newrelic-install install \
    && rm -rf /tmp/newrelic-php5-* /tmp/nrinstall*

RUN sed -i -e "s/REPLACE_WITH_REAL_KEY/${NEW_RELIC_LICENSE_KEY}/" \
    -e "s/newrelic.appname[[:space:]]=[[:space:]].*/newrelic.appname=\"${NEW_RELIC_APPNAME}\"/" \
    -e '$anewrelic.daemon.address="newrelic-php-daemon:31339"' \
    $(php -r "echo(PHP_CONFIG_FILE_SCAN_DIR);")/newrelic.ini

#略

立ち上げ

.envに環境変数を適宜入れた後

$ docker-compose up

以下イメージ

スクリーンショット 2022-12-01 22.30.01.png

注意点

ログフォワーダーは、コンテナ化されたエージェントには含まれていません。すべての機能を提供する基盤となるホストにエージェントをインストールすることをお勧めします。

ログはDockerAgentだと取得できないらしい😇

参考

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?