Skip to content

Commit

Permalink
Adds a built-in PagerDuty action
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

Some slight refactoring of the action service simulators, to get the
xsrf paths set up so the FT config.ts doesn't have to be updated
every time we add a simulator.
  • Loading branch information
pmuellr committed Aug 22, 2019
1 parent e568c3d commit ada3266
Show file tree
Hide file tree
Showing 10 changed files with 958 additions and 55 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 ada3266

Please sign in to comment.