Using Kibana Canvas
1. Understanding Canvas
Example: Basic Canvas Expression
{"type": "canvas", "expression": "data() | filter "}
| Property | Description | Values |
|---|---|---|
| type | Defines the type of Kibana object | "canvas" |
| expression | Defines the expression to execute in Canvas | "data() | filter " |
Note: Canvas expressions are built using a domain-specific language (DSL) that allows for complex data transformations and visualizations.
2. Creating Canvas Workpads
Example: Basic Canvas Workpad Structure
{
"title": "My Workpad",
"version": 1,
"objects": [
{
"id": "chart-1",
"type": "visualization",
"params": {
"visType": "area",
"data": {
"query": "match_all()"
}
}
}
]
}
| Property | Description | Values |
|---|---|---|
| title | Name of the workpad | string |
| version | Canvas version (currently 1) | number |
| objects | List of visualizations and layouts | array |
Note: Workpads are saved as JSON documents in Kibana's canvas workspace.
Workflow: Creating a New Canvas Workpad
- Navigate to Kibana > Canvas
- Click
+ New Workpad - Set title and version
- Add visualization objects using the UI or JSON editor
- Save and preview workpad
3. Adding Elements
Example: Adding a Text Element
{
"name": "myCanvas",
"elements": [
{
"type": "text",
"content": "Hello, Kibana Canvas!",
"position": {
"x": 10,
"y": 10
},
"size": {
"width": 200,
"height": 50
}
}
]
}
| Property | Description | Values |
|---|---|---|
| type | Element type | text, image, chart |
| content | Content to display (for text elements) | string |
| position.x | X coordinate of element | number |
| position.y | Y coordinate of element | number |
| size.width | Width of element | number |
| size.height | Height of element | number |
Note: Canvas elements are positioned absolutely within the canvas area.
Example: Adding a Chart Element
{
"name": "salesChart",
"elements": [
{
"type": "chart",
"data": "salesData",
"chartType": "bar",
"position": {
"x": 250,
"y": 50
},
"size": {
"width": 400,
"height": 300
}
}
]
}
4. Using Data Sources
Example: Configuring a Data Source in Kibana Canvas
{
"dataSources": [
{
"name": "sales_data",
"type": "elasticsearch",
"index": "sales-2025",
"query": {
"size": 1000,
"query": {
"range": {
"date": {
"gte": "2025-01-01",
"lt": "2025-12-31"
}
}
}
}
}
]
}
| Data Source Type | Description | Usage |
|---|---|---|
| elasticsearch | Connects to Elasticsearch indices | Used for querying and visualizing log data |
| search | Performs search queries on Elasticsearch | Allows filtering and aggregation of data |
| saved_search | Uses a saved search from Kibana | Reuses existing Kibana search queries |
Note: Data sources in Kibana Canvas must be defined within the
dataSources array of a Canvas template.
Warning: Ensure that the Elasticsearch index specified in the data source has proper mappings to avoid query errors.
5. Configuring Element Expressions
| Property | Description | Values | Notes |
|---|---|---|---|
| element | Defines the type of element to render | text, image, chart, table |
Required field for all elements |
| label | Human-readable label for the element | string |
Used in UI for identification |
| expression | Expression defining how to compute or display data | string |
Can use Kibana Canvas DSL or Elasticsearch queries |
| style | Styling properties for the element | object |
Supports color, size, font, etc. |
Example: Text Element with Expression
{
"element": "text",
"label": "Total Logs",
"expression": "count(logs)",
"style": {
"fontSize": "16px",
"color": "#007bff"
}
}
Example: Chart Element with Expression
{
"element": "chart",
"label": "Log Volume Over Time",
"expression": "timeseries(logs)",
"style": {
"width": "100%",
"height": "300px"
}
}
6. Using Canvas Functions
| Function | Description | Parameters | Example |
|---|---|---|---|
| canvas.add | Adds a new element to the canvas | element, position |
canvas.add("rectangle", { x: 10, y: 10 }) |
| canvas.image | Inserts an image into the canvas | url, position |
canvas.image("https://example.com/image.png", { x: 0, y: 0 }) |
| canvas.text | Adds a text element to the canvas | text, position, style |
canvas.text("Hello World", { x: 50, y: 50 }, { fontSize: 16 }) |
| canvas.shape | Draws a shape (rectangle, circle, etc.) | type, position, size |
canvas.shape("circle", { x: 100, y: 100 }, { radius: 50 }) |
Example: Creating a Canvas with Text and Shape
const canvas = new KibanaCanvas();
canvas.text("Welcome to Kibana Canvas", { x: 10, y: 10 });
canvas.shape("rectangle", { x: 10, y: 30 }, { width: 200, height: 50 });
7. Styling Elements
| Property | Description | Values | Notes |
|---|---|---|---|
| color | Text or background color | "#FF0000", "red", "rgb(255, 0, 0)" |
Supports hex, named colors, and RGB values |
| fontSize | Size of the font | 12, "14px" |
Can be specified in pixels or numeric values |
| fontFamily | Font family to use | "Arial", "Helvetica" |
Must be a valid font name or family |
| fontWeight | Font weight (bold, normal, etc.) | "normal", "bold" |
Supports standard CSS font weights |
| textAlign | Text alignment within the element | "left", "center", "right" |
Aligns text inside the element |
| border | Border style and properties | "1px solid #000" |
Accepts standard CSS border syntax |
Example: Applying Styles to Text
const textElement = {
type: "text",
content: "Hello World",
style: {
color: "#FF0000",
fontSize: 16,
fontWeight: "bold"
}
};
Example: Styling a Rectangle
const rectangle = {
type: "rectangle",
width: 100,
height: 50,
style: {
color: "blue",
border: "2px solid black"
}
};
8. Creating Reusable Elements
Example: Creating a Reusable Canvas Element
// Define a reusable element for a Kibana Canvas
const reusableElement = {
name: "salesReportCard",
type: "canvasElement",
properties: {
title: "Sales Report",
width: 300,
height: 200
},
content: {
type: "text",
value: "Quarterly Sales Summary"
}
};
console.log("Reusable element defined:", reusableElement);
| Property | Description | Value Type | Notes |
|---|---|---|---|
| name | Unique identifier for the element | string |
Must be unique within the Kibana instance |
| type | Element type definition | string |
Must be canvasElement |
| properties | Configuration options for the element | object |
Includes title, dimensions, etc. |
| content | Content to display in the element | object |
Can be text, image, or chart |
Note: Reusable elements can be shared across multiple Kibana Canvas workspaces.
Warning: Changes to a reusable element will update all instances where it is used.
Best Practices for Reusable Elements
- Use descriptive names to identify the purpose of each element
- Define consistent properties for similar elements
- Test elements in different contexts before deploying
- Document element usage and dependencies
9. Using Variables
| Property | Description | Values |
|---|---|---|
| name | Name of the variable | string |
| value | Value assigned to the variable | string |
Note: Variables in Kibana Canvas are used to store and reuse values across different parts of a canvas expression.
10. Configuring Auto-Refresh
| Setting | Description | Default Value | Notes |
|---|---|---|---|
| autoRefresh | Enables or disables auto-refresh in Kibana Canvas | false |
Set to true to enable automatic refresh |
| autoRefreshInterval | Time interval (in seconds) between auto-refreshes | 30 |
Valid range: 1 to 3600 seconds |
Note: Auto-refresh is useful for dashboards that require real-time data updates. Adjust the interval to balance between responsiveness and performance.
11. Exporting Canvas
| Option | Values | Description |
|---|---|---|
| export.format | png, pdf, svg |
Format to export the Canvas as |
| export.width | 1024, 1920 |
Width in pixels for PNG/PDF export |
| export.height | 768, 1080 |
Height in pixels for PNG/PDF export |
Note: PDF exports support embedded fonts and high-resolution rendering for print-quality outputs.
12. Sharing Workpads
| Option | Values | Notes |
|---|---|---|
| workpad.share | true |
Enable sharing of workpads |
| workpad.public | false |
Make workpad publicly accessible |
| workpad.access | private |
Access level: private, restricted, or public |
Example: Sharing a Workpad
{
"title": "Sales Report",
"share": {
"public": true,
"access": "public"
}
}
Note: Public workpads are accessible to anyone with the URL. Use carefully.
Warning: Sharing workpads publicly may expose sensitive data. Ensure appropriate access controls are in place.