-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding pagerduty target #71
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Can you resolve the comments and add a isAccessible()
method like in the Jira Target: https://github.com/etsy/411/blob/master/phplib/Target/Jira.php#L22-L25
This hides the Target from the UI if it hasn't been configured.
class PagerDuty_Target extends Target { | ||
public static $TYPE = 'pagerduty'; | ||
|
||
public static $DESC = 'Create a incident for this alert and assign to <assignee>.'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpicky: "an incident"
$curl = new \Curl\Curl; | ||
$curl->setHeader('Content-type', 'application/json'); | ||
$ret = $curl->post( | ||
'https://events.pagerduty.com/generic/2010-04-15/create_event.json', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that... the api version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so? They don't call it out specifically in their API docs: https://v2.developer.pagerduty.com/v2/docs/trigger-events
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
json_encode($event_data) | ||
); | ||
|
||
if($curl->httpStatusCode < 200 || $curl->httpStatusCode >= 300) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the API return non 200 responses on success? If not, you should just check for 200 here.
); | ||
|
||
if($curl->httpStatusCode < 200 || $curl->httpStatusCode >= 300) { | ||
return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the Jira Target to give better error info when a request fails: https://github.com/etsy/411/blob/master/phplib/Target/Jira.php#L83
So I'm not sure what to do for the isAccessible() function. The only configuration that is required for this target is an API key which I've set up as configurable per search since it sends it to different escalation policies. So I guess just return true? |
Do you mean the API token? https://v2.developer.pagerduty.com/docs/authentication |
So when you create an event via the API (https://v2.developer.pagerduty.com/docs/trigger-events) you have to pass in a "service_key" which is associated with the service and escalation policy that's defined for your teams in PagerDuty, it basically acts as both authentication and internal routing. There's no additional api keys or tokens which are required to call their API. |
Ah, I see. No need to implement |
Merged, thanks! :] |
This adds the ability to create pagerduty incidents from alerts