Skip to content

Commit dedfd62

Browse files
authored
Adds a built-in PagerDuty action (#43395)
The PagerDuty action can be used to post events via the PagerDuty Events API v2: https://v2.developer.pagerduty.com/docs/events-api-v2
1 parent 7054662 commit dedfd62

File tree

9 files changed

+949
-48
lines changed

9 files changed

+949
-48
lines changed

x-pack/legacy/plugins/actions/server/builtin_action_types/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ import { actionType as serverLogActionType } from './server_log';
1010
import { actionType as slackActionType } from './slack';
1111
import { actionType as emailActionType } from './email';
1212
import { actionType as indexActionType } from './es_index';
13+
import { actionType as pagerDutyActionType } from './pagerduty';
1314

1415
export function registerBuiltInActionTypes(actionTypeRegistry: ActionTypeRegistry) {
1516
actionTypeRegistry.register(serverLogActionType);
1617
actionTypeRegistry.register(slackActionType);
1718
actionTypeRegistry.register(emailActionType);
1819
actionTypeRegistry.register(indexActionType);
20+
actionTypeRegistry.register(pagerDutyActionType);
1921
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
import axios, { AxiosResponse } from 'axios';
8+
import { Services } from '../../types';
9+
10+
interface PostPagerdutyOptions {
11+
apiUrl: string;
12+
data: any;
13+
headers: Record<string, string>;
14+
services: Services;
15+
}
16+
17+
// post an event to pagerduty
18+
export async function postPagerduty(options: PostPagerdutyOptions): Promise<AxiosResponse> {
19+
const { apiUrl, data, headers } = options;
20+
const axiosOptions = {
21+
headers,
22+
validateStatus: () => true,
23+
};
24+
25+
return axios.post(apiUrl, data, axiosOptions);
26+
}

0 commit comments

Comments
 (0)