Custom Extension 2.0 Development

The following page contains development steps for creating a custom python extension 2.0 in Visual Studio Code and deploying to Dynatrace.

✅ Prerequisites

  1. Python Installation
    • Python 3.10 or later is installed. (YT video)
  2. VS Code Installation
  3. Certificate and Access Token
    1. Contact the Enterprise Monitoring team for
      1. Developer certificate PEM.
      2. Extension Development API token 

Setup and Configuration

🧰 Install Dynatrace Extension Add-On 

  1. You can find Dynatrace Extensions in the Visual Studio Code marketplace. Install it from there or via the VS Code extension search.

🧰 Install Dynatrace Extension SDK CLI via PIP

  1. From command prompt execute the following command

    pip install dt-extensions-sdk[cli]

🧰 Save Developer Certificate PEM file locally

From the prerequisites you should have received a Developer PEM file (developer_netid.pem) from the Enterprise Monitoring team.

  1. Save the developer_netid.pem file on your localmachine and record the path

🧰 Connect VS Code to your Dynatrace Environemnt

Note: The Dynatrace environment is the URL you use to access your Dynatrace instance.

  1. Navigate to the Dynatrace Extensions in VS Code, then select the Add environment button.
    1. NOTE: If this is a second environment being added then the button will not exist and you use the ‘+’ button on the top right. 
  2. Provide the base URL for your environment following this structure: https://<Id>.apps.dynatrace.com 
    1. NOTE: This is the same as the URL you use to access your Dynatrace instance. Contact Enterprise Monitoring team if you require assistance.
    2. NOTE: It’s best practice to test in the POC environment. Contact Enterprise Monitoring team if you do not know the POC tenant URL
  3. Provide the ‘Extension Developmetn API Token’ from the prerequisites phase of this document.
    1. NOTE: If you do not have the ‘Extension Development API Token’ you will need to contact Enterprise Monitoring team to generate one for you.
  4. Set this as your current environment.

🧰 Initialization your VS Code Workspace 

  1. Open an empty folder in Visual Studio Code
  2. Open command pallet and run 

>Dynatrace extensions: Initialize workspace

  1. Choose the second to latest available schema version (e.g. 1.328)
  2. Download the schema
  3. From the above step ‘Save Developer Certificate PEM file locally’, provide the path to your developer certificate.
  4. Select Python Extension 2.0 when asked “What type of project are you starting?”
  5. Name Your Module
    1. No spaces or capital letters.
    2. Name must be under 50 characters.

🗂 File Setup & Configuration

Each bullet below corresponds to a file that was created when installing dt-extensions-sdk. See Fig.1 for example

🔹 setup.py file - add necessary libraries Additional details

This is a standard Python setup file that is used to package the extension and is used by the extension execution controller to install the extension on the ActiveGate or OneAgent along with required dependencies.

  • In the install_requires field, add all required libraries (dt-extensions-sdk is added by default).
  • Example:
ext 2.0 installation example

🔹 activation.json Additional details

This is a config file that can be used for local testing when extension instance is launched using the Run contain. It must contain all the mandatory fields as defined in the activationSchema.json. During development, the SDK reads the configuration values from this file. When extension is deployed to the Dynatrace environment and monitoring configuration is created, then the environment provides an individual activation config for each instance of the extension.

“endpoints”: [

  {

    “api_token”: “”,  //provided by Enterprise Monitoring Team

    “cron”: “”  //how often you want the extension to run

  • *It is recommended to use Yale’s custom cron. Contact the Enterprise Monitoring team for details

🔹 activationSchema.json Additional details

This is the schema file that describes the structure of the monitoring configuration

  • Update the module name inside this file to match your actual module.
     

🔹 extension.yaml Additional details

This is the main configuration file of the extension. In this file, you can examine the construction of a Python extension.
It declares the Python module name, the minimum Python version, and the activation schema for a remote ActiveGate or local OneAgent extension.

  • In the activation: section, remove any local: path.
  • Make sure to increment the module version field if the current version has been deployed, and is trying to modify

🔹 {your extension name} file

  • This will contain the _init_.py and _main_.py (where you will configure code)
  • This is “my_first_extension” in Fig.1
files created

Fig.1 Example Files Created

extension structure

Extension Structure

The basic structure of an extension created

Additional details

Code Migration

Once complete, testing can be done in the POC environment. Please contact the Enterprise Monitoring team stating that you have created a custom ActiveGate Extension 2.0 and are ready to test. We will then go through the process with you. 

🚀 Publish your Extension

  1. Press the F1 key and choose the Dynatrace extensions: Build command. The workflow will build your extension, creating a package inside your dist folder.
  2. When prompted about uploading your extension to Dynatrace, choose Yes.
  3. When prompted about activating this extension version, choose Yes

Congratulations. You created, built, uploaded, and activated your first ActiveGate Extension 2.0. You can view this in the Dynatrace UI by navigating to Extensions.