This guide explains how to enable APM Insight monitoring for your Python application running in Docker, using the APM Insight Python agent and Data Exporter (in the same container).
# Copy exporter directory COPY AppManagerDataExporter_amd64/ /opt/AppManagerDataExporter/ # Copy agent directory COPY apm_insight_agent_python/ /opt/apm_insight_agent_python/ # Switch to agent directory and install agent Python package WORKDIR /opt/apm_insight_agent_python/agent RUN pip install .
apminsight-run).Example command to include in your Dockerfile:
# Entrypoint: Start exporter and agent with your app CMD ["sh", "-c", "/opt/AppManagerDataExporter/AppManagerDataExporter/bin/AppManagerDataExporter run \ & apminsight-run python app.py"]
ENV S247_LICENSE_KEY="{APM_LICENSE_KEY}"
ENV APM_APP_NAME="{APPLICATION_NAME}"
ENV APM_HOST="{APM_SERVER_HOST}"
ENV APM_PORT="{APM_SERVER_PORT}"Below is the contents of the sample Dockerfile with changes for exporter and agent included:
FROM python:3.10-slim AS base
# Application and APM Insight configuration
ENV S247_LICENSE_KEY="<YOUR_LICENSE_KEY>"
ENV APM_APP_NAME="<YOUR_APP_NAME>"
ENV APM_HOST="<YOUR_APM_SERVER_HOST>"
ENV APM_PORT="8443"
WORKDIR /opt
RUN apt-get update && \
apt-get install -y --no-install-recommends curl && \
rm -rf /var/lib/apt/lists/*
# Copy APM Data Exporter
COPY AppManagerDataExporter_amd64/ /opt/AppManagerDataExporter/
# Copy APM Insight Python Agent
COPY apm_insight_agent_python/ /opt/apm_insight_agent_python/
COPY . /opt/app/
# Install APM Insight Python Agent
WORKDIR /opt/apm_insight_agent_python/agent
RUN pip install .
WORKDIR /opt/app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
EXPOSE 5000
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD curl -f http://localhost:5000/ || exit 1
# Start both the APM Data Exporter and the Python application with apminsight-run as the entrypoint
CMD ["sh", "-c", "/opt/AppManagerDataExporter/AppManagerDataExporter/bin/AppManagerDataExporter run \
& apminsight-run python app.py"]
It allows us to track crucial metrics such as response times, resource utilization, error rates, and transaction performance. The real-time monitoring alerts promptly notify us of any issues or anomalies, enabling us to take immediate action.
Reviewer Role: Research and Development