HealthCheckIntegrations

Collect integrations name and count number of engines.

python · System Diagnostics and Health Check

Source

import demistomock as demisto  # noqa: F401
from CommonServerPython import *  # noqa: F401

incident = demisto.incidents()[0]
accountName = incident.get("account")
accountName = f"acc_{accountName}" if accountName != "" else ""

res = demisto.executeCommand(
    "core-api-post",
    {
        "uri": f"{accountName}/settings/integration/search",
        "body": {"size": 500},
    },
)[0]["Contents"]["response"]

enabledInstances = list(filter(lambda x: x["enabled"] == "true", res["instances"]))
enabledInstancesNames = []
for instance in enabledInstances:
    if instance["name"] in ["testmodule", "d2"]:
        continue
    else:
        enabledInstancesNames.append({"instancename": instance["name"]})

demisto.executeCommand("setIncident", {"healthcheckenabledinstances": enabledInstancesNames})
demisto.executeCommand("setIncident", {"healthchecknumberofengines": res["engines"]["total"]})

README

Troubleshooting

Multi-tenant environments should be configured with the Cortex Rest API instance when using this
automation. Make sure the Use tenant parameter (in the Cortex Rest API integration) is checked
to ensure that API calls are made to the current tenant instead of the master tenant.