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

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

Overview
      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 Same Container).

1. Download the Required Components
  1. APM Insight Python Agent:
    Download python agent 
    (Extract to get the apm_insight_agent_python directory)
  2. 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
  1.       Place the extracted AppManagerDataExporter_amd64 directory in your project root.
  2.       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). 
           a). Include Data-Exporter and Agent in docker image
    1. # Copy exporter directory
    2. COPY AppManagerDataExporter_amd64/ /opt/AppManagerDataExporter/

    3. # Copy agent directory
    4. COPY apm_insight_agent_python/ /opt/apm_insight_agent_python/

    5. # Switch to agent directory and Install agent Python package
    6. WORKDIR /opt/apm_insight_agent_python/agent
    7. RUN pip install .
            b). 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.
                  How to do it?
      1. The exporter binary should be started in the background.
      2. The agent should wrap your app’s startup command (using apminsight-run).
        Please find the example command to include in your dockerfile below.
        1. # Entrypoint: Start exporter and agent with your app
        2. CMD ["sh", "-c", "/opt/AppManagerDataExporter/AppManagerDataExporter/bin/AppManagerDataExporter run & apminsight-run python app.py"]
/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, app name, and APM server details as environment variables in your Dockerfile or deployment environment
  1. ENV S247_LICENSE_KEY="{APM_LICENSE_KEY}"
  2. ENV APM_APP_NAME="{APPLICATION_NAME}"
  3. ENV APM_HOST="{APM_SERVER_HOST}"
  4. ENV APM_PORT="{APM_SERVER_PORT}"
5. Build and Run Your Docker Image

6. Verify Monitor Creation
  1. Check your APM Insight dashboard for data from your app.
  2. Check container logs for exporter and agent startup messages.

Please find attached the sample dockerfile with changes for exporter and agent included 


                  New to ADSelfService Plus?

                    • Related Articles

                    • How to add an APM Insight Python agent in Kubernetes via InitContainers?

                      Adding the APM Insight Python agent via init containers in Kubernetes enables the seamless integration of performance monitoring for Python applications, ensuring efficient tracking and analysis of application behavior within the Kubernetes ...
                    • Adding APM Insight Java agent in a Kubernetes environment

                      There are three methods for installing the APM Insight Java agent in a Kubernetes environment: Using Dockerfile Using InitContainers Using Persistent Volumes Prerequisites Download the latest APM Insight Java agent ZIP file. Extract the ZIP file and ...
                    • How to rename an existing APM - Java agent application's monitor?

                      In Applications Manager's APM(Application Performance Monitoring) doesn't support renaming applications/monitors from the web client. However, the application name of an existing application instance can be renamed in the `apminsight.conf` file and ...
                    • Self monitor Applications Manager using APM Insight Java Agent

                      Applications Manager is built with Java, hence we can monitor it using APM Insight Java Agent to measure it's performance continuously, which can be very much useful. Setting up APM Insight Java Agent Follow the below steps to download and set up the ...
                    • Uninstrumented Block of Code - APM Insight

                      In the traces tab --> Slowest Method Calls and Count we show if you find Un-instrumented block of code the reason is as follows: Basically, What is un-instrumented block of code in APM Insight? By default, APM Insight agent monitors known frameworks ...