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

    • Prerequisites for Python agent installation

      For a smooth Python agent installation, ensure that you've fulfilled the following prerequisites: The environment should support Python version 3.7 or above. The application should be built on any of the supported frameworks. The application user ...
    • Adding a Python agent to a Python application service

      To monitor a Python application using Site24x7 APM, you need to integrate the Site24x7 Python agent as a system service. Follow the steps below to install the S24x7DataExporter, add the agent to a custom directory, and configure the environment. ...
    • Prerequisites for Java agent installation

      For a smooth Java agent installation, ensure that you've fulfilled the following prerequisites. The environment should have Java version 8 or above installed. The application user should have full permissions over the agent directory. The server ...
    • Prerequisites for Node.js agent installation

      For a smooth Node.js agent installation, ensure that you've fulfilled the following prerequisites. The environment should have node version 16.20.2 or above installed. The application user should have full permission to access the agent directory. ...
    • Troubleshooting tips for monitoring Go applications in Docker

      If you encounter issues with Go application monitoring in Docker, follow these troubleshooting steps to identify and resolve common problems quickly. The container fails to start Symptom: The APM container terminates immediately after starting. ...