Home -> Wagento Way -> New Relic Agent Installation for Magento on AWS

New Relic Agent Installation for Magento on AWS

Joe Shelton April 27, 2022

New Relic Agent

Installing a New Relic agent on a server using an advanced continuous deployment tool like Elastic Beanstalk can be a confusing problem to approach. Installation methods found in New Relic documentation and other online resources didn’t work well for this author. New Relic supports so many different technology stacks that you become lost in installation documentation that is not applicable to you. Hopefully, this article can serve as a brief overview of installing New Relic on a LAMP stack appropriate for Magento while using AWS Elastic Beanstalk.

At first, the author mistakenly thought there was only one New Relic agent to install and was encountering multiple ways to install it. Eventually, the realization came that there are two agents: a PHP agent and an infrastructure agent. Both should be installed to get the most out of New Relic. Here are the two configuration files needed to get those agents installed via Elastic Beanstalk.

.ebextensions/new_relic_php.config

<CODE>
packages:
  yum:
    newrelic-php5: []
  rpm:
    newrelic: http://yum.newrelic.com/pub/newrelic/el5/x86_64/newrelic-repo-5-3.noarch.rpm
commands:
  configure_new_relic:
    command: newrelic-install install
    env:
      NR_INSTALL_SILENT: true
      NR_INSTALL_KEY: <new_relic_key>
files:
  "/etc/php.d/newrelic_custom.ini":
    mode: "000644"
    owner: root
    group: root
    content: |
      [newrelic]
      newrelic.appname = "`{ "Ref" : "AWSEBEnvironmentName" }`"
      newrelic.distributed_tracing_enabled = true
      newrelic.span_events_enabled = true
</CODE>

.ebextensions/new_relic_infrastructure.config

</CODE>
files:
  "/etc/newrelic-infra.yml" :
    mode: "000644"
    owner: root
    group: root
    content: |
      license_key: <new_relic_key>
      enable_process_metrics: true
  "/etc/newrelic-infra/logging.d/discovered.yml" :
    mode: "000644"
    owner: root
    group: root
    content: |
      logs:
        - name: configured-logs-0
          file: /var/log/httpd/*access_log
        - name: configured-logs-1
          file: /var/log/httpd/*error_log
  "/etc/newrelic-infra/logging.d/magento.yml" :
    mode: "000644"
    owner: root
    group: root
    content: |
      logs:
        - name: magento-logs
          file: /var/app/current/var/log/*.log


commands:
# Create the agent’s yum repository
  "01-agent-repository":
    command: sudo curl -o /etc/yum.repos.d/newrelic-infra.repo https://download.newrelic.com/infrastructure_agent/linux/yum/amazonlinux/2/x86_64/newrelic-infra.repo
#
# Update your yum cache
  "02-update-yum-cache":
    command: yum -q makecache -y --disablerepo='*' --enablerepo='newrelic-infra'
#
# Run the installation script
  "03-run-installation-script":
    command: sudo yum install newrelic-infra -y
</CODE>

This is the author’s first attempt to install New Relic in an environment with PHP using Elastic Beanstalk for deployment. This is a basic configuration, not an advanced one. The essential metrics are ingested by New Relic; transactions and logs, specifically. Hopefully, this article provides clarity on the overall method of installation for New Relic agents and provides an extensible foundation for further tweaks to configuration. Happy tweaking!

Let's build something together!

Contact us today to get your project started and hear more about all the awesome things we can do for you!

Become the Next Success Story