Manage Configurations for UI-based integrations using the API

Configurations for UI-based integrations are stored in the moog_intdb database.

You manage these configurations using the Integrations API. The following example shows how to use the Integrations API to manage an installed Webhook integration. Specifically, the example shows how to:

  • Enable a capture log for the Webhook integration.

  • Start and stop the Webhook integration.

Your Moogsoft Enterprise user must have the Grazer role with the manage_integrations permission in order to manage the configuration using the API. The Grazer role only has the manage_integrations permission with a new install of Moogsoft Enterprise v8.x.

Enable a capture log for the Webhook integration

  1. In the Moogsoft Enterprise UI, go to Integrations > Installed Integrations and select the integration for which you want to enable the capture log.

  2. Note the integration ID from the URL:

    https://example.com/#/integrations/integration-details/<integration_ID>
  3. Run the following cURL command to extract the existing configuration. Substitute the username and password of the user authorised to use the Integrations API, and the integration ID.

    curl -u <username>:<password> \
    --insecure "https://localhost/integrations/api/v1/integrations/<integration_ID>" 2>/dev/null

    This returns JSON similar to the following:

    {
    	"id": 6,
    	"name": "Webhook1",
    	"type_id": "Webhook",
    	"version": "1.14",
    	"config": {
    		"config": {
    			"filter": {
    				"modules": [],
    				"presend": "WebhookLam-SolutionPak.js",
    		                "dependencies": {
    					"lambot": ["LamBot.js", "WebhookLam-SolutionPak.js"],
    					"contrib": []
    				}
    			},
    			"mapping": {
    				"rules": [...],
    				"catchAll": "overflow",
    				"lambotOverridden": []
    			},
    			"monitor": {
    				"name": "Webhook Lam Monitor",
    				"port": "$config#port()",
    				"class": "CRestMonitor",
    				"use_ssl": false,
    				"num_threads": 5,
    				"accept_all_json": true,
    				"basic_auth_static": {
    					"password": "test",
    					"username": "test"				},				"rest_response_mode": "on_receipt",
    				"authentication_type": "basic_auth_static",
    				"rpc_response_timeout": 20,
    				"lists_contain_multiple_events": true
    			},
    			"constants": {
    				"severity": {
    					...
    				}
    			},
    			"conversions": {
    				...
    			}
    		},
    		"type_id": "Webhook",
    		"version": "1.14",
    		"category": "monitoring",
    		"ha_profile": "active_active",
    		"description": "A webhook integration to allow events to be sent via generic REST and processed by Moogsoft AIOps.",
    		"display_name": "Webhook"
    	},
    	"inputs": [...],
    	"readonly": [...]
    }
    
  4. Edit the returned JSON by adding "agent":{"log":"/usr/share/moogsoft/log/data-capture/mycapturefile.log"} to the config.config section. For example:

    ...
      "config": {
        "config": {
          "agent":{"log":"/usr/share/moogsoft/log/data-capture/mycapturefile.log"},
          "filter": {
    ...
  5. Run the following cURL command to update the integration configuration:

    curl -X PUT -u <username>:<password> -k -v --insecure "<host>/integrations/api/v1/integrations/6"  -H "Content-Type: application/json" -d'
    {
      "config": {
        "config": {
          "agent": {
            "log": "/usr/share/moogsoft/log/data-capture/mycapturefile.log"
            },
            "filter": {
              "modules": [],
              "presend": "WebhookLam-SolutionPak.js",
              "dependencies": {
                "lambot": [
                  "LamBot.js",
                  "WebhookLam-SolutionPak.js"
                ],
                "contrib": []
              }
            },
            "mapping": {
              "rules": [{
                "name": "signature",
                "rule": "$source::$type"
              },
              {
                "name": "source_id",
                "rule": "$source_id"
              },
              {
                "name": "external_id",
                "rule": "$external_id"
              },
              {
                "name": "manager",
                "rule": "$manager"
              },
              {
                "name": "source",
                "rule": "$source"
              },
              {
                "name": "class",
                "rule": "$class"
              },
              {
                "name": "agent",
                "rule": "$LamInstanceName"
              },
              {
                "name": "agent_location",
                "rule": "$agent_location"
              },
              {
                "name": "type",
                "rule": "$type"
              },
              {
                "name": "severity",
                "rule": "$severity",
                "conversion": "sevConverter"
              },
              {
                "name": "description",
                "rule": "$description"
              },
              {
                "name": "agent_time",
                "rule": "$agent_time",
                "conversion": "stringToInt"
              }
            ],
            "catchAll": "overflow",
            "lambotOverridden": []
           },
           "monitor": {
             "name": "Webhook Lam Monitor",
             "port": "$config#port()",
             "class": "CRestMonitor",
             "use_ssl": false,
             "num_threads": 5,
             "accept_all_json": true,
             "basic_auth_static": {
               "password": "test",
               "username": "test"
             },
             "rest_response_mode": "on_receipt",
             "authentication_type": "basic_auth_static",
             "rpc_response_timeout": 20,
             "lists_contain_multiple_events": true
           },
             "constants": {
               "severity": {
                 "0": 0,
                 "1": 1,
                 "2": 2,
                 "3": 3,
                 "4": 4,
                 "5": 5,
                 "CLEAR": 0,
                 "MAJOR": 4,
                 "MINOR": 3,
                 "WARNING": 2,
                 "CRITICAL": 5,
                 "INDETERMINATE": 1,
                 "moog_lookup_default": 1
               }
             },
             "conversions": {
               "stringToInt": {
                 "input": "STRING",
                 "output": "INTEGER"
               },
               "sevConverter": {
                 "input": "STRING",
                 "lookup": "severity",
                 "output": "INTEGER"
               }
             }
           },
           "type_id": "Webhook",
           "version": "1.14",
           "category": "monitoring",
           "ha_profile": "active_active",
           "description": "A webhook integration to allow events to be sent via generic REST and processed by Moogsoft AIOps.",
           "display_name": "Webhook"
         },
         "inputs": [{
           "key": "username",
           "value": "test"
         },
         {
           "key": "password",
           "value": "test"
         }
       ]
     }'
    
  6. Run the following cURL command to restart the integration:

    curl -X PUT "https://example.com/integrations/api/v1/integrations/<integration_ID>/status" -u <username>:<password> -k -v --insecure  -H "Content-Type: application/json" -d'
    {
      "command": "stop"
    }'
    
    curl -X PUT "https://example.com/integrations/api/v1/integrations/<integration_ID>/status" -u <username>:<password> -k -v --insecure  -H "Content-Type: application/json" -d'
    {
      "command": "start"
    }'

You can now send events to your integration and find those events in your capture log.

Start and stop the Webhook integration

  1. In Moogsoft Enterprise, go to Integrations > Installed Integrations and select the integration that you want to start or stop. In this example, select the Webhook integration.

  2. Note the integration ID from the URL:

    https://example.com/#/integrations/integration-details/<integration_ID>
  3. Run the following cURL command to extract the existing configuration. Substitute the username and password of the user authorised to use the Integrations API, the integration ID, and the command. Command can be either start or stop.

    curl -X PUT "https://example.com \
    /integrations/api/v1/integrations/<integration_ID>/status" -u <username>:<password> \ 
    -k -v --insecure -H "Content-Type: application/json" -d' { "command": "<command>" }'
    

Supporting information

See Webhook for more information on the Webhook integration.

See Configure Logging for more information on capture logs.

See Role Permissions for more information on roles and permissions.

See /integrations/{integrationId}/status for more information on the status endpoint.