Monitor creation (REST)

Goal of this tutorial

To show how to create a monitor via REST API.

Scenario

In this tutorial, you will create a monitor and configure its tasks.

You can use any REST Client of your choice, or you can use built-in web service at https://<your_appmon_server>:8021/api-docs/current. This tutorial uses localhost as the AppMon server name. If you have the AppMon installed on a different host, replace it accordingly.

This tutorial uses the demo easyTravel System Profile. However, you can use any System Profile from your AppMon installation. In that case, replace easyTravel with the name of your System Profile.

Requirements

As a prerequisite, you should be familiar with Monitor configuration in the AppMon Client.

Detailed Steps

Step 1: Create default Monitor for a specific type

At first we'll create a new sampleMonitor of the Windows Performance Monitor type. The available Monitor types depend on your installed Monitor plug-ins, try to configure a Monitor through the AppMon client to view the available types in the Monitor Type Chooser.

  1. Go to https://localhost:8021/api-docs/current.
  2. Expand the Business Hours > PUT /profiles/{profileid}/monitors/{monitorname} section.
  3. In the profileid field, type easyTravel.
  4. In the monitorname field, type sampleMonitor.
  5. In the body field, put the following JSON:
    {
      "type": "Windows Performance Monitor"
    }
    
  6. Click Execute!.

2. View available Monitor task parameters

Monitors can have any number of task parameters, which are defined in the respective Monitor plug-in. To get an overview over the supported parameters for the specific Monitor type used, you can query the details of the newly created Monitor. Any properties which need to be further adapted can be updated in the next steps.

  1. Go to https://localhost:8021/api-docs/current.
  2. Expand the Business Hours > GET /profiles/{profileid}/monitors/{monitorname} section.
  3. In the profileid field, type easyTravel.
  4. In the monitorname field, type sampleMonitor.
  5. Click Execute!.

3. Update task parameters and execution target

Now we need to update parameters of the monitor. We will you use the same endpoint as was used for the creation of the new Monitor. This example sets the execution target to a specific Collector, schedule the Monitor task to run periodically, and change some of the task parameters. The Collector has to be specified in the format collectorname@collectorhost. You can view the available execution targets in the expected format in the AppMon Client if you have any doubts, go to Monitor configuration, switch to the Schedule tab, and check out the Execute on list.

Note that you can't modify the type of a Monitor.

  1. Go to https://localhost:8021/api-docs/current.
  2. Expand the Business Hours > PUT /profiles/{profileid}/monitors/{monitorname} section.
  3. In the profileid field, type easyTravel.
  4. In the monitorname field, type sampleMonitor.
  5. In the body field, put the following JSON:
    {
      "schedule": "Every 10 Minutes",
      "executiontarget": "Dynatrace Collector@<your-computer-name>",
      "taskparameters": {
        "host": "localhost",
        "password": "labpass",
        "auth": "false",
        "username": "administrator",
        "domain": "travel"
      }
    }
    
  6. Click Execute!.

4. Add target hosts

Monitors execute separately for each specified host, so at least one host must be configured for the Monitor to execute. Here we'll add your computer as a host for monitor to run on. The host expression is evaluated during runtime against the infrastructure configuration, which has to be adapted manually through the AppMon client if a yet unknown host should be monitored.

  1. Go to https://localhost:8021/api-docs/current.
  2. Expand the Business Hours > POST /profiles/{profileid}/monitors/{monitorname}/hosts section.
  3. In the profileid field, type easyTravel.
  4. In the monitorname field, type sampleMonitor.
  5. In the body field, put the following JSON:
    {
      "hostintersection": [
        {
          "type": "host",
          "expression": "<your-computer-name>"
        }
      ]
    }
    
  6. Click Execute!.