Skip to content

Commit

Permalink
Merge branch 'main' into fix-long-input-166019
Browse files Browse the repository at this point in the history
  • Loading branch information
nickofthyme authored Sep 8, 2023
2 parents ab6a537 + e5a7261 commit 2be4ba0
Show file tree
Hide file tree
Showing 50 changed files with 1,452 additions and 615 deletions.
35 changes: 2 additions & 33 deletions docs/management/connectors/action-types/jira.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ or as needed when you're creating a rule. For example:

[role="screenshot"]
image::management/connectors/images/jira-connector.png[Jira connector]
// NOTE: This is an autogenerated screenshot. Do not edit it directly.

[float]
[[jira-connector-configuration]]
Expand All @@ -38,48 +39,16 @@ Project key:: Jira project key.
Email:: The account email for HTTP Basic authentication.
API token:: Jira API authentication token for HTTP Basic authentication.

[float]
[[preconfigured-jira-configuration]]
=== Create preconfigured connectors

If you are running {kib} on-prem, you can define connectors by
adding `xpack.actions.preconfigured` settings to your `kibana.yml` file.
For example:

[source,text]
--
xpack.actions.preconfigured:
my-jira:
name: preconfigured-jira-connector-type
actionTypeId: .jira
config:
apiUrl: https://elastic.atlassian.net
projectKey: ES
secrets:
email: testuser
apiToken: tokenkeystorevalue
--

Config defines information for the connector type.

`apiUrl`:: An address that corresponds to *URL*.
`projectKey`:: A key that corresponds to *Project Key*.

Secrets defines sensitive information for the connector type.

`email`:: A string that corresponds to *Email*.
`apiToken`:: A string that corresponds to *API Token*. Should be stored in the <<creating-keystore, {kib} keystore>>.

[float]
[[jira-action-configuration]]
=== Test connectors

You can test connectors with the <<execute-connector-api,run connector API>> or
as you're creating or editing the connector in {kib}. For example:


[role="screenshot"]
image::management/connectors/images/jira-params-test.png[Jira params test]
// NOTE: This is an autogenerated screenshot. Do not edit it directly.

Jira actions have the following configuration properties.

Expand Down
7 changes: 7 additions & 0 deletions docs/management/connectors/action-types/xmatters.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
++++
<titleabbrev>xMatters</titleabbrev>
++++
:frontmatter-description: Add a connector that can send alerts to xMatters.
:frontmatter-tags-products: [kibana]
:frontmatter-tags-content-type: [how-to]
:frontmatter-tags-user-goals: [configure]

The xMatters connector uses the https://help.xmatters.com/integrations/#cshid=Elastic[xMatters Workflow for Elastic] to send actionable alerts to on-call xMatters resources.

Expand All @@ -15,9 +19,11 @@ or as needed when you're creating a rule. You must choose between basic and URL

[role="screenshot"]
image::management/connectors/images/xmatters-connector-basic.png[xMatters connector with basic authentication]
// NOTE: This is an autogenerated screenshot. Do not edit it directly.

[role="screenshot"]
image::management/connectors/images/xmatters-connector-url.png[xMatters connector with url authentication]
// NOTE: This is an autogenerated screenshot. Do not edit it directly.

[float]
[[xmatters-connector-configuration]]
Expand Down Expand Up @@ -90,6 +96,7 @@ as you're creating or editing the connector in {kib}. For example:

[role="screenshot"]
image::management/connectors/images/xmatters-params-test.png[xMatters params test]
// NOTE: This is an autogenerated screenshot. Do not edit it directly.

xMatters rules have the following properties:

Expand Down
Binary file modified docs/management/connectors/images/jira-connector.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/management/connectors/images/jira-params-test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/management/connectors/images/xmatters-connector-basic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/management/connectors/images/xmatters-connector-url.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/management/connectors/images/xmatters-params-test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions docs/management/connectors/pre-configured-connectors.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ Index names must start with `kibana-alert-history-` to take advantage of the pre
=== Examples

* <<preconfigured-index-configuration>>
* <<preconfigured-jira-configuration>>
* <<preconfigured-opsgenie-configuration>>
* <<preconfigured-pagerduty-configuration>>
* <<preconfigured-server-log-configuration>>
Expand All @@ -132,6 +133,30 @@ xpack.actions.preconfigured:
<1> The {es} index to be written to.
<2> A field that indicates when the document was indexed.

[float]
[[preconfigured-jira-configuration]]
==== Jira connectors

The following example creates a <<jira-action-type,Jira connector>>:

[source,text]
--
xpack.actions.preconfigured:
my-jira:
name: preconfigured-jira-connector-type
actionTypeId: .jira
config:
apiUrl: https://elastic.atlassian.net <1>
projectKey: ES <2>
secrets:
email: testuser <3>
apiToken: tokenkeystorevalue <4>
--
<1> The Jira instance URL.
<2> The Jira project key.
<3> The account email for HTTP basic authentication.
<4> The API authentication token for HTTP basic authentication. NOTE: This value should be stored in the <<creating-keystore,{kib} keystore>>.

[float]
[[preconfigured-opsgenie-configuration]]
==== {opsgenie} connectors
Expand Down
10 changes: 10 additions & 0 deletions docs/settings/alert-action-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ The configuration details, which are specific to the type of preconfigured conne
A configuration URL that varies by connector:
+
--
* For a <<jira-action-type,Jira connector>>, specifies the Jira instance URL.
* For an <<opsgenie-action-type,{opsgenie} connector>>, specifies the {opsgenie} URL. For example, `https://api.opsgenie.com` or `https://api.eu.opsgenie.com`.
* For a <<pagerduty-action-type,PagerDuty connector>>, specifies the PagerDuty event URL. Defaults to `https://events.pagerduty.com/v2/enqueue`.

Expand All @@ -274,6 +275,9 @@ For an <<index-action-type,index connector>>, a field that indicates when the do
`xpack.actions.preconfigured.<connector-id>.config.index`::
For an <<index-action-type,index connector>>, specifies the {es} index.

`xpack.actions.preconfigured.<connector-id>.config.projectKey`::
For a <<jira-action-type,Jira connector>>, specifies the Jira project key.

`xpack.actions.preconfigured.<connector-id>.name`::
The name of the preconfigured connector.

Expand All @@ -289,6 +293,12 @@ An API key secret that varies by connector:
* For an <<opsgenie-action-type,{opsgenie} connector>>, specifies the {opsgenie} API authentication key for HTTP basic authentication.
--

`xpack.actions.preconfigured.<connector-id>.secrets.apiToken`::
For a <<jira-action-type,Jira connector>>, specifies the API authentication token for HTTP basic authentication.

`xpack.actions.preconfigured.<connector-id>.secrets.email`::
For a <<jira-action-type,Jira connector>>, specifies the account email for HTTP basic authentication.

`xpack.actions.preconfigured.<connector-id>.secrets.routingKey`::
For a <<pagerduty-action-type,PagerDuty connector>>, specifies the 32 character PagerDuty Integration Key for an integration on a service, also referred to as the routing key.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ export class Router<Context extends RequestHandlerContextBase = RequestHandlerCo
kibanaRequest = CoreKibanaRequest.from(request, routeSchemas);
} catch (error) {
this.log.error(`400 Bad Request - ${request.path}`, {
error,
http: { response: { status_code: 400 } },
});

Expand All @@ -218,7 +217,6 @@ export class Router<Context extends RequestHandlerContextBase = RequestHandlerCo
// forward 401 errors from ES client
if (isElasticsearchUnauthorizedError(error)) {
this.log.error(`401 Unauthorized - ${request.path}`, {
error,
http: { response: { status_code: 401 } },
});
return hapiResponseAdapter.handle(
Expand All @@ -228,7 +226,6 @@ export class Router<Context extends RequestHandlerContextBase = RequestHandlerCo

// return a generic 500 to avoid error info / stack trace surfacing
this.log.error(`500 Server Error - ${request.path}`, {
error,
http: { response: { status_code: 500 } },
});
return hapiResponseAdapter.toInternalError();
Expand Down
29 changes: 4 additions & 25 deletions src/core/server/integration_tests/http/router.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -568,28 +568,17 @@ describe('Handler', () => {
router.get({ path: '/', validate: false }, (context, req, res) => {
throw new Error('unexpected error');
});

await server.start();

const result = await supertest(innerServer.listener).get('/').expect(500);

expect(result.body.message).toBe(
'An internal server error occurred. Check Kibana server logs for details.'
);
expect(loggingSystemMock.collect(logger).error).toMatchInlineSnapshot(`
Array [
Array [
"500 Server Error - /",
Object {
"error": [Error: unexpected error],
"http": Object {
"response": Object {
"status_code": 500,
},
},
},
],
]
`);

const [message] = loggingSystemMock.collect(logger).error[0];
expect(message).toEqual('500 Server Error - /');
});

it('captures the error if handler throws', async () => {
Expand Down Expand Up @@ -627,7 +616,6 @@ describe('Handler', () => {
Array [
"500 Server Error - /",
Object {
"error": [Error: Unauthorized],
"http": Object {
"response": Object {
"status_code": 500,
Expand Down Expand Up @@ -657,7 +645,6 @@ describe('Handler', () => {
Array [
"500 Server Error - /",
Object {
"error": [Error: Unexpected result from Route Handler. Expected KibanaResponse, but given: string.],
"http": Object {
"response": Object {
"status_code": 500,
Expand Down Expand Up @@ -702,7 +689,6 @@ describe('Handler', () => {
Array [
"400 Bad Request - /",
Object {
"error": [Error: [request query.page]: expected value of type [number] but got [string]],
"http": Object {
"response": Object {
"status_code": 400,
Expand Down Expand Up @@ -1187,7 +1173,6 @@ describe('Response factory', () => {
Array [
"500 Server Error - /",
Object {
"error": [Error: expected 'location' header to be set],
"http": Object {
"response": Object {
"status_code": 500,
Expand Down Expand Up @@ -1601,7 +1586,6 @@ describe('Response factory', () => {
Array [
"500 Server Error - /",
Object {
"error": [Error: Unexpected Http status code. Expected from 400 to 599, but given: 200],
"http": Object {
"response": Object {
"status_code": 500,
Expand Down Expand Up @@ -1678,7 +1662,6 @@ describe('Response factory', () => {
Array [
"500 Server Error - /",
Object {
"error": [Error: expected 'location' header to be set],
"http": Object {
"response": Object {
"status_code": 500,
Expand Down Expand Up @@ -1826,7 +1809,6 @@ describe('Response factory', () => {
Array [
"500 Server Error - /",
Object {
"error": [Error: expected error message to be provided],
"http": Object {
"response": Object {
"status_code": 500,
Expand Down Expand Up @@ -1860,7 +1842,6 @@ describe('Response factory', () => {
Array [
"500 Server Error - /",
Object {
"error": [Error: expected error message to be provided],
"http": Object {
"response": Object {
"status_code": 500,
Expand Down Expand Up @@ -1893,7 +1874,6 @@ describe('Response factory', () => {
Array [
"500 Server Error - /",
Object {
"error": [Error: options.statusCode is expected to be set. given options: undefined],
"http": Object {
"response": Object {
"status_code": 500,
Expand Down Expand Up @@ -1926,7 +1906,6 @@ describe('Response factory', () => {
Array [
"500 Server Error - /",
Object {
"error": [Error: Unexpected Http status code. Expected from 100 to 599, but given: 20.],
"http": Object {
"response": Object {
"status_code": 500,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { ViewMode } from '@kbn/embeddable-plugin/public';
import { SLOResponse } from '@kbn/slo-schema';
import moment from 'moment';
import React from 'react';
import { useKibana } from '../../../utils/kibana_react';
import { useLensDefinition } from './use_lens_definition';

interface Props {
slo: SLOResponse;
fromRange: Date;
}

export function ErrorRateChart({ slo, fromRange }: Props) {
const {
lens: { EmbeddableComponent },
} = useKibana().services;
const lensDef = useLensDefinition(slo);

return (
<EmbeddableComponent
id="sloErrorRateChart"
style={{ height: 190 }}
timeRange={{
from: fromRange.toISOString(),
to: moment().toISOString(),
}}
attributes={lensDef}
viewMode={ViewMode.VIEW}
noPadding
/>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

export * from './error_rate_chart';
Loading

0 comments on commit 2be4ba0

Please sign in to comment.