IncidentsCheck-PlaybooksHealthNames
Health Check dynamic section, showing the top ten playbook names of the failed incidents in a bar chart.
Details
| ID | IncidentsCheck-PlaybooksHealthNames |
|---|---|
| Language | python |
| From Version | 6.0.0 |
| Docker Image | demisto/python3:3.12.13.10116658 |
| Tags | dynamic-section failedIncidents |
README
Health Check dynamic section, showing the top ten playbook names of the failed incidents in a bar chart.
Script Data
| Name | Description |
|---|---|
| Script Type | python3 |
| Tags | dynamic-section, failedIncidents |
| Cortex XSOAR Version | 6.0.0 |
Inputs
There are no inputs for this script.
Outputs
There are no outputs for this script.
import demistomock as demisto # noqa: F401 from CommonServerPython import * # noqa: F401 import collections import random from collections import Counter def parse_data(playbook_names): playbooks_data = [] if playbook_names: playbooks_collections: Counter = collections.Counter(playbook_names) top_playbooks = playbooks_collections.most_common(10) playbooks_number = len(top_playbooks) playbook_number = 0 while playbook_number < playbooks_number: for topPlaybook in top_playbooks: random_number = random.randint(0, 16777215) hex_number = hex(random_number) # convert to hexadecimal color = f"#{hex_number[2:].zfill(6)}" # remove 0x and prepend '#' playbook_widget_data = { "data": [topPlaybook[1]], "groups": None, "name": str(topPlaybook[0]), "label": str(topPlaybook[0]), "color": color, } playbooks_data.append(playbook_widget_data) playbook_number += 1 return {"Type": 17, "ContentsFormat": "bar", "Contents": {"stats": playbooks_data, "params": {"layout": "horizontal"}}} return {} # pragma: no cover def main(): incident = demisto.incidents() playbook_names = incident[0].get("CustomFields", {}).get("playbooknameswithfailedtasks") if playbook_names: data = parse_data(playbook_names) else: # pragma: no cover data = { "Type": 17, "ContentsFormat": "bar", "Contents": { "stats": [ {"data": [0], "groups": None, "name": "N/A", "label": "N/A", "color": "rgb(255, 23, 68)"}, ], "params": {"layout": "horizontal"}, }, } demisto.results(data) if __name__ in ["__main__", "builtin", "builtins"]: main()