Prerequisites and installation of S247DataExporter and Python agent in a Docker container
Step 1: Check prerequisites
- Before installing the Python agent, verify that all prerequisites are met.
- To install the required system utilities for the S247DataExporter in your Docker container, add the following command to your Dockerfile:
- 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:
- # Mandatory
- ENV S247_LICENSE_KEY="Your Site24x7 device key"
- ENV APM_APP_NAME="Your application name"
- # Optional
- ENV AGENT_STATUS_PORT=20021
- ENV AGENT_DATA_PORT=20022
Where:
- S247_LICENSE_KEY: Your unique Site24x7 device key used to authenticate and link the agent with your account.
- APM_APP_NAME: A custom name for your application monitor as it will appear in the Site24x7 portal.
- AGENT_STATUS_PORT (optional): A port for agent status checks. The default value is 20021.
- 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:
If the Docker container is running as a user other than root, you need to provide permission for that user to run the exporter:
- chmod -R 777 /opt/S247DataExporter
Step 4: Install the Python agent
Install the APM Insight Python agent using pip:
- 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:
- Start the S247DataExporter service.
- Launch your Python application using the apminsight-run command, which enables APM Insight monitoring.
For example, if your original CMD was:
- CMD ["gunicorn", "-w", "4", "app:wsgi"]
You would modify it to:
- 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
- #!/bin/sh
- # Start the S247DataExporter service
- sh /opt/S247DataExporter/bin/service.sh start
- # Start your Python application using apminsight-run
- apminsight-run <your app start command>
- Replace <your app start command> with the actual command to run your Python app: gunicorn -w 4 app:wsgi
- This script is then copied into the container and used as the Docker entrypoint.
In your Dockerfile:
- COPY ./example-entrypoint.sh /example-entrypoint.sh
- 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 ...
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. ...
How to deploy the Site24x7 PHP agent in a Kubernetes environment?
For PHP version 7.0 and above The PHP agent (PHP version 7.0 and above) can be deployed in a Kubernetes environment using any of the following methods. You can also keep the license keys in a configmap to avoid using them in the deployment files. ...
List of log files generated and maintained by the Site24x7 server monitoring agent
Here is the list of log files generated by the Linux and Windows server monitoring agent. The log files are stored in the same directory where the agent source file is installed. By default they are at: For Linux : ...