pip install required.Refer: APM Insight Python Agent – Official Installation Help
| Requirement | Details | How to Verify |
|---|---|---|
| Python 3.5+ | Python 2.x is not supported | python --version |
| Correct Architecture ZIP | amd64 / arm64 / 386 — must match server architecture | Check OS system information |
| AppManager Data Exporter | Must be installed and running (ports 20021 & 20022) | Confirm ports 20021 and 20022 are listening |
| Read/Write Permissions | Application user must have access to the agent directory | Verify directory permissions for the app user |
Step 1 — Download & transfer the agent ZIP
From Applications Manager: APM → Add New Monitor → Python → Download Agent
Transfer apm_insight_agent_python.zip to the target server using any available method (SCP, shared folder, USB, etc.) and place it in a working directory.
Example: <AGENT_HOME>/ (e.g., /opt/apminsight/ or C:\apminsight\)
Step 2 — Verify checksum (recommended)
Generate the SHA256 hash of the downloaded ZIP and compare it with the .sha256 file bundled alongside the agent. Both values must match to confirm file integrity.
For detailed checksum validation steps, refer: APM Insight Python Agent – Checksum Validation
Step 3 — Extract the agent
Create a directory (e.g., <AGENT_HOME>) and extract the ZIP contents into a subfolder named apminsight_agent.
Use your OS's built-in extraction tool — right-click → Extract, or a command-line utility:
unzip apm_insight_agent_python.zip -d apminsight_agent # Linux / macOS
Expand-Archive apm_insight_agent_python.zip -DestinationPath apminsight_agent # Windows PowerShell
After extraction, the directory structure should look like:
<AGENT_HOME>/apminsight_agent/
wheels/
apminsight/
bootstrap/
sitecustomize.py ← agent bootstrap entry point
...
...
Step 4 — Set environment variables and start your application
Set the following environment variables before starting your Python application. Use the appropriate syntax for your OS/shell:
| Variable | Value |
|---|---|
PYTHONPATH |
<AGENT_HOME>/apminsight_agent/wheels/apminsight/bootstrap + <AGENT_HOME>/apminsight_agent/wheelsuse : as separator on Linux/macOS, ; on Windows |
S247_LICENSE_KEY |
Your license key from APM → Agent Download page |
APM_APP_NAME |
Application display name for the APM monitor |
APM_LOGS_DIR (optional) |
Custom directory for agent logs (default: application working directory) |
APM_EXPORTER_HOST (optional) |
Hostname or container name where the Data Exporter is running (default: localhost). Set this when the Data Exporter runs on a different machine, server, or Docker container. |
APM_EXPORTER_STATUS_PORT (optional) |
Data Exporter status port (default: 20021). Set only if the default port has been changed. |
APM_EXPORTER_DATA_PORT (optional) |
Data Exporter data port (default: 20022). Set only if the default port has been changed. |
Example (Linux / macOS — Bash):
export PYTHONPATH="<AGENT_HOME>/apminsight_agent/wheels/apminsight/bootstrap:<AGENT_HOME>/apminsight_agent/wheels"
export S247_LICENSE_KEY="<YOUR_LICENSE_KEY>"
export APM_APP_NAME="<YOUR_APP_NAME>"
# (Optional) If Data Exporter is on a different host or non-default ports
export APM_EXPORTER_HOST="localhost" # default: localhost
export APM_EXPORTER_STATUS_PORT="20021" # default: 20021
export APM_EXPORTER_DATA_PORT="20022" # default: 20022
python app.py
Example (Windows — Command Prompt):
set PYTHONPATH="<AGENT_HOME>\apminsight_agent\wheels\apminsight\bootstrap;<AGENT_HOME>\apminsight_agent\wheels"
set S247_LICENSE_KEY="<YOUR_LICENSE_KEY>"
set APM_APP_NAME="<YOUR_APP_NAME>"
REM (Optional) If Data Exporter is on a different host or non-default ports
set APM_EXPORTER_HOST="localhost" REM default: localhost
set APM_EXPORTER_STATUS_PORT="20021" REM default: 20021
set APM_EXPORTER_DATA_PORT="20022" REM default: 20022
python app.py
sitecustomize.py from PYTHONPATH. The agent's bootstrap sitecustomize.py initialises the APM Insight agent automatically — no code changes needed.
Environment="VARIABLE=value" entries in the [Service] section of your unit file-e flags or an env_file| Variable | Required | Description | Default |
|---|---|---|---|
PYTHONPATH |
Yes | Must include bootstrap/ and wheels/ paths |
— |
S247_LICENSE_KEY |
Yes | License key / device key from APM tab | — |
APM_APP_NAME |
Yes | Monitor display name in APM tab | — |
APM_LOGS_DIR |
No | Custom agent log directory | App working dir |
APM_EXPORTER_HOST |
No | Data Exporter hostname (if not on same host) | localhost |
APM_EXPORTER_STATUS_PORT |
No | Exporter status port | 20021 |
APM_EXPORTER_DATA_PORT |
No | Exporter data port | 20022 |
1. Check startup output — you should see:
APM Insight agent initialized successfully
2. Check agent log
Open the log file at apminsightdata/logs/apminsight-agent-log.txt (relative to the application working directory).
Look for lines like INFO flask instrumented, INFO werkzeug.serving instrumented, etc.
3. Verify agent version (offline agent won’t appear in pip list)
python -c "import apminsight; print(apminsight.name, apminsight.version)"| Issue | Cause | Resolution |
|---|---|---|
ModuleNotFoundError: No module named 'apminsight' |
PYTHONPATH missing wheels/ directory |
Ensure PYTHONPATH includes <AGENT_HOME>/apminsight_agent/wheels |
Socket Connection failed |
Data Exporter not running on ports 20021/20022 | Start the AppManager Data Exporter service and confirm ports 20021 & 20022 are listening |
Please configure a valid license key |
S247_LICENSE_KEY not set or invalid |
Set the S247_LICENSE_KEY environment variable with the correct license key from the APM tab |
Agent not in pip list |
Expected — offline agent is loaded via PYTHONPATH, not pip | Use python -c "import apminsight; print(apminsight.version)" to verify |
| Agent loads when not intended | PYTHONPATH persists in shell/profile | Remove or unset the PYTHONPATH variable from the current session and any startup profiles |
apminsightdata/logs/apminsight-agent-log.txtapminsightdata/apminsight_info.iniPYTHONPATH value, Python version, and OS details