Skip to main content

Install Python agent

Using the Agent Wizard is the simplest way to deploy a new agent. Additional methods are also available, including with PyPI, in a container, or in a pipeline.

Before you begin a Python agent installation

Make sure you have everything you need before you start.

  • The agent will need to be able to reach your Contrast instance. It can be a local/on-premise instance or a hosted instance. A proxy can be configured if the environment has limited network access.

  • It must use supported versions, frameworks, and tools.

  • Understand the order of precedence.

  • You will also need access to a command line interface (with a chosen directory for downloading the agent) and your organization's instance of Contrast.

Start the Agent Wizard

To open the Agent Wizard:

  • In Northstar: From the left navigation, select Administration > Agent management, then select Add agent at the top of the view.

  • In Contrast: Use one of the following options:

    • From the header, select Add New, and then select the Application card.

    • From the header, select Administration > Agent Management, and then select Add agent at the top of the view.

Select the Python agent

In the Agent Wizard:

  1. Under Select an installation method, select Language-specific.

  2. Under Select a language, select Python.

Install and configure the agent

  1. Under Select application deployment method, select Install manually.

  2. Under Install agent, install the agent from PyPI using your preferred package manager, or add the contrast-agent package to your dependencies file, such as pyproject.toml or requirements.txt.

  3. Follow the instructions in the wizard to configure Python.

    The agent requires a connection token or an API configuration to communicate with Contrast. You can use a connection token (recommended) or you can download the configuration as a YAML file.

  4. Configure the Python agent.

  5. Start your application with the Contrast Runner.

    For example, for a WSGI application that is started with the following command:

    gunicorn myproject.wsgi:application
  6. Run the following command to add Contrast to this application:

    contrast-python-run -- gunicorn myproject.wsgi:application

    The double dash separator -- separates the runner command's arguments from ones that belong to the original command.

Verify the agent deployment

Interact with your application as you normally would. For example, interact with your application's web interface or send API commands.

  1. In the Agent Wizard, select View agent activity to verify that your agent appears in the agents list.

  2. Verify that you see the name of your application in the applications list.

    • In Northstar, select Applications from the left navigation.

    • In Contrast, select Applications from the header.

  3. Verify that you see the name of your local server in the servers list.

    • In Northstar, select Servers from the left navigation.

    • In Contrast, select Servers from the header.