Replies: 1 comment
-
|
Hi @davidis2 thanks for using the CLI! So the problem is that I am outputting one row per EP and for fields that have multiple values I am putting a delimiter in between the values (default But it sounds to me like maybe you want one line for each EP rule. For that I'd recommend calling PD CLI from a simple python script, like this: #!/usr/bin/env python3
import csv
import json
import subprocess
import argparse
parser = argparse.ArgumentParser('Get escalation policy rules with delay minutes')
parser.add_argument('-o', '--output_file', help="File to write CSV results", required=True)
args = parser.parse_args()
def runcmd(cmd):
r = subprocess.run(cmd, shell=True, capture_output=True)
return json.loads(r.stdout)
print(f"Getting EPs... ", end='', flush=True)
eps = runcmd(f"pd ep:list -j")
print(f"got {len(eps)}")
rows = []
for ep in eps:
for rule in ep['escalation_rules']:
rows.append([
ep['id'],
ep['summary'],
ep['html_url'],
rule['escalation_delay_in_minutes'],
', '.join([target['summary'] for target in rule['targets']])
])
f = open(args.output_file, "w")
w = csv.writer(f)
w.writerow([
'EP ID',
'EP Name',
'EP URL',
'Rule delay',
'Rule targets'
])
w.writerows(rows)This should give you CSV output that looks like this: Let me know what you think... thanks... |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment


Uh oh!
There was an error while loading. Please reload this page.
-
Hello and many thanks for developing this awesome tool.
I am using the following command to query for escalation_delay_in_minutes data but am having an issue where there are escalations with multiple escalation rules. The minutes are not seen when exporting to csv as individual levels so it makes it hard filter properly. They all get lumped into the first escaltion rule. Any ideas how to get around this?
pd ep:list -k 'html_url' -k 'escalation_rules[*].escalation_delay_in_minutes' --csv > Prod_EP_over_10Min_escalations_8_05_2022
sorry can't share a file due to PII
Beta Was this translation helpful? Give feedback.
All reactions