Skip to content

Commit

Permalink
Adds a built-in PagerDuty action (elastic#43395)
Browse files Browse the repository at this point in the history
The PagerDuty action can be used to post events via the PagerDuty
Events API v2:

https://v2.developer.pagerduty.com/docs/events-api-v2
  • Loading branch information
pmuellr committed Aug 26, 2019
1 parent bc7a2c1 commit df8eb82
Show file tree
Hide file tree
Showing 9 changed files with 949 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ import { actionType as serverLogActionType } from './server_log';
import { actionType as slackActionType } from './slack';
import { actionType as emailActionType } from './email';
import { actionType as indexActionType } from './es_index';
import { actionType as pagerDutyActionType } from './pagerduty';

export function registerBuiltInActionTypes(actionTypeRegistry: ActionTypeRegistry) {
actionTypeRegistry.register(serverLogActionType);
actionTypeRegistry.register(slackActionType);
actionTypeRegistry.register(emailActionType);
actionTypeRegistry.register(indexActionType);
actionTypeRegistry.register(pagerDutyActionType);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import axios, { AxiosResponse } from 'axios';
import { Services } from '../../types';

interface PostPagerdutyOptions {
apiUrl: string;
data: any;
headers: Record<string, string>;
services: Services;
}

// post an event to pagerduty
export async function postPagerduty(options: PostPagerdutyOptions): Promise<AxiosResponse> {
const { apiUrl, data, headers } = options;
const axiosOptions = {
headers,
validateStatus: () => true,
};

return axios.post(apiUrl, data, axiosOptions);
}
Loading

0 comments on commit df8eb82

Please sign in to comment.