Prerequisites for installing S247DataExporter and Python agent in Docker

Prerequisites and installation of S247DataExporter and Python agent in a Docker container

Step 1: Check prerequisites

  1. Before installing the Python agent, verify that all prerequisites are met.
  2. To install the required system utilities for the S247DataExporter in your Docker container, add the following command to your Dockerfile:
  1. RUN apt-get update && apt-get install -y wget unzip procps curl

Step 2: Set agent configuration via environment variables

Configure the Python agent and the S247DataExporter using the following environment variables in your Dockerfile:
  1. # Mandatory
  2. ENV S247_LICENSE_KEY="Your Site24x7 device key"
  3. ENV APM_APP_NAME="Your application name"

  4. # Optional
  5. ENV AGENT_STATUS_PORT=20021
  6. ENV AGENT_DATA_PORT=20022
Where:
  1. S247_LICENSE_KEY: Your unique Site24x7 device key used to authenticate and link the agent with your account.
  2. APM_APP_NAME: A custom name for your application monitor as it will appear in the Site24x7 portal.
  3. AGENT_STATUS_PORT (optional): A port for agent status checks. The default value is 20021.
  4. AGENT_DATA_PORT (optional): A port used for internal agent communication and data handling. The default value is 20022.

Step 3: Install the S247DataExporter

Add the following commands to your Dockerfile to download and install the S247DataExporter:
  1.  RUN wget -O InstallDataExporter.sh https://staticdownloads.site24x7.com/apminsight/S247DataExporter/linux/InstallDataExporter.sh
  2.  RUN sh InstallDataExporter.sh -root -nsvc
If the Docker container is running as a user other than root, you need to provide permission for that user to run the exporter:
  1. chmod -R 777 /opt/S247DataExporter

Step 4: Install the Python agent

Install the APM Insight Python agent using pip:
  1. RUN pip3 install -U apminsight

Step 5: Start your application with the Python agent and the exporter

Method 1: Modify the CMD directly in the Dockerfile

In this method, you update the Dockerfile's CMD to perform the following steps:
  1. Start the S247DataExporter service.
  2. Launch your Python application using the apminsight-run command, which enables APM Insight monitoring.
            For example, if your original CMD was:
  1.             CMD ["gunicorn", "-w", "4", "app:wsgi"]
            You would modify it to:
  1. CMD ["sh", "-c", "/opt/S247DataExporter/bin/service.sh start && apminsight-run gunicorn -w 4 app:wsgi"]
This ensures both the S247DataExporter and Python agent are started automatically when the container launches.

Method 2: Use a custom entrypoint script

Create a script (example-entrypoint.sh) and copy it into the container:

example-entrypoint.sh
  1. #!/bin/sh
  2. # Start the S247DataExporter service
  3. sh /opt/S247DataExporter/bin/service.sh start

  4. # Start your Python application using apminsight-run
  5. apminsight-run <your app start command>
  1. Replace <your app start command> with the actual command to run your Python app: gunicorn -w 4 app:wsgi
  2. This script is then copied into the container and used as the Docker entrypoint.
In your Dockerfile:
  1. COPY ./example-entrypoint.sh /example-entrypoint.sh
  2. ENTRYPOINT [ "sh", "/example-entrypoint.sh" ]

    • Related Articles

    • Validating sender email using DKIM authentication

      What is DKIM? DomainKeys Identified Mail (DKIM) is an advanced authentication method used widely by email service providers to verify the email from the point of its origin by validating the email sender. It allows the email senders to authenticate ...