Closed notjames closed 3 years ago
Hi @notjames , thanks for reporting this. I think there may be a bug in PD CLI in here somewhere, but one thing that I should make more clear about the way that PD works is that incidents that are not open are not considered to have any assignees, which means that neither --me
nor -e
will ever show any resolved incidents -- so -s closed --me
and -s closed -e someone
will always return an empty list. This is perhaps not intuitive given the context within which the CLI is exposing this functionality, so I will definitely change the doc, online help and flags validation to reflect this fact.
One potential issue is that when specifying only --since
or only --until
will cause the CLI to rely on whatever default until or since the API assigns, which ya know what I am not sure what that is in all cases. I can either make it require that both be specified, or I can try to assign some sensible defaults. But I am leaning toward making it so that if one is specified the other must also be specified, just to avoid confusion.
Apart from these items, what else are you seeing that is incorrect or inconsistent?
Thank you!!
I can concur that adding --since
or --until
without the other returns no results to me as well, so the sensible default returned be the PD api is non-existent.
I'll do some testing without the -e
and with --since
and --until
to see if I get expected results. I'll let you know what my results are.
OK, I've confirmed that using -e
definitely causes the empty-set problems for me. As for --since
without --until
, I don't think it's necessary to require both, but it would be nice that whatever the API asserts in the absence of one or the other is at least documented. It seems to me that the time frame asserted is from 0000 HRS Zulu, though I could be wrong on the TZ.
OK so I should definitely document this or give some online help for this, but the way PD works is that an incident that is in a resolved state doesn't have anyone currently assigned -- and --me
and -e
search incidents currently assigned to a user. So anything with only -s closed
or -s resolved
plus -e
or -m
will always return empty. This should probably be handled by flags validation, where if the user is asking for 'resolved incidents assigned to some user' then we already know we are not going to get anything.
Is the goal to get incidents that were once assigned to a user, or incidents that were first assigned to a user? If so, that is a little bit tricky in PD, because the incident itself doesn't have that information after it's resolved. You have to get the incident log entries and look for assign_log_entry
with the User ID you are looking for... You could get close by doing something like this:
USER_ID=$(pd user:list -E martin@pagerduty.com -p)
pd incident:list --since 1/1/2021 --until 1/2/2021 -s closed -p | pd incident:log -p -k 'assignees[*].id' --filter 'log entry type=assign' | grep $USER_ID
Another alternative is to write a small Python script that calls pd user:list
, pd incident:list
, etc. with -j
and does the correlation that you want directly...
So in 0.0.72, I added an explicit message letting you know when the combination of -s
and -e
/-m
makes it so that you will never get anything back...
Hi @notjames , I am going to close this now as it looks like there's nothing more that we can do currently. Let me know if there's anything else...
First off, this tool is by far the best of any PD client I've used. So kudos!
Today, I needed to grab a list of all incidents I owned since a certain date (about 7 days ago). The problem is that I get the same output regardless of the permutation of arguments and I know we had far more than a few incidents as seen below even given the arguments. I suspect there might be something wrong with how output is filtered using arguments and at the very least, something is not intuitive with respect to either PD or potentially this tool. I'm inclined to think the issue is with PD, but I'm reporting the issue just case.
I tried the following permutations:
I'll file a separate issue for
--me
All of these fetched the exact same acknowledged alerts. Over the period requested (since Sept 1, 2021), we had over 1000 entries but with the qualifying arguments, I could never get what I expected. Here's some output: (note that for these I was using 0.0.71 but updated and verified the issue persists in the latest version)
When I removed all of the qualifiers and just put the
--since
in there, I got more returned, but nothing that occurred before 9/11 which I know we have a plethora.