From 2edb6e6b9d1e8e1d6f181ca05a324dbe03adf028 Mon Sep 17 00:00:00 2001 From: Florent LB Date: Thu, 16 Apr 2026 22:16:43 +0200 Subject: [PATCH] [Docs][Dashboards API] Add request and response examples for all 5 endpoints (#262865) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary - Adds cURL and Console code samples (`x-codeSamples`) to all 5 Dashboards API endpoints (POST, GET `/{id}`, PUT `/{id}`, DELETE `/{id}`, GET `_find`) - POST includes two examples: simple dashboard (markdown + 2 metrics + ES|QL line chart) and a structured dashboard with sections and controls - Adds inlined response examples for POST (201), GET (200), PUT (200), and GET `_find` (200) All examples tested against a live Kibana 9.4.0 instance using the Kibana sample logs dataset (`kibana_sample_data_logs`). Follows the grid best practices documented in the tag description (PR #262396). Part of the Dashboards API documentation series: #262396 (merged) → descriptions (#263166, #263281, #263282, #263283) → this PR. ## Preview https://bump.sh/elastic/hub/elastic-apis/doc/dashboards-api-cleanup-intro-and-get-started/group/endpoint-dashboards ## Test plan - [ ] Generate Bump preview and verify code samples appear in upper right dropdown for each endpoint - [ ] Verify response examples appear in the Responses section - [ ] Confirm all JSON in code samples is fully expanded (no inline objects) 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Sonnet 4.6 (1M context) (cherry picked from commit f6059b02aca72b0978a1da87a5c74ccb60e26325) --- oas_docs/overlays/dashboards.overlays.yaml | 1358 +++++++++++++++++++- 1 file changed, 1357 insertions(+), 1 deletion(-) diff --git a/oas_docs/overlays/dashboards.overlays.yaml b/oas_docs/overlays/dashboards.overlays.yaml index 1dafe32cd9328..fe28c85226651 100644 --- a/oas_docs/overlays/dashboards.overlays.yaml +++ b/oas_docs/overlays/dashboards.overlays.yaml @@ -172,7 +172,7 @@ actions: To create ES|QL-based charts, embed them inline as `vis` panels and set `data_source.type` to `"esql"`. - - **`metric` charts**: reference query result columns in `metrics` using `operation: "value"` and `column`: + - **`metric` charts**: reference query result columns in `metrics` using `column`: ```json { @@ -206,3 +206,1359 @@ actions: description: Dashboards documentation url: https://www.elastic.co/docs/explore-analyze/dashboards x-displayName: Dashboards + + # ────────────────────────────────────────────── + # POST /api/dashboards — examples and code samples + # ────────────────────────────────────────────── + - target: "$.paths['/api/dashboards']['post']" + description: Add examples and code samples to create endpoint + update: + responses: + '201': + content: + application/json: + examples: + createDashboardResponse: + summary: Create dashboard response + description: > + Response to creating a dashboard. Returns the generated ID, the full dashboard state + in `data`, and metadata. Default option values are always returned even when not + explicitly set in the request. Panel `id` values are generated automatically. + value: + id: 3c4b8e10-d57a-11ef-9a52-4f3c2a8d0e1b + data: + options: + hide_panel_titles: false + hide_panel_borders: false + use_margins: true + auto_apply_filters: true + sync_colors: false + sync_cursor: true + sync_tooltips: false + panels: + - grid: + x: 0 + y: 0 + w: 24 + h: 15 + config: + content: "## Web logs overview\n\n \n\nCreated with the [Dashboards API](https://www.elastic.co/docs/api/doc/kibana) using the Kibana sample web logs dataset (`kibana_sample_data_logs`). Contains:\n- This markdown panel\n- 2 metrics, showing request count and average response size\n- A line chart based on an ES|QL query\n\n \n\n \n\n[Learn more about dashboards](https://www.elastic.co/docs/explore-analyze/dashboards)" + id: a1b2c3d4-0001-4000-8000-000000000001 + type: markdown + - grid: + x: 24 + y: 0 + w: 12 + h: 5 + config: + title: "" + data_source: + type: data_view_spec + index_pattern: kibana_sample_data_logs + time_field: timestamp + type: metric + sampling: 1 + ignore_global_filters: false + metrics: + - type: primary + operation: count + empty_as_null: false + styling: + primary: + position: bottom + labels: + alignment: left + value: + sizing: auto + alignment: right + id: a1b2c3d4-0001-4000-8000-000000000002 + type: vis + - grid: + x: 36 + y: 0 + w: 12 + h: 5 + config: + title: "" + data_source: + type: data_view_spec + index_pattern: kibana_sample_data_logs + time_field: timestamp + type: metric + sampling: 1 + ignore_global_filters: false + metrics: + - type: primary + operation: average + field: bytes + styling: + primary: + position: bottom + labels: + alignment: left + value: + sizing: auto + alignment: right + id: a1b2c3d4-0001-4000-8000-000000000003 + type: vis + - grid: + x: 24 + y: 5 + w: 24 + h: 10 + config: + title: Requests over time + type: xy + layers: + - type: line + data_source: + type: esql + query: "FROM kibana_sample_data_logs | STATS count = COUNT() BY @timestamp = BUCKET(@timestamp, 75, ?_tstart, ?_tend)" + sampling: 1 + ignore_global_filters: false + x: + column: "@timestamp" + y: + - column: count + axis_id: "y" + axis: + x: + title: + visible: true + ticks: + visible: true + grid: + visible: true + domain: + type: fit + rounding: false + labels: + orientation: horizontal + scale: ordinal + y: + anchor: start + title: + visible: true + scale: linear + ticks: + visible: true + grid: + visible: true + domain: + type: full + rounding: true + labels: + orientation: horizontal + styling: + overlays: + partial_buckets: + visible: false + current_time_marker: + visible: false + interpolation: linear + points: + visibility: auto + legend: + visibility: hidden + placement: outside + position: right + layout: + type: grid + truncate: + max_lines: 1 + id: a1b2c3d4-0001-4000-8000-000000000003 + type: vis + pinned_panels: [] + title: Web logs overview + meta: + created_at: "2026-04-13T10:00:00.000Z" + managed: false + updated_at: "2026-04-13T10:00:00.000Z" + version: WzEwMiwxXQ== + x-codeSamples: + - lang: cURL + label: Create a dashboard (simple) - cURL + source: | + curl -X POST "${KIBANA_URL}/api/dashboards" \ + -H "Authorization: ApiKey ${API_KEY}" \ + -H "kbn-xsrf: true" \ + -H "Content-Type: application/json" \ + -d '{ + "title": "Web logs overview", + "panels": [ + { + "grid": { + "x": 0, + "y": 0, + "w": 24, + "h": 15 + }, + "type": "markdown", + "config": { + "content": "## Web logs overview\n\n \n\nCreated with the [Dashboards API](https://www.elastic.co/docs/api/doc/kibana) using the Kibana sample web logs dataset (`kibana_sample_data_logs`). Contains:\n- This markdown panel\n- 2 metrics, showing request count and average response size\n- A line chart based on an ES|QL query\n\n \n\n \n\n[Learn more about dashboards](https://www.elastic.co/docs/explore-analyze/dashboards)" + } + }, + { + "grid": { + "x": 24, + "y": 0, + "w": 12, + "h": 5 + }, + "type": "vis", + "config": { + "type": "metric", + "data_source": { + "type": "data_view_spec", + "index_pattern": "kibana_sample_data_logs", + "time_field": "timestamp" + }, + "metrics": [ + { + "type": "primary", + "operation": "count" + } + ] + } + }, + { + "grid": { + "x": 36, + "y": 0, + "w": 12, + "h": 5 + }, + "type": "vis", + "config": { + "type": "metric", + "data_source": { + "type": "data_view_spec", + "index_pattern": "kibana_sample_data_logs", + "time_field": "timestamp" + }, + "metrics": [ + { + "type": "primary", + "operation": "average", + "field": "bytes" + } + ] + } + }, + { + "grid": { + "x": 24, + "y": 5, + "w": 24, + "h": 10 + }, + "type": "vis", + "config": { + "type": "xy", + "title": "Requests over time", + "layers": [ + { + "type": "line", + "data_source": { + "type": "esql", + "query": "FROM kibana_sample_data_logs | STATS count = COUNT() BY @timestamp = BUCKET(@timestamp, 75, ?_tstart, ?_tend)" + }, + "x": { + "column": "@timestamp" + }, + "y": [ + { + "column": "count" + } + ] + } + ] + } + } + ] + }' + - lang: Console + label: Create a dashboard (simple) - Console + source: | + POST kbn:/api/dashboards + { + "title": "Web logs overview", + "panels": [ + { + "grid": { + "x": 0, + "y": 0, + "w": 24, + "h": 15 + }, + "type": "markdown", + "config": { + "content": "## Web logs overview\n\n \n\nCreated with the [Dashboards API](https://www.elastic.co/docs/api/doc/kibana) using the Kibana sample web logs dataset (`kibana_sample_data_logs`). Contains:\n- This markdown panel\n- 2 metrics, showing request count and average response size\n- A line chart based on an ES|QL query\n\n \n\n \n\n[Learn more about dashboards](https://www.elastic.co/docs/explore-analyze/dashboards)" + } + }, + { + "grid": { + "x": 24, + "y": 0, + "w": 12, + "h": 5 + }, + "type": "vis", + "config": { + "type": "metric", + "data_source": { + "type": "data_view_spec", + "index_pattern": "kibana_sample_data_logs", + "time_field": "timestamp" + }, + "metrics": [ + { + "type": "primary", + "operation": "count" + } + ] + } + }, + { + "grid": { + "x": 36, + "y": 0, + "w": 12, + "h": 5 + }, + "type": "vis", + "config": { + "type": "metric", + "data_source": { + "type": "data_view_spec", + "index_pattern": "kibana_sample_data_logs", + "time_field": "timestamp" + }, + "metrics": [ + { + "type": "primary", + "operation": "average", + "field": "bytes" + } + ] + } + }, + { + "grid": { + "x": 24, + "y": 5, + "w": 24, + "h": 10 + }, + "type": "vis", + "config": { + "type": "xy", + "title": "Requests over time", + "layers": [ + { + "type": "line", + "data_source": { + "type": "esql", + "query": "FROM kibana_sample_data_logs | STATS count = COUNT() BY @timestamp = BUCKET(@timestamp, 75, ?_tstart, ?_tend)" + }, + "x": { + "column": "@timestamp" + }, + "y": [ + { + "column": "count" + } + ] + } + ] + } + } + ] + } + - lang: cURL + label: Create a dashboard (with sections and controls) - cURL + source: | + curl -X POST "${KIBANA_URL}/api/dashboards" \ + -H "Authorization: ApiKey ${API_KEY}" \ + -H "kbn-xsrf: true" \ + -H "Content-Type: application/json" \ + -d '{ + "title": "Operations overview", + "time_range": { + "from": "now-7d", + "to": "now" + }, + "pinned_panels": [ + { + "type": "options_list_control", + "width": "medium", + "grow": true, + "config": { + "title": "Response code", + "data_view_id": "90943e30-9a47-11e8-b64d-95841ca0b247", + "field_name": "response.keyword" + } + } + ], + "panels": [ + { + "title": "Key metrics", + "collapsed": false, + "grid": { + "y": 0 + }, + "panels": [ + { + "grid": { + "x": 0, + "y": 0, + "w": 12, + "h": 5 + }, + "type": "vis", + "config": { + "type": "metric", + "title": "Total requests", + "data_source": { + "type": "data_view_spec", + "index_pattern": "kibana_sample_data_logs", + "time_field": "timestamp" + }, + "metrics": [ + { + "type": "primary", + "operation": "count" + } + ] + } + }, + { + "grid": { + "x": 12, + "y": 0, + "w": 12, + "h": 5 + }, + "type": "vis", + "config": { + "type": "metric", + "title": "Average response size", + "data_source": { + "type": "data_view_spec", + "index_pattern": "kibana_sample_data_logs", + "time_field": "timestamp" + }, + "metrics": [ + { + "type": "primary", + "operation": "average", + "field": "bytes" + } + ] + } + } + ] + }, + { + "title": "Traffic trends", + "collapsed": false, + "grid": { + "y": 8 + }, + "panels": [ + { + "grid": { + "x": 0, + "y": 0, + "w": 24, + "h": 10 + }, + "type": "vis", + "config": { + "type": "xy", + "title": "Requests over time", + "layers": [ + { + "type": "line", + "data_source": { + "type": "data_view_spec", + "index_pattern": "kibana_sample_data_logs", + "time_field": "timestamp" + }, + "x": { + "operation": "date_histogram", + "field": "timestamp" + }, + "y": [ + { + "operation": "count" + } + ] + } + ] + } + }, + { + "grid": { + "x": 24, + "y": 0, + "w": 24, + "h": 10 + }, + "type": "vis", + "config": { + "type": "xy", + "title": "Requests over time (ES|QL)", + "layers": [ + { + "type": "line", + "data_source": { + "type": "esql", + "query": "FROM kibana_sample_data_logs | STATS count = COUNT() BY @timestamp = BUCKET(@timestamp, 75, ?_tstart, ?_tend)" + }, + "x": { + "column": "@timestamp" + }, + "y": [ + { + "column": "count" + } + ] + } + ] + } + } + ] + } + ] + }' + - lang: Console + label: Create a dashboard (with sections and controls) - Console + source: | + POST kbn:/api/dashboards + { + "title": "Operations overview", + "time_range": { + "from": "now-7d", + "to": "now" + }, + "pinned_panels": [ + { + "type": "options_list_control", + "width": "medium", + "grow": true, + "config": { + "title": "Response code", + "data_view_id": "90943e30-9a47-11e8-b64d-95841ca0b247", + "field_name": "response.keyword" + } + } + ], + "panels": [ + { + "title": "Key metrics", + "collapsed": false, + "grid": { + "y": 0 + }, + "panels": [ + { + "grid": { + "x": 0, + "y": 0, + "w": 12, + "h": 5 + }, + "type": "vis", + "config": { + "type": "metric", + "title": "Total requests", + "data_source": { + "type": "data_view_spec", + "index_pattern": "kibana_sample_data_logs", + "time_field": "timestamp" + }, + "metrics": [ + { + "type": "primary", + "operation": "count" + } + ] + } + }, + { + "grid": { + "x": 12, + "y": 0, + "w": 12, + "h": 5 + }, + "type": "vis", + "config": { + "type": "metric", + "title": "Average response size", + "data_source": { + "type": "data_view_spec", + "index_pattern": "kibana_sample_data_logs", + "time_field": "timestamp" + }, + "metrics": [ + { + "type": "primary", + "operation": "average", + "field": "bytes" + } + ] + } + } + ] + }, + { + "title": "Traffic trends", + "collapsed": false, + "grid": { + "y": 8 + }, + "panels": [ + { + "grid": { + "x": 0, + "y": 0, + "w": 24, + "h": 10 + }, + "type": "vis", + "config": { + "type": "xy", + "title": "Requests over time", + "layers": [ + { + "type": "line", + "data_source": { + "type": "data_view_spec", + "index_pattern": "kibana_sample_data_logs", + "time_field": "timestamp" + }, + "x": { + "operation": "date_histogram", + "field": "timestamp" + }, + "y": [ + { + "operation": "count" + } + ] + } + ] + } + }, + { + "grid": { + "x": 24, + "y": 0, + "w": 24, + "h": 10 + }, + "type": "vis", + "config": { + "type": "xy", + "title": "Requests over time (ES|QL)", + "layers": [ + { + "type": "line", + "data_source": { + "type": "esql", + "query": "FROM kibana_sample_data_logs | STATS count = COUNT() BY @timestamp = BUCKET(@timestamp, 75, ?_tstart, ?_tend)" + }, + "x": { + "column": "@timestamp" + }, + "y": [ + { + "column": "count" + } + ] + } + ] + } + } + ] + } + ] + } + + # ────────────────────────────────────────────── + # GET /api/dashboards — examples and code samples + # ────────────────────────────────────────────── + - target: "$.paths['/api/dashboards']['get']" + description: Add examples and code samples to search endpoint + update: + responses: + '200': + content: + application/json: + examples: + searchDashboardsResponse: + summary: Search dashboards response + description: > + Paginated list of dashboard summaries. Each item includes the ID, a subset of + dashboard state fields (`title`, `time_range` if set), and metadata. Full panel + content is not included — use the GET endpoint to retrieve a specific dashboard. + value: + dashboards: + - id: 3c4b8e10-d57a-11ef-9a52-4f3c2a8d0e1b + data: + title: Web logs overview + meta: + created_at: "2026-04-13T10:00:00.000Z" + managed: false + updated_at: "2026-04-13T10:00:00.000Z" + version: WzEwMiwxXQ== + - id: 7f2a1c40-e83b-11ef-a641-7d5b3f9e1c2a + data: + time_range: + from: now-7d + to: now + title: Operations overview + meta: + created_at: "2026-04-12T08:00:00.000Z" + managed: false + updated_at: "2026-04-12T14:22:00.000Z" + version: WzEwMSwxXQ== + page: 1 + total: 2 + x-codeSamples: + - lang: cURL + label: Search dashboards - cURL + source: | + curl -X GET "${KIBANA_URL}/api/dashboards?query=web+logs&per_page=10" \ + -H "Authorization: ApiKey ${API_KEY}" + - lang: Console + label: Search dashboards - Console + source: | + GET kbn:/api/dashboards?query=web+logs&per_page=10 + + # ────────────────────────────────────────────── + # GET /api/dashboards/{id} — examples and code samples + # ────────────────────────────────────────────── + - target: "$.paths['/api/dashboards/{id}']['get']" + description: Add examples and code samples to get endpoint + update: + responses: + '200': + content: + application/json: + examples: + getDashboardResponse: + summary: Get dashboard response + description: > + The full dashboard state including all panels, options, and metadata. + value: + id: 3c4b8e10-d57a-11ef-9a52-4f3c2a8d0e1b + data: + options: + hide_panel_titles: false + hide_panel_borders: false + use_margins: true + auto_apply_filters: true + sync_colors: false + sync_cursor: true + sync_tooltips: false + title: Web logs overview + panels: + - grid: + x: 0 + y: 0 + w: 12 + h: 8 + config: + title: Total requests + data_source: + type: data_view_spec + index_pattern: kibana_sample_data_logs + time_field: timestamp + type: metric + sampling: 1 + ignore_global_filters: false + metrics: + - type: primary + operation: count + empty_as_null: false + styling: + primary: + position: bottom + labels: + alignment: left + value: + sizing: auto + alignment: right + id: a1b2c3d4-0001-4000-8000-000000000001 + type: vis + - grid: + x: 12 + y: 0 + w: 12 + h: 8 + config: + title: Average response size + data_source: + type: data_view_spec + index_pattern: kibana_sample_data_logs + time_field: timestamp + type: metric + sampling: 1 + ignore_global_filters: false + metrics: + - type: primary + operation: average + field: bytes + styling: + primary: + position: bottom + labels: + alignment: left + value: + sizing: auto + alignment: right + id: a1b2c3d4-0001-4000-8000-000000000002 + type: vis + - grid: + x: 0 + y: 15 + w: 24 + h: 10 + config: + title: Requests over time + type: xy + layers: + - type: line + data_source: + type: esql + query: "FROM kibana_sample_data_logs | STATS count = COUNT() BY @timestamp = BUCKET(@timestamp, 75, ?_tstart, ?_tend)" + sampling: 1 + ignore_global_filters: false + x: + column: "@timestamp" + y: + - column: count + axis_id: "y" + axis: + x: + title: + visible: true + ticks: + visible: true + grid: + visible: true + domain: + type: fit + rounding: false + labels: + orientation: horizontal + scale: ordinal + y: + anchor: start + title: + visible: true + scale: linear + ticks: + visible: true + grid: + visible: true + domain: + type: full + rounding: true + labels: + orientation: horizontal + styling: + overlays: + partial_buckets: + visible: false + current_time_marker: + visible: false + interpolation: linear + points: + visibility: auto + legend: + visibility: hidden + placement: outside + position: right + layout: + type: grid + truncate: + max_lines: 1 + id: a1b2c3d4-0001-4000-8000-000000000003 + type: vis + pinned_panels: [] + meta: + created_at: "2026-04-13T10:00:00.000Z" + managed: false + updated_at: "2026-04-13T10:00:00.000Z" + version: WzEwMiwxXQ== + x-codeSamples: + - lang: cURL + label: Get a dashboard - cURL + source: | + curl -X GET "${KIBANA_URL}/api/dashboards/3c4b8e10-d57a-11ef-9a52-4f3c2a8d0e1b" \ + -H "Authorization: ApiKey ${API_KEY}" + - lang: Console + label: Get a dashboard - Console + source: | + GET kbn:/api/dashboards/3c4b8e10-d57a-11ef-9a52-4f3c2a8d0e1b + + # ────────────────────────────────────────────── + # PUT /api/dashboards/{id} — examples and code samples + # ────────────────────────────────────────────── + - target: "$.paths['/api/dashboards/{id}']['put']" + description: Add description note and examples to update endpoint + update: + description: | + Creates a new dashboard with the given ID if none exists, or replaces the complete state of an + existing one. + + > warn + > This is a full replacement. Any panels not included in the request body are permanently + > removed. To make targeted changes, retrieve the current state first with + > GET /api/dashboards/{id}, apply your changes, and submit the full updated object. + responses: + '200': + content: + application/json: + examples: + updateDashboardResponse: + summary: Update dashboard response + description: > + The complete updated dashboard state after a full replacement. Note that + `meta.created_at` is not returned in update responses — use the GET endpoint + to retrieve it. + value: + id: 3c4b8e10-d57a-11ef-9a52-4f3c2a8d0e1b + data: + options: + hide_panel_titles: false + hide_panel_borders: false + use_margins: true + auto_apply_filters: true + sync_colors: false + sync_cursor: true + sync_tooltips: false + panels: + - grid: + x: 0 + y: 0 + w: 24 + h: 15 + config: + content: "## Web logs overview\n\n \n\nCreated with the [Dashboards API](https://www.elastic.co/docs/api/doc/kibana) using the Kibana sample web logs dataset (`kibana_sample_data_logs`). Contains:\n- This markdown panel\n- 2 metrics, showing request count and average response size\n- A line chart based on an ES|QL query\n\n \n\n \n\n[Learn more about dashboards](https://www.elastic.co/docs/explore-analyze/dashboards)" + id: a1b2c3d4-0001-4000-8000-000000000001 + type: markdown + - grid: + x: 24 + y: 0 + w: 12 + h: 5 + config: + title: "" + data_source: + type: data_view_spec + index_pattern: kibana_sample_data_logs + time_field: timestamp + type: metric + sampling: 1 + ignore_global_filters: false + metrics: + - type: primary + operation: count + empty_as_null: false + styling: + primary: + position: bottom + labels: + alignment: left + value: + sizing: auto + alignment: right + id: a1b2c3d4-0001-4000-8000-000000000002 + type: vis + - grid: + x: 36 + y: 0 + w: 12 + h: 5 + config: + title: "" + data_source: + type: data_view_spec + index_pattern: kibana_sample_data_logs + time_field: timestamp + type: metric + sampling: 1 + ignore_global_filters: false + metrics: + - type: primary + operation: average + field: bytes + styling: + primary: + position: bottom + labels: + alignment: left + value: + sizing: auto + alignment: right + id: a1b2c3d4-0001-4000-8000-000000000003 + type: vis + - grid: + x: 24 + y: 5 + w: 24 + h: 10 + config: + title: Requests over time + type: xy + layers: + - type: line + data_source: + type: esql + query: "FROM kibana_sample_data_logs | STATS count = COUNT() BY @timestamp = BUCKET(@timestamp, 75, ?_tstart, ?_tend)" + sampling: 1 + ignore_global_filters: false + x: + column: "@timestamp" + y: + - column: count + axis_id: "y" + axis: + x: + title: + visible: true + ticks: + visible: true + grid: + visible: true + domain: + type: fit + rounding: false + labels: + orientation: horizontal + scale: ordinal + y: + anchor: start + title: + visible: true + scale: linear + ticks: + visible: true + grid: + visible: true + domain: + type: full + rounding: true + labels: + orientation: horizontal + styling: + overlays: + partial_buckets: + visible: false + current_time_marker: + visible: false + interpolation: linear + points: + visibility: auto + legend: + visibility: hidden + placement: outside + position: right + layout: + type: grid + truncate: + max_lines: 1 + id: a1b2c3d4-0001-4000-8000-000000000003 + type: vis + - grid: + x: 24 + y: 8 + w: 24 + h: 10 + config: + title: Unique visitors + data_source: + type: data_view_spec + index_pattern: kibana_sample_data_logs + time_field: timestamp + type: metric + sampling: 1 + ignore_global_filters: false + metrics: + - type: primary + operation: unique_count + field: clientip + empty_as_null: false + styling: + primary: + position: bottom + labels: + alignment: left + value: + sizing: auto + alignment: right + id: a1b2c3d4-0001-4000-8000-000000000004 + type: vis + pinned_panels: [] + title: Web logs overview + meta: + managed: false + updated_at: "2026-04-13T11:00:00.000Z" + version: WzEwMywxXQ== + x-codeSamples: + - lang: cURL + label: Update a dashboard - cURL + source: | + curl -X PUT "${KIBANA_URL}/api/dashboards/3c4b8e10-d57a-11ef-9a52-4f3c2a8d0e1b" \ + -H "Authorization: ApiKey ${API_KEY}" \ + -H "kbn-xsrf: true" \ + -H "Content-Type: application/json" \ + -d '{ + "title": "Web logs overview", + "panels": [ + { + "grid": { + "x": 0, + "y": 0, + "w": 12, + "h": 5 + }, + "type": "vis", + "config": { + "type": "metric", + "data_source": { + "type": "data_view_spec", + "index_pattern": "kibana_sample_data_logs", + "time_field": "timestamp" + }, + "metrics": [ + { + "type": "primary", + "operation": "count" + } + ] + } + }, + { + "grid": { + "x": 12, + "y": 0, + "w": 12, + "h": 5 + }, + "type": "vis", + "config": { + "type": "metric", + "data_source": { + "type": "data_view_spec", + "index_pattern": "kibana_sample_data_logs", + "time_field": "timestamp" + }, + "metrics": [ + { + "type": "primary", + "operation": "average", + "field": "bytes" + } + ] + } + }, + { + "grid": { + "x": 0, + "y": 8, + "w": 24, + "h": 10 + }, + "type": "vis", + "config": { + "type": "xy", + "title": "Requests over time", + "layers": [ + { + "type": "line", + "data_source": { + "type": "esql", + "query": "FROM kibana_sample_data_logs | STATS count = COUNT() BY @timestamp = BUCKET(@timestamp, 75, ?_tstart, ?_tend)" + }, + "x": { + "column": "@timestamp" + }, + "y": [ + { + "column": "count" + } + ] + } + ] + } + }, + { + "grid": { + "x": 24, + "y": 8, + "w": 12, + "h": 5 + }, + "type": "vis", + "config": { + "type": "metric", + "data_source": { + "type": "data_view_spec", + "index_pattern": "kibana_sample_data_logs", + "time_field": "timestamp" + }, + "metrics": [ + { + "type": "primary", + "operation": "unique_count", + "field": "clientip" + } + ] + } + } + ] + }' + - lang: Console + label: Update a dashboard - Console + source: | + PUT kbn:/api/dashboards/3c4b8e10-d57a-11ef-9a52-4f3c2a8d0e1b + { + "title": "Web logs overview", + "panels": [ + { + "grid": { + "x": 0, + "y": 0, + "w": 12, + "h": 5 + }, + "type": "vis", + "config": { + "type": "metric", + "data_source": { + "type": "data_view_spec", + "index_pattern": "kibana_sample_data_logs", + "time_field": "timestamp" + }, + "metrics": [ + { + "type": "primary", + "operation": "count" + } + ] + } + }, + { + "grid": { + "x": 12, + "y": 0, + "w": 12, + "h": 5 + }, + "type": "vis", + "config": { + "type": "metric", + "data_source": { + "type": "data_view_spec", + "index_pattern": "kibana_sample_data_logs", + "time_field": "timestamp" + }, + "metrics": [ + { + "type": "primary", + "operation": "average", + "field": "bytes" + } + ] + } + }, + { + "grid": { + "x": 0, + "y": 8, + "w": 24, + "h": 10 + }, + "type": "vis", + "config": { + "type": "xy", + "title": "Requests over time", + "layers": [ + { + "type": "line", + "data_source": { + "type": "esql", + "query": "FROM kibana_sample_data_logs | STATS count = COUNT() BY @timestamp = BUCKET(@timestamp, 75, ?_tstart, ?_tend)" + }, + "x": { + "column": "@timestamp" + }, + "y": [ + { + "column": "count" + } + ] + } + ] + } + }, + { + "grid": { + "x": 24, + "y": 8, + "w": 12, + "h": 5 + }, + "type": "vis", + "config": { + "type": "metric", + "data_source": { + "type": "data_view_spec", + "index_pattern": "kibana_sample_data_logs", + "time_field": "timestamp" + }, + "metrics": [ + { + "type": "primary", + "operation": "unique_count", + "field": "clientip" + } + ] + } + } + ] + } + + # ────────────────────────────────────────────── + # DELETE /api/dashboards/{id} — code samples + # ────────────────────────────────────────────── + - target: "$.paths['/api/dashboards/{id}']['delete']" + description: Add code samples to delete endpoint + update: + x-codeSamples: + - lang: cURL + label: Delete a dashboard - cURL + source: | + curl -X DELETE "${KIBANA_URL}/api/dashboards/3c4b8e10-d57a-11ef-9a52-4f3c2a8d0e1b" \ + -H "Authorization: ApiKey ${API_KEY}" \ + -H "kbn-xsrf: true" + - lang: Console + label: Delete a dashboard - Console + source: | + DELETE kbn:/api/dashboards/3c4b8e10-d57a-11ef-9a52-4f3c2a8d0e1b + + # ────────────────────────────────────────────── + # Fix required fields incorrectly promoted by schema.maybe() + # ────────────────────────────────────────────── + - target: "$.components.schemas['Kibana_HTTP_APIs_kbn-dashboard-data']" + description: "Remove x-oas-optional fields from required: query, refresh_interval, time_range" + update: + required: + - options + - title