Skip to content

Commit

Permalink
Merge branch 'master' into np-vega
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Apr 20, 2020
2 parents 4f51828 + 53a0752 commit af5fd4d
Show file tree
Hide file tree
Showing 343 changed files with 2,581 additions and 1,678 deletions.
133 changes: 128 additions & 5 deletions docs/user/alerting/action-types/pagerduty.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,142 @@

The PagerDuty action type uses the https://v2.developer.pagerduty.com/docs/events-api-v2[v2 Events API] to trigger, acknowledge, and resolve PagerDuty alerts.

* <<pagerduty-benefits, PagerDuty and Elastic integration benefits>>
* <<pagerduty-connector-configuration, Connector configuration>>
* <<pagerduty-action-configuration, Action configuration>>

[float]
[[pagerduty-benefits]]
=== PagerDuty + Elastic integration benefits

By integrating PagerDuty with alerts, you can:

* Route your alerts to the right PagerDuty responder within your team, based on your structure, escalation policies, and workflows.
* Automatically generate incidents of different types and severity based on each alert’s context.
* Tailor the incident data to match your needs by easily passing the alerting context from Kibana to PagerDuty.

[float]
[[pagerduty-how-it-works]]
==== How it works

{kib} allows you to create alerts to notify you of a significant move
in your dataset.
You can create alerts for all your Observability, Security, and Elastic Stack use cases.
Alerts will trigger a new incident on the corresponding PagerDuty service.

[float]
==== Requirements

In the `kibana.yml` configuration file, you must add the <<general-alert-action-settings, saved objects encryption setting>>.
This is required to encrypt parameters that must be secured, for example PagerDuty’s integration key.

If you have security enabled:

* You must have
application privileges to access Metrics, APM, Uptime, or SIEM.
* If you are using a self-managed deployment with security, you must have
Transport Security Layer (TLS) enabled for communication <<configuring-tls-kib-es, between Elasticsearch and Kibana>>.
Alerts uses API keys to secure background alert checks and actions,
and API keys require {ref}/configuring-tls.html#tls-http[TLS on the HTTP interface].

Although not a requirement, to harden the integrations security you might want to
review the <<action-settings, Actions settings>> that are available to you.

[float]
[[pagerduty-support]]
==== Support
If you need help with this integration, get in touch with the {kib} team by visiting
https://support.elastic.co[support.elastic.co] or by using the *Ask Elastic* option in the {kib} Help menu.
You can also select the {kib} category at https://discuss.elastic.co/[discuss.elastic.co].

[float]
[[pagerduty-integration-walkthrough]]
==== Integration with PagerDuty walkthrough

[float]
[[pagerduty-in-pagerduty]]
===== In PagerDuty

. From the *Configuration* menu, select *Services*.
. Add an integration to a service:
+
* If you are adding your integration to an existing service,
click the name of the service you want to add the integration to.
Then, select the *Integrations* tab and click the *New Integration* button.
* If you are creating a new service for your integration,
go to
https://support.pagerduty.com/docs/services-and-integrations#section-configuring-services-and-integrations[Configuring Services and Integrations]
and follow the steps outlined in the *Create a New Service* section, selecting *Elastic* as the *Integration Type* in step 4.
Continue with the <<pagerduty-in-elastic, In Elastic>> section once you have finished these steps.

. Enter an *Integration Name* in the format Elastic-service-name (for example, Elastic-Alerting or Kibana-APM-Alerting)
and select Elastic from the *Integration Type* menu.
. Click *Add Integration* to save your new integration.
+
You will be redirected to the *Integrations* tab for your service. An Integration Key is generated on this screen.
+
[role="screenshot"]
image::user/alerting/images/pagerduty-integration.png[PagerDuty Integrations tab]

. Save this key, as you will use it when you configure the integration with Elastic in the next section.

[float]
[[pagerduty-in-elastic]]
===== In Elastic

. Create a PagerDuty Connector in Kibana. You can:
+
* Create a connector as part of creating an alert by selecting PagerDuty in the *Actions*
section of the alert configuration and selecting *Add new*.
* Alternatively, create a connector by navigating to *Management* from the {kib} navbar and selecting
*Alerts and Actions*. Then, select the *Connectors* tab, click the *Create connector* button, and select the PagerDuty option.

. Configure the connector by giving it a name and optionally entering the API URL and Routing Key, or using the defaults.
+
See <<pagerduty-in-pagerduty, In PagerDuty>> for how to obtain the endpoint and key information from PagerDuty and
<<pagerduty-connector-configuration, Connector configuration>> for more details.

. Save the Connector.

. Create an alert using *Management > Alerts and Actions* or the application of your choice.

. Set up an action using your PagerDuty connector, by determining:
+
* The action’s type: Trigger, Resolve, or Acknowledge.
* The event’s severity: Info, warning, error, or critical.
* An array of different fields, including the timestamp, group, class, component, and your dedup key.
Depending on your custom needs, assign them variables from the alerting context.
To see the available context variables, click on the *Add alert variable* icon next
to each corresponding field. For more details on these parameters, see the
<<pagerduty-action-configuration, Actions Configuration>> and the PagerDuty
https://v2.developer.pagerduty.com/v2/docs/send-an-event-events-api-v2[API v2 documentation].


[float]
[[pagerduty-uninstall]]
==== How to uninstall
To remove a PagerDuty connector from an alert, simply remove it
from the *Actions* section of that alert, using the remove (x) icon.
This will disable the integration for the particular alert.

To delete the connector entirely, go to *Management > Alerts and Actions*.
Select the *Connectors* tab, and then click on the delete icon.
This is an irreversible action and impacts all alerts that use this connector.


[float]
[[pagerduty-connector-configuration]]
==== Connector configuration
=== Connector configuration

PagerDuty connectors have the following configuration properties:

Name:: The name of the connector. The name is used to identify a connector in the management UI connector listing, or in the connector list when configuring an action.
API URL:: An optional PagerDuty event URL. Defaults to `https://events.pagerduty.com/v2/enqueue`. If you are using the <<action-settings, `xpack.actions.whitelistedHosts`>> setting, make sure the hostname is whitelisted.
API URL:: An optional PagerDuty event URL. Defaults to `https://events.pagerduty.com/v2/enqueue`. If you are using the <<action-settings, `xpack.actions.whitelistedHosts`>> setting, make sure the hostname is whitelisted.
Routing Key:: A 32 character PagerDuty Integration Key for an integration on a service or on a global ruleset.

[float]
[[pagerduty-action-configuration]]
==== Action configuration
=== Action configuration

PagerDuty actions have the following properties:

Expand All @@ -26,8 +149,8 @@ Dedup Key:: All actions sharing this key will be associated with the same Pa
Timestamp:: An *optional* https://v2.developer.pagerduty.com/v2/docs/types#datetime[ISO-8601 format date-time], indicating the time the event was detected or generated.
Component:: An *optional* value indicating the component of the source machine that is responsible for the event, for example `mysql` or `eth0`.
Group:: An *optional* value indicating the logical grouping of components of a service, for example `app-stack`.
Source:: An *optional* value indicating the affected system, preferably a hostname or fully qualified domain name. Defaults to the {kib} saved object id of the action.
Source:: An *optional* value indicating the affected system, preferably a hostname or fully qualified domain name. Defaults to the {kib} saved object id of the action.
Summary:: An *optional* text summary of the event, defaults to `No summary provided`. The maximum length is 1024 characters.
Class:: An *optional* value indicating the class/type of the event, for example `ping failure` or `cpu load`.

For more details on these properties, see https://v2.developer.pagerduty.com/v2/docs/send-an-event-events-api-v2[PagerDuty v2 event parameters].
For more details on these properties, see https://v2.developer.pagerduty.com/v2/docs/send-an-event-events-api-v2[PagerDuty v2 event parameters].
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions src/core/public/plugins/plugin_loader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ test('`loadPluginBundles` creates a script tag and loads initializer', async ()
const fakeScriptTag = createdScriptTags[0];
expect(fakeScriptTag.setAttribute).toHaveBeenCalledWith(
'src',
'/bundles/plugin:plugin-a/plugin-a.plugin.js'
'/bundles/plugin/plugin-a/plugin-a.plugin.js'
);
expect(fakeScriptTag.setAttribute).toHaveBeenCalledWith('id', 'kbn-plugin-plugin-a');
expect(fakeScriptTag.onload).toBeInstanceOf(Function);
Expand All @@ -85,7 +85,7 @@ test('`loadPluginBundles` includes the basePath', async () => {
const fakeScriptTag = createdScriptTags[0];
expect(fakeScriptTag.setAttribute).toHaveBeenCalledWith(
'src',
'/mybasepath/bundles/plugin:plugin-a/plugin-a.plugin.js'
'/mybasepath/bundles/plugin/plugin-a/plugin-a.plugin.js'
);
});

Expand All @@ -96,7 +96,7 @@ test('`loadPluginBundles` rejects if script.onerror is called', async () => {
fakeScriptTag1.onerror(new Error('Whoa there!'));

await expect(loadPromise).rejects.toThrowErrorMatchingInlineSnapshot(
`"Failed to load \\"plugin-a\\" bundle (/bundles/plugin:plugin-a/plugin-a.plugin.js)"`
`"Failed to load \\"plugin-a\\" bundle (/bundles/plugin/plugin-a/plugin-a.plugin.js)"`
);
});

Expand All @@ -105,7 +105,7 @@ test('`loadPluginBundles` rejects if timeout is reached', async () => {
// Override the timeout to 1 ms for testi.
loadPluginBundle(addBasePath, 'plugin-a', { timeoutMs: 1 })
).rejects.toThrowErrorMatchingInlineSnapshot(
`"Timeout reached when loading \\"plugin-a\\" bundle (/bundles/plugin:plugin-a/plugin-a.plugin.js)"`
`"Timeout reached when loading \\"plugin-a\\" bundle (/bundles/plugin/plugin-a/plugin-a.plugin.js)"`
);
});

Expand All @@ -115,11 +115,11 @@ test('`loadPluginBundles` rejects if bundle does attach an initializer to window
const fakeScriptTag1 = createdScriptTags[0];

// Setup a fake initializer as if a plugin bundle had actually been loaded.
coreWindow.__kbnBundles__['plugin:plugin-a'] = undefined;
coreWindow.__kbnBundles__['plugin/plugin-a'] = undefined;
// Call the onload callback
fakeScriptTag1.onload();

await expect(loadPromise).rejects.toThrowErrorMatchingInlineSnapshot(
`"Definition of plugin \\"plugin-a\\" should be a function (/bundles/plugin:plugin-a/plugin-a.plugin.js)."`
`"Definition of plugin \\"plugin-a\\" should be a function (/bundles/plugin/plugin-a/plugin-a.plugin.js)."`
);
});
2 changes: 1 addition & 1 deletion src/core/public/plugins/plugin_loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const loadPluginBundle: LoadPluginBundle = <

const script = document.createElement('script');
// Assumes that all plugin bundles get put into the bundles/plugins subdirectory
const bundlePath = addBasePath(`/bundles/plugin:${pluginName}/${pluginName}.plugin.js`);
const bundlePath = addBasePath(`/bundles/plugin/${pluginName}/${pluginName}.plugin.js`);
script.setAttribute('src', bundlePath);
script.setAttribute('id', `kbn-plugin-${pluginName}`);
script.setAttribute('async', '');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ kibana_vars=(
xpack.reporting.capture.viewport.width
xpack.reporting.capture.zoom
xpack.reporting.csv.checkForFormulas
xpack.reporting.csv.escapeFormulaValues
xpack.reporting.csv.enablePanelActionDownload
xpack.reporting.csv.maxSizeBytes
xpack.reporting.csv.scroll.duration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ const {
core,
chrome,
data,
docTitle,
history,
indexPatterns,
filterManager,
Expand Down Expand Up @@ -214,6 +213,7 @@ function discoverController(
isAppStateDirty,
kbnUrlStateStorage,
getPreviousAppState,
resetInitialAppState,
} = getState({
defaultAppState: getStateDefaults(),
storeInSessionStorage: config.get('state:storeInSessionStorage'),
Expand Down Expand Up @@ -373,6 +373,8 @@ function discoverController(
// If the save wasn't successful, put the original values back.
if (!response.id || response.error) {
savedSearch.title = currentTitle;
} else {
resetInitialAppState();
}
return response;
});
Expand Down Expand Up @@ -758,7 +760,7 @@ function discoverController(
} else {
// Update defaults so that "reload saved query" functions correctly
setAppState(getStateDefaults());
docTitle.change(savedSearch.lastSavedTitle);
chrome.docTitle.change(savedSearch.lastSavedTitle);
}
}
});
Expand Down
5 changes: 3 additions & 2 deletions src/legacy/core_plugins/kibana/public/kibana.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ import { showAppRedirectNotification } from '../../../../plugins/kibana_legacy/p
import 'leaflet';
import { localApplicationService } from './local_application_service';

npSetup.plugins.kibanaLegacy.forwardApp('doc', 'discover', { keepPrefix: true });
npSetup.plugins.kibanaLegacy.forwardApp('context', 'discover', { keepPrefix: true });
npSetup.plugins.kibanaLegacy.registerLegacyAppAlias('doc', 'discover', { keepPrefix: true });
npSetup.plugins.kibanaLegacy.registerLegacyAppAlias('context', 'discover', { keepPrefix: true });

localApplicationService.attachToAngular(routes);

routes.enable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,29 @@ export class LocalApplicationService {
}
});

npStart.plugins.kibanaLegacy.getForwards().forEach(({ legacyAppId, newAppId, keepPrefix }) => {
angularRouteManager.when(matchAllWithPrefix(legacyAppId), {
resolveRedirectTo: ($location: ILocationService) => {
const url = $location.url();
return `/${newAppId}${keepPrefix ? url : url.replace(legacyAppId, '')}`;
npStart.plugins.kibanaLegacy.getForwards().forEach(forwardDefinition => {
angularRouteManager.when(matchAllWithPrefix(forwardDefinition.legacyAppId), {
outerAngularWrapperRoute: true,
reloadOnSearch: false,
reloadOnUrl: false,
template: '<span></span>',
controller($location: ILocationService) {
const newPath = forwardDefinition.rewritePath($location.url());
npStart.core.application.navigateToApp(forwardDefinition.newAppId, { path: newPath });
},
});
});

npStart.plugins.kibanaLegacy
.getLegacyAppAliases()
.forEach(({ legacyAppId, newAppId, keepPrefix }) => {
angularRouteManager.when(matchAllWithPrefix(legacyAppId), {
resolveRedirectTo: ($location: ILocationService) => {
const url = $location.url();
return `/${newAppId}${keepPrefix ? url : url.replace(legacyAppId, '')}`;
},
});
});
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

export const TAB_INDEXED_FIELDS = 'indexedFields';
export const TAB_SCRIPTED_FIELDS = 'scriptedFields';
export const TAB_SOURCE_FILTERS = 'sourceFilters';
Loading

0 comments on commit af5fd4d

Please sign in to comment.