Can I install Dynatrace via AWS Elastic Beanstalk?

Before you begin

What you’ll need:

  • Dynatrace OneAgent download link (Windows or Linux).
  • Access to your AWS Console

We tested Dynatrace OneAgent installation with the following applications:

  • IIS
  • Tomcat on Linux
  • Apache HTTP Server and Python on Linux

What is AWS Elastic Beanstalk?

AWS Elastic Beanstalk is a service provided by Amazon that gives you the option of deploying and auto scaling applications and services. Using a predefined .ebextensions configuration file you can modify your deployment by supplying additional resources or packages. For more information, see the Amazon documentation.

You can prepare configurations where Dynatrace OneAgent is already part of your application deployment. In such cases you won’t have to manually install the agent or restart servers to enable service monitoring.

  1. From the Dynatrace menu, click Monitor another host.
  2. Select Linux on the Download Dynatrace OneAgent page.
  3. When the Install Dynatrace OneAgent on your Linux hosts page is displayed, copy the URL from the wget command line and save it in a text editor.
  4. Windows only: In your text editor, replace the unix part of the URL with windows/exe.
    For example, if the URL for Linux is:
    https://abcdefghij.live.dynatrace.com/installer/agent/unix/latest/abc1234567890
    Then the URL for Windows is:
    https://abcdefghij.live.dynatrace.com/installer/agent/windows/exe/latest/abc1234567890

Keep the URL in the editor — you’ll need it later.

Because the specifics of this type of installation depend heavily on user customizations, we can’t provide a simple set of steps that work in all scenarios. Following is only a brief overview of the entire process with examples that will help you create your own deployment.

Prepare configuration for monitoring on Linux

It’s best to split plugin configuration into two files, one for downloading Dynatrace OneAgent installer and a second for invoking the installation and post-installation tasks. Note that the Elastic Beanstalk plugin script file names are important—the Amazon interpreter executes them alphabetically.

  1. Create the download configuration file and save it with the name 0dynatraceDownload.config. The configuration file needs to contain a files section where you need to define:

    • Download path and target file name, for example /tmp/Dynatrace-OneAgent.sh
    • Proper user rights settings
    • The Dynatrace OneAgent download URL you copied to your text editor.

    For example:

	files:
	    "/tmp/Dynatrace-OneAgent.sh" :
	    mode: "000755"
	    owner: root
	    group: root
	    source: https://abcdefghij.live.dynatrace.com/installer/agent/unix/latest/abc1234567890
	
  1. Create a file called 1dynatraceInstallAndPost.config to execute the Dynatrace OneAgent installer and perform other tasks like service restart.
    The following script checks for an existing Dynatrace OneAgent setup, executes installation from the /tmp directory if no OneAgent is found, and restarts httpd service:
	commands:   
		install_dynatrace_oneagent:     
			command: [ -d /opt/dynatrace/oneagent ] || /tmp/Dynatrace-Agent.sh     
			cwd: /tmp  
		restart_httpd:    
			command: service httpd restart
	

Prepare configuration for monitoring on Windows

  1. Create a configuration file for downloading the installer and save it as 0dynatraceDownload.config. The file needs to contain a sources section where you need to define:

    • Download destination (for example, your desktop)
    • Download URL

    The following script excerpt downloads the Dynatrace OneAgent installer to the administrator’s desktop:

	sources:
	    "C:\Users\Administrator\Desktop":
	https://abcdefghij.live.dynatrace.com/installer/agent/windows/exe/latest/abc1234567890
	
  1. Enter the installation command for Dynatrace OneAgent in the commands section.

    The following script fragment executes the installer from the administrator’s desktop folder in quiet mode (i.e., with no graphical user interface):

	install_ruxit:    
			command: "C:\Users\Administrator\Desktop\Dynatrace-OneAgent-Windows-1.69.18.exe" /quiet
  
  1. You don’t need to add extra commands following Dynatrace OneAgent installation. Amazon will restart IIS for you after you successfully upload all your application files.

Extend your config

In our examples the Dynatrace OneAgent download step is included in each procedure. While this is necessary for the first installation of Dynatrace OneAgent, this may substantially extend your application updates in the future by taking extra time to download Dynatrace OneAgent each time. You can improve your Beanstalk configuration by adding a check for an existing Dynatrace OneAgent installation and have your scripts download the agent only when Dynatrace OneAgent isn’t found on the system.

Have a look at the following configurations before creating your own scripts. Take care in formatting and escaping special characters. The Amazon interpreter is sensitive to syntax errors.

files:
  "C:\Users\Administrator\Desktop\installDynatrace.ps1":
    content: |
      if (!(Test-Path -path 'C:\Program Files (x86)
dynatraceoneagent\')) {

      #download installer file
      $url = "https://abcdefghij.live.dynatrace.com/installer/agent/windows/exe/latest/abc1234567890"
      $webclient = New-Object System.Net.WebClient
      $destination = "C:Users\Administrator\Desktop\"
      $filename = "Dynatrace-OneAgent-install.exe"
      $webclient.DownloadFile($url, $destination + $filename)

      #install Dynatrace OneAgent silently
      &'C:sers\Administrator\Desktop\Dynatrace-OneAgent-Windows-1.69.18.exe' /quiet

      }

commands:
  install_dynatrace_agent:
    command: powershell.exe -ExecutionPolicy ByPass -File C:Users\Administrator\Desktop\installDynatrace.ps1

Note: The configuration in the Windows example is Power Shell based. Before copying it, ensure that Power Shell is accessible on the target machine.

files:
  "/tmp/dynatraceElasticBeanstalk.sh":
    mode: "000755"
    owner: root
    group: root
    content: |
      #!/bin/bash
      if [ ! -d /opt/dynatrace/oneagent ]
      then
      wget -O /tmp/Dynatrace-OneAgent-Linux.sh https://abcdefghij.live.dynatrace.com/installer/agent/unix/latest/abc1234567890
      chmod 755 /tmp/Dynatrace-OneAgent-Linux.sh
      chown root:root /tmp/Dynatrace-OneAgent-Linux.sh
      /tmp/Dynatrace-OneAgent-Linux.sh
      service httpd restart
      fi

commands:
  install_dynatrace:
    command: /tmp/dynatraceElasticBeanstalk.sh