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
How do I monitor an Oracle database hosted in a Docker container in the same machine?
To monitor your Oracle Database hosted in a Docker container, follow these steps: Log in to Site24x7 and install the Site24x7 Linux monitoring agent. Execute the following command in your terminal and enter your Oracle Database instance's username ...
Where are Site24x7's physical data storage regions located?
Site24x7's integrated data centers are located in the US, European Union, India, China, Australia, and Japan. All Site24x7 customer-related data are stored in these physical storage regions. Data Center Primary Data Center Disaster Recovery Data ...
APM Insight integration for Next.js in Kubernetes
To integrate the Site24x7 APM Insight Next.js agent into your Kubernetes application using initContainers with the prebuilt agent image, follow the steps below: Prerequisites A Next.js application container image The Site24x7 APM Insight license key ...
Troubleshoot the "pymysql module not found" error when installing the MySQL plugin
If you're encountering the pymysql module not found error, it likely means that the pymysql Python library is not installed on the server. pymysql is a Python package that provides a way to interact with MySQL databases using Python code and is used ...
Troubleshoot the Error 404 and Error 99 for RabbitMQ
When installing the RabbitMQ plugin, you may encounter the following errors: HTTP Error 404: Not Found: This error usually occurs when Site24x7's RabbitMQ monitoring plugin attempts to access the /api/overview page of RabbitMQ, but the resource ...