Skip to content

Python Agent

Last update October 29, 2018

CA APM for Python allows enterprises running Python applications to identify and resolve performance issues. APM for Python integrates performance metrics into CA APM for Intelligent analytics, alerting, and visibility on a single dashboard.

CA APM for Python is based on a multi-process agent architecture that consists of two components: the Python Agent and the Infrastructure Agent.
The Python Agent is a lightweight probe that collects the required data from your Python applications. The probe sends the data to the Infrastructure Agent for processing and analysis. You view the processed and analyzed data in Application Performance Management. This architecture helps CA APM to have little effect on your Python application performance.

This architecture provides these benefits:

  • Lightweight probes are dedicated solely to raw data collection.
  • The Infrastructure Agent manages configuration, data collection, and processing outside of the monitored application to reduce overhead.

You must install the Infrastructure Agent before you install the Python Agent. You can configure the installation so that the Infrastructure Agent and the Python Agent are not installed on the same host.

Supportability Requirement and Information

The Python Agent requires Python 2.7.

The Python Agent is only supported on Linux.  

Here are the supported frameworks and databases:

Install the CA APM Infrastructure Agent and Python Agent

The CA APM Infrastructure Agent (Infrastructure Agent) is a master package containing CA APM extensions and a JRE. You must install the Infrastructure Agent before you install the Python agent. The Python Agent has two main components: an Infrastructure agent extension, which provides data to the Infrastructure Agent and the Python probe, which collects the data.

Download the Infrastructure Agent Software

After you get access to CA Digital Experience Insights, you download and extract the Infrastructure Agent containing the Python agent.

Follow these steps:

  1. Sign up for a free trial or purchase an Essentials or Enterprise Edition of CA Digital Experience Insights.
    After registration, you receive your credentials and a tenant ID.
  2. Log in to CA Digital Experience Insights. 
  3. Click Open on the Application Performance Management box.
    You now download the agent package containing the Python Probe Agent.

  4. Click Download Agent at the top of any page.

    Note: If you already connected one agent, you can only access the  Download Agent button by clicking  Agents in the left pane, under  Settings.


  5. On the Select Agent to Download page, select UNIX/Linux as your operating system.

  6. Click on Python under the Applications category.
    CA Digital Experience Insights downloads the python_v<number>.tar file to your Linux computer.

Install the Infrastructure Agent

  1. Run this command to extract the contents of the Infrastructure-Agent-<version>-<OS> package file to the desired installation location:

    tar xf python_v<number>.tar

  2. Run this command to start the Infrastructure Agent:

     ./apmia-ca-installer.sh install

  3. (Optional) Use more Infrastructure Agent-related commands.

  4. (Optional) Review the installation log.

    1. Navigate to apmia/apmia_install.log.
    2. Review the log for error messages or troubleshooting help.

Log Files

You can review the Infrastructure Agent logs in the <Infrastructure_Agent_Home>/logs directory.

These log files are in the logs directory:

  • IntroscopeAgent.log
  • APMIAgentConsole.log

You can review the Python agent installation log in the apmia/apmia_install.log directory.

You can review the Python agent logs in the ca_apm_logs/python_agent.log. You can configure the log file location.

Install the Python Agent

You use the Python pip installation tool to download and install the CA APM Python agent software from the Python Package Index (PyPI) repository.

Follow these steps:

  1. (Optional): If you already have pip, ensure that the installed pip version works with the Python interpreter that runs your Python application. 

  2. A typical Linux operating system uses at least two Python interpreters to run the system and applications. 

    1.  If you run a Python interpreter version that is not 2.7, you can encounter problems. If you are not sure which Python interpreter version to which your pip is mapped, uninstall pip. Perform the uninstall process using the same application that you used to install pip.

    2. Run the following commands to download and install pip using the appropriate Python 2.7.x interpreter:

      wget https://bootstrap.pypa.io/get-pip.py
      <python interpreter> get-pip.py
  3. Run the following command to Install the Python agent:
    Some Linux distributions and versions do not put the binaries that the Python Agent provides in PATH locations. Using the sudo command ensures that the binaries are installed into a globally available PATH location.

    sudo pip install ca-apm-agent
  4. (Optional) When you manage multiple Python projects and packages using virtualenv, you can install the Python agent using these installation instructions.

Configure the Python Agent

Follow these steps:

  1. Run this command to find the ca-apm-agent installation directory:

    pip show ca-apm-agent
  2. Navigate to the installation directory.
  3. Find the directives subdirectory, which contains the agent.profile and instrument.pbd files.
  4. Open the agent.profile in a text editor.

  5. Specify the values for the properties you want to configure:

    host
    This property specifies the host name of the Python Infrastructure Agent. 
    Default value: '127.0.0.1'
    Note: Requires managed application restart.

    port
    This property specifies the port number for the Python Infrastructure Agent.
    Default value: 5005
    Note: Requires managed application restart.

    app_name
    This property specifies the name of the Python application as you want it to appear in Application Performance Management.
    Default value: default
    Note: Requires managed application restart.

    log.handlers.file.filename
    This property specifies the log file name that the Python Agent creates. The agent creates the file in the directory from which you run the command to for the Python agent to start the Python application. Relative paths are allowed. Providing an absolute path overrides a relative path. The property assumes that it has the necessary permissions to create intermediary folders that do not exist.
    Default value: ca_apm_logs/python_agent.log
    Note: Requires managed application restart.

    log.loggers.python_agent.level
    This property specifies the level at which Python Agent information is logged in the log file. Change to DEBUG for detailed logs if necessary.
    Default value: INFO
    Note: Requires managed application restart.

  6. Save and close the file.

  7. Restart the managed application

Start the Python Agent

Using gunicorn as an example, if you currently start your Python application using this command:

gunicorn -w 2 -b :8000 myproject.wsgi 

You start the application with the Python Agent using this command:

ca-apm-runpy gunicorn -w 2 -b :8000 myproject.wsgi 

Monitor Python Agent Metrics in Map View

You view the applications metrics using the Components view and other views in Application Performance Management.

  1. Log in to CA Digital Experience Insights. 
  2. Click Open on the Application Performance Management box.
    Application Performance Management home page appears
  3. In the left navigation pane, click the Map icon.
  4. Select Application Layer and Default Overview from the drop-down list on the left side of the screen.
  5. Examine the monitored Python components.
  6. View the Python agent   metrics.
    1. On the map, click a component.
      The Components View opens to the right of the map.
    2. Click the Generic Frontend or Agent tab to view the data.
      The tabs display the metrics.
    3. Scroll down the data to examine the Python agent metrics to determine if any of the values indicate poor performance. 

    Python application in Application Performance Management map

Monitor Python Performance

Follow these steps:

  1. Monitor performance using the Experience View.

  2. View the Python metrics.
    1. In Application Performance Management, click an item of interest such as an individual metric from the details panel.
      The metric appears for the monitored Python process.
    2. Navigate the nodes to investigate the BlamePoint metrics.
    3. Click a metric and view the performance information.
Was this helpful?

Please log in to post comments.