Schedule demo

APM Insight Python Agent & Data Exporter Onboarding Docker Guide (Same Container)


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).

  1. Download the required components:
    • APM Insight Python Agent:Download Python agent
      (Extract to get the apm_insight_agent_python directory)
    • AppManager Data Exporter:Download Data Exporter
      (Download respective archive and extract to get the AppManagerDataExporter directory)
      Example: For Linux, download and extract AppManagerDataExporter_amd64
  2. Add the agent and Data Exporter to your project.
    • Place the extracted AppManagerDataExporter_amd64 directory in your project root.
    • Place the extracted apm_insight_agent_python/ directory in your project root.
  3. Update your Dockerfile: Add the following steps to your Dockerfile (after your existing Python/app setup).
    • Include Data Exporter and Agent in Docker image.
      # 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 .
    • Start the Exporter and Agent with your app: To ensure both the exporter and the APM Insight agent are running, you need to start both when the container runs. This is typically done in the Dockerfile’s CMD or ENTRYPOINT. To do so:
      • The exporter binary should be started in the background.
      • The agent should wrap your app’s startup command (using 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"]
      where,
      • /opt/AppManagerDataExporter/AppManagerDataExporter/bin/AppManagerDataExporter run → starts the exporter in the background.
      • apminsight-run python app.py → starts your Python app with the APM Insight agent enabled.
  4. Set Environment Variables: Set your license key, application name, and Applications Manager server details as environment variables in your Dockerfile or deployment environment.
    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}"
  5. Build and run your Docker image: Build the updated Docker image and run the container with the configured environment variables.
  6. Verify monitor creation:
    • Check your APM Insight dashboard for data from your application.
    • Check container logs for exporter and agent startup messages.

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"]

Loved by customers all over the world

"Standout Tool With Extensive Monitoring Capabilities"

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

carlos-rivero
"I like Applications Manager because it helps us to detect issues present in our servers and SQL databases."
Carlos Rivero

Tech Support Manager, Lexmark

Trusted by over 6000+ businesses globally