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.
Enable a capture log for the Webhook integration
In the Moogsoft Enterprise UI, go to Integrations > Installed Integrations and select the integration for which you want to enable the capture log.
Note the integration ID from the URL:
https://example.com/#/integrations/integration-details/<integration_ID>
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": [...] }
Edit the returned JSON by adding
"agent":{"log":"/usr/share/moogsoft/log/data-capture/mycapturefile.log"}
to theconfig.config
section. For example:... "config": { "config": { "agent":{"log":"/usr/share/moogsoft/log/data-capture/mycapturefile.log"}, "filter": { ...
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" } ] }'
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
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.
Note the integration ID from the URL:
https://example.com/#/integrations/integration-details/<integration_ID>
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
orstop
.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.