Skip to content
This repository has been archived by the owner on Feb 20, 2024. It is now read-only.

Commit

Permalink
Update api.py
Browse files Browse the repository at this point in the history
Patch to handle dead subscriptions
  • Loading branch information
adonm committed Mar 30, 2023
1 parent 1004d70 commit 0a5a1c8
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions siem_query_utils/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,18 +200,22 @@ def workspace_details():
for wsdata in list_workspaces("json"):
customerId = wsdata["customerId"]
sub = wsdata["subscription"]
ws = azcli(
[
"monitor",
"log-analytics",
"workspace",
"list",
"--subscription",
sub,
"--query",
f"[?customerId == '{customerId}']",
]
)[0]
try: # handle dead/missing subscriptions
ws = azcli(
[
"monitor",
"log-analytics",
"workspace",
"list",
"--subscription",
sub,
"--query",
f"[?customerId == '{customerId}']",
]
)[0]
except Exception as exc:
logger.warning(exc)
continue
ws["id"] = ws["id"].lower()
ws["name"] = ws["name"].lower()
ws["ingest_function"] = f"{ws['customerId'].replace('-', '_')}_incoming"
Expand Down

0 comments on commit 0a5a1c8

Please sign in to comment.