-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into add_execution_context
- Loading branch information
Showing
214 changed files
with
5,495 additions
and
3,053 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
] | ||
-------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
] | ||
-------------------------------------------------- |
Oops, something went wrong.