Skip to content

Commit

Permalink
Merge branch 'main' into add_execution_context
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Apr 15, 2022
2 parents 53dbb8a + cf84437 commit 0501e99
Show file tree
Hide file tree
Showing 214 changed files with 5,495 additions and 3,053 deletions.
12 changes: 11 additions & 1 deletion .buildkite/scripts/steps/package_testing/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ elif [[ "$TEST_PACKAGE" == "docker" ]]; then
fi
cd ..

export VAGRANT_CWD=test/package
export VAGRANT_CWD=$PWD/test/package
vagrant up "$TEST_PACKAGE" --no-provision

node scripts/es snapshot \
Expand All @@ -29,6 +29,16 @@ node scripts/es snapshot \
--license=trial &
while ! timeout 1 bash -c "echo > /dev/tcp/localhost/9200"; do sleep 30; done

function echoKibanaLogs {
echo '--- Kibana logs'
if [[ "$TEST_PACKAGE" == "deb" ]] || [[ "$TEST_PACKAGE" == "rpm" ]]; then
vagrant ssh $TEST_PACKAGE -t -c 'sudo cat /var/log/kibana/kibana.log'
elif [[ "$TEST_PACKAGE" == "docker" ]]; then
vagrant ssh $TEST_PACKAGE -t -c 'sudo docker logs kibana'
fi
}
trap "echoKibanaLogs" EXIT

vagrant provision "$TEST_PACKAGE"

export TEST_BROWSER_HEADLESS=1
Expand Down
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -462,10 +462,12 @@ x-pack/plugins/session_view @elastic/awp-platform

# Reporting
/x-pack/examples/reporting_example/ @elastic/kibana-reporting-services @elastic/kibana-app-services
/x-pack/examples/screenshotting_example/ @elastic/kibana-reporting-services @elastic/kibana-app-services
/x-pack/plugins/reporting/ @elastic/kibana-reporting-services @elastic/kibana-app-services
/x-pack/test/functional/apps/dashboard/reporting/ @elastic/kibana-reporting-services @elastic/kibana-app-services
/x-pack/test/functional/apps/reporting/ @elastic/kibana-reporting-services @elastic/kibana-app-services
/x-pack/test/functional/apps/reporting_management/ @elastic/kibana-reporting-services @elastic/kibana-app-services
/x-pack/test/examples/screenshotting/ @elastic/kibana-reporting-services @elastic/kibana-app-services
/x-pack/test/functional/es_archives/lens/reporting/ @elastic/kibana-reporting-services @elastic/kibana-app-services
/x-pack/test/functional/es_archives/reporting/ @elastic/kibana-reporting-services @elastic/kibana-app-services
/x-pack/test/functional/fixtures/kbn_archiver/reporting/ @elastic/kibana-reporting-services @elastic/kibana-app-services
Expand Down
12 changes: 4 additions & 8 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,11 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "build_bazel_rules_nodejs",
patch_args = ["-p1"],
patches = ["//:src/dev/bazel/rules_nodejs_patches/exclude_npm_directory_copies_from_remote_cache.patch"],
sha256 = "2b2004784358655f334925e7eadc7ba80f701144363df949b3293e1ae7a2fb7b",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.4.0/rules_nodejs-5.4.0.tar.gz"],
patches = ["//:src/dev/bazel/rules_nodejs_patches/normalized_paths_for_windows_runfiles.patch"],
sha256 = "6f15d75f9e99c19d9291ff8e64e4eb594a6b7d25517760a75ad3621a7a48c2df",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/4.7.0/rules_nodejs-4.7.0.tar.gz"],
)

# Build Node.js rules dependencies
load("@build_bazel_rules_nodejs//:repositories.bzl", "build_bazel_rules_nodejs_dependencies")
build_bazel_rules_nodejs_dependencies()

# Now that we have the rules let's import from them to complete the work
load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories", "yarn_install")

Expand All @@ -41,7 +37,7 @@ node_repositories(
node_urls = [
"https://nodejs.org/dist/v{version}/{filename}",
],
yarn_releases = {
yarn_repositories = {
"1.21.1": ("yarn-v1.21.1.tar.gz", "yarn-v1.21.1", "d1d9f4a0f16f5ed484e814afeb98f39b82d4728c6c8beaafb5abc99c02db6674"),
},
yarn_version = "1.21.1",
Expand Down
87 changes: 87 additions & 0 deletions dev_docs/tutorials/screenshotting.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
---
id: kibDevTutorialScreenshotting
slug: /kibana-dev-docs/tutorials/screenshotting
title: Kibana Screenshotting Service
summary: Kibana Screenshotting Service
date: 2022-04-12
tags: ['kibana', 'onboarding', 'dev', 'architecture']
---

## Screenshotting Plugin

This plugin provides functionality to take screenshots of the Kibana pages.
It uses Chromium and Puppeteer underneath to run the browser in headless mode.

If you are planning to integrate with the screenshotting plugin, please get in touch with the App Services team to know all the limitations.

### Capabilities
- Canvas workpads screenshots.
- Dashboards screenshots.
- Expressions screenshots.
- PDF generation.
- Batch screenshotting.

### Usage
After listing the `screenshotting` plugin in your dependencies, the plugin will be intitalized on the setup stage.
The intitalization process downloads (if it is not already present) and verifies the Chromium build.

The start contract exposes a public API to interact with the plugin.
Apart from the actual screenshotting functionality, it also provides a way for self-diagnostics.

Here is an example of how you can take a screenshot of a Kibana URL.


```typescript
import { lastValueFrom } from 'rxjs';
import type { CoreSetup, Plugin } from 'src/core/server';
import type { ScreenshottingStart } from 'x-pack/plugins/screenshotting/server';


interface StartDeps {
screenshotting: ScreenshottingStart;
}

class ExamplePlugin implements Plugin<void, void, void, StartDeps> {
setup({ http, getStartServices }: CoreSetup<StartDeps>) {
const router = http.createRouter();

router.get(
{
path: '/api/capture',
validate: {
query: schema.object({
id: schema.string(),
}),
},
},
async (context, request, response) => {
const [, { screenshotting }] = await getStartServices();
const { metrics, results } = await lastValueFrom(
screenshotting.getScreenshots({
request,
urls: [`http://localhost/app/canvas#/workpad/workpad-${request.query.id}`],
})
);

return response.ok({
body: JSON.stringify({
metrics,
image: results[0]?.screenshots[0]?.data.toString('base64'),
errors: results[0]?.renderErrors,
} as ScreenshottingExpressionResponse),
});
}
);
}

start() {}
}

export function plugin() {
return new ExamplePlugin();
}
```

<DocCallOut>
Check the complete API reference <DocLink id="kibScreenshottingPluginApi" text="here" />.
</DocCallOut>
11 changes: 7 additions & 4 deletions docs/api/cases.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,19 @@ these APIs:
* <<cases-api-create>>
* <<cases-api-delete-cases>>
* <<cases-api-delete-comments>>
* {security-guide}/cases-api-find-alert.html[Find all alerts attached to a case]
* <<cases-api-find-cases>>
* {security-guide}/cases-api-find-cases-by-alert.html[Find cases by alert]
* <<cases-api-find-connectors>>
* <<cases-api-get-alerts>>
* <<cases-api-get-case-activity>>
* <<cases-api-get-case>>
* <<cases-api-get-status>>
* <<cases-api-get-cases-by-alert>>
* <<cases-api-get-comments>>
* <<cases-get-configuration>>
* <<cases-api-get-reporters>>
* <<cases-api-get-tag>>
* {security-guide}/cases-api-push.html[Push case]
* <<cases-api-push>>
* <<cases-api-set-configuration>>
* {security-guide}/case-api-update-connector.html[Update case configurations]
* <<cases-api-update>>
* <<cases-api-update-comment>>
* <<cases-api-update-configuration>>
Expand All @@ -37,13 +36,17 @@ include::cases/cases-api-delete-comments.asciidoc[leveloffset=+1]
include::cases/cases-api-find-cases.asciidoc[leveloffset=+1]
include::cases/cases-api-find-connectors.asciidoc[leveloffset=+1]
//GET
include::cases/cases-api-get-alerts.asciidoc[leveloffset=+1]
include::cases/cases-api-get-case-activity.asciidoc[leveloffset=+1]
include::cases/cases-api-get-case.asciidoc[leveloffset=+1]
include::cases/cases-api-get-status.asciidoc[leveloffset=+1]
include::cases/cases-api-get-cases-by-alert.asciidoc[leveloffset=+1]
include::cases/cases-api-get-comments.asciidoc[leveloffset=+1]
include::cases/cases-api-get-configuration.asciidoc[leveloffset=+1]
include::cases/cases-api-get-reporters.asciidoc[leveloffset=+1]
include::cases/cases-api-get-tags.asciidoc[leveloffset=+1]
//PUSH
include::cases/cases-api-push.asciidoc[leveloffset=+1]
//SET
include::cases/cases-api-set-configuration.asciidoc[leveloffset=+1]
//UPDATE
Expand Down
60 changes: 60 additions & 0 deletions docs/api/cases/cases-api-get-alerts.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
[[cases-api-get-alerts]]
== Get alerts attached to case API
++++
<titleabbrev>Get alerts</titleabbrev>
++++

preview::[]

Gets all alerts attached to a case.

=== {api-request-title}

`GET <kibana host>:<port>/api/cases/<case_id>/alerts`

`GET <kibana host>:<port>/s/<space_id>/api/cases/<case_id>/alerts`

=== {api-prereq-title}

You must have `read` privileges for the *Cases* feature in the *Management*,
*{observability}*, or *Security* section of the
<<kibana-feature-privileges,{kib} feature privileges>>, depending on the
`owner` of the cases you're seeking.

=== {api-path-parms-title}

`<case_id>`::
(Required, string) The identifier for the case. To retrieve case IDs, use
<<cases-api-find-cases>>.

`<space_id>`::
(Optional, string) An identifier for the space. If it is not specified, the
default space is used.

=== {api-response-codes-title}

`200`::
Indicates a successful call.

=== {api-example-title}

Return all alerts attached to case `293f1bc0-74f6-11ea-b83a-553aecdb28b6`:

[source,sh]
--------------------------------------------------
GET api/cases/293f1bc0-74f6-11ea-b83a-553aecdb28b6/alerts
--------------------------------------------------
// KIBANA

The API returns a JSON array listing the alerts. For example:

[source,json]
--------------------------------------------------
[
{
"id": "09f0c261e39e36351d75995b78bb83673774d1bc2cca9df2d15f0e5c0a99a540",
"index": ".internal.alerts-security.alerts-default-000001",
"attached_at": "2022-04-13T21:35:24.602Z"
}
]
--------------------------------------------------
72 changes: 72 additions & 0 deletions docs/api/cases/cases-api-get-cases-by-alert.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
[[cases-api-get-cases-by-alert]]
== Get cases by alert API
++++
<titleabbrev>Get cases by alert</titleabbrev>
++++

preview::[]

Returns the cases associated with a specific alert.

=== {api-request-title}

`GET <kibana host>:<port>/api/cases/alerts/<alert_id>`

`GET <kibana host>:<port>/s/<space_id>/api/cases/alerts/<alert_id>`

=== {api-prereq-title}

You must have `read` privileges for the *Cases* feature in the *Management*,
*{observability}*, or *Security* section of the
<<kibana-feature-privileges,{kib} feature privileges>>, depending on the
`owner` of the cases you're seeking.

=== {api-path-parms-title}

`<alert_id>`::
(Required, string) The alert identifier.

`<space_id>`::
(Optional, string) An identifier for the space. If it is not specified, the
default space is used.

=== {api-query-parms-title}

`owner`::
(Optional, string or array of strings) A filter to limit the retrieved cases to
a specific set of applications. Valid values are: `cases`, `observability`,
and `securitySolution`. If this parameter is omitted, the response contains all
cases that the user has access to read.

=== {api-response-codes-title}

`200`::
Indicates a successful call.

=== {api-example-title}

Return cases associated with the alert ID
`09f0c261e39e36351d75995b78bb83673774d1bc2cca9df2d15f0e5c0a99a540`:

[source,sh]
--------------------------------------------------
GET api/cases/alerts/09f0c261e39e36351d75995b78bb83673774d1bc2cca9df2d15f0e5c0a99a540
--------------------------------------------------
// KIBANA

The API returns a JSON array containing the identifier and title of the cases.
For example:

[source,json]
--------------------------------------------------
[
{
"id": "8af6ac20-74f6-11ea-b83a-553aecdb28b6",
"title": "Case 1"
},
{
"id": "a18b38a0-71b0-11ea-a0b2-c51ea50a58e2",
"title": "Case 2"
}
]
--------------------------------------------------
Loading

0 comments on commit 0501e99

Please sign in to comment.