From a0392f8fc0e37647c580e54694a21731d1a154be Mon Sep 17 00:00:00 2001 From: Kyle Pollich Date: Wed, 1 Mar 2023 07:49:41 -0500 Subject: [PATCH 01/10] [Fleet] Add OpenAPI tags to help group Fleet API requests (#152386) ## Summary Ref https://github.com/elastic/observability-docs/pull/2715 Adds relevant `tags` to all operations in order to help group them more effectively in the generated docs. --------- Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- .../plugins/fleet/common/openapi/bundled.json | 798 +++++++++++------- .../plugins/fleet/common/openapi/bundled.yaml | 607 +++++++------ .../fleet/common/openapi/entrypoint.yaml | 25 +- .../openapi/paths/agent_download_sources.yaml | 11 +- .../agent_download_sources@{source_id}.yaml | 13 +- .../common/openapi/paths/agent_policies.yaml | 10 +- .../paths/agent_policies@_bulk_get.yaml | 5 +- .../openapi/paths/agent_policies@delete.yaml | 4 +- .../agent_policies@{agent_policy_id}.yaml | 10 +- ...agent_policies@{agent_policy_id}@copy.yaml | 5 +- ...t_policies@{agent_policy_id}@download.yaml | 5 +- ...agent_policies@{agent_policy_id}@full.yaml | 5 +- .../common/openapi/paths/agent_status.yaml | 7 +- .../openapi/paths/agent_status@data.yaml | 5 +- .../paths/agent_status_deprecated.yaml | 5 +- .../common/openapi/paths/agent_tags.yaml | 5 +- .../fleet/common/openapi/paths/agents.yaml | 5 +- .../openapi/paths/agents@action_status.yaml | 14 +- .../openapi/paths/agents@bulk_reassign.yaml | 23 +- .../agents@bulk_request_diagnostics.yaml | 7 +- .../openapi/paths/agents@bulk_unenroll.yaml | 21 +- .../paths/agents@bulk_update_tags.yaml | 25 +- .../openapi/paths/agents@bulk_upgrade.yaml | 13 +- .../paths/agents@current_upgrades.yaml | 5 +- .../agents@files@{file_id}@{file_name}.yaml | 5 +- .../common/openapi/paths/agents@setup.yaml | 9 +- .../openapi/paths/agents@{agent_id}.yaml | 15 +- .../paths/agents@{agent_id}@actions.yaml | 9 +- ...{agent_id}@actions@{action_id}@cancel.yaml | 5 +- .../paths/agents@{agent_id}@reassign.yaml | 11 +- ...agents@{agent_id}@request_diagnostics.yaml | 6 +- .../paths/agents@{agent_id}@unenroll.yaml | 43 +- .../paths/agents@{agent_id}@upgrade.yaml | 5 +- .../paths/agents@{agent_id}@uploads.yaml | 3 +- .../common/openapi/paths/data_streams.yaml | 5 +- .../openapi/paths/enrollment_api_keys.yaml | 10 +- .../paths/enrollment_api_keys@{key_id}.yaml | 10 +- ...rollment_api_keys@{key_id}_deprecated.yaml | 10 +- .../paths/enrollment_api_keys_deprecated.yaml | 10 +- .../common/openapi/paths/epm@categories.yaml | 15 +- .../common/openapi/paths/epm@get_file.yaml | 5 +- .../openapi/paths/epm@limited_list.yaml | 5 +- .../common/openapi/paths/epm@packages.yaml | 20 +- .../paths/epm@packages@{pkg_name}@stats.yaml | 5 +- ...epm@packages@{pkg_name}@{pkg_version}.yaml | 24 +- .../epm@packages@{pkgkey}_deprecated.yaml | 19 +- .../openapi/paths/epm@packages_bulk.yaml | 12 +- .../paths/epm@verification_key_id.yaml | 22 +- .../openapi/paths/fleet_server_hosts.yaml | 12 +- .../paths/fleet_server_hosts@{item_id}.yaml | 13 +- .../common/openapi/paths/health_check.yaml | 5 +- .../common/openapi/paths/kubernetes.yaml | 35 +- .../openapi/paths/logstash_api_keys.yaml | 3 +- .../fleet/common/openapi/paths/outputs.yaml | 13 +- .../openapi/paths/outputs@{output_id}.yaml | 19 +- .../openapi/paths/package_policies.yaml | 9 +- .../paths/package_policies@_bulk_get.yaml | 5 +- .../paths/package_policies@delete.yaml | 4 +- .../paths/package_policies@upgrade.yaml | 4 +- .../package_policies@upgrade_dryrun.yaml | 4 +- .../package_policies@{package_policy_id}.yaml | 14 +- .../fleet/common/openapi/paths/proxies.yaml | 12 +- .../openapi/paths/proxies@{item_id}.yaml | 13 +- .../common/openapi/paths/service_tokens.yaml | 5 +- .../paths/service_tokens_deprecated.yaml | 5 +- .../fleet/common/openapi/paths/settings.yaml | 10 +- .../fleet/common/openapi/paths/setup.yaml | 5 +- 67 files changed, 1238 insertions(+), 868 deletions(-) diff --git a/x-pack/plugins/fleet/common/openapi/bundled.json b/x-pack/plugins/fleet/common/openapi/bundled.json index eb7dcf0cad55c..4ff0b522325ca 100644 --- a/x-pack/plugins/fleet/common/openapi/bundled.json +++ b/x-pack/plugins/fleet/common/openapi/bundled.json @@ -20,10 +20,67 @@ } ], "paths": { + "/health_check": { + "post": { + "summary": "Fleet Server health check", + "tags": [ + "Fleet internals" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "status": { + "type": "string" + }, + "host": { + "type": "string" + } + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "fleet-server-health-check", + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "host": { + "type": "string" + } + } + } + } + } + } + } + }, "/setup": { "post": { - "summary": "Setup", - "tags": [], + "summary": "Initiate Fleet setup", + "tags": [ + "Fleet internals" + ], "responses": { "200": { "description": "OK", @@ -64,8 +121,10 @@ }, "/settings": { "get": { - "summary": "Settings", - "tags": [], + "summary": "Get settings", + "tags": [ + "Fleet internals" + ], "responses": { "200": { "description": "OK", @@ -84,8 +143,10 @@ "operationId": "get-settings" }, "put": { - "summary": "Settings - Update", - "tags": [], + "summary": "Update settings", + "tags": [ + "Fleet internals" + ], "requestBody": { "content": { "application/json": { @@ -128,63 +189,12 @@ "operationId": "update-settings" } }, - "/health_check": { - "post": { - "summary": "Fleet Server Health Check", - "tags": [], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "status": { - "type": "string" - }, - "host": { - "type": "string" - } - } - } - } - } - }, - "400": { - "$ref": "#/components/responses/error" - } - }, - "operationId": "fleet-server-health-check", - "parameters": [ - { - "$ref": "#/components/parameters/kbn_xsrf" - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "host": { - "type": "string" - } - } - } - } - } - } - } - }, "/service-tokens": { "post": { - "summary": "Generate service tokens", - "tags": [], + "summary": "Create service token", + "tags": [ + "Service tokens" + ], "responses": { "200": { "description": "OK", @@ -219,8 +229,10 @@ }, "/service_tokens": { "post": { - "summary": "Generate service tokens", - "tags": [], + "summary": "Create service token", + "tags": [ + "Service tokens" + ], "responses": { "200": { "description": "OK", @@ -255,7 +267,9 @@ "/epm/verification_key_id": { "get": { "summary": "Get package signature verification key ID", - "tags": [], + "tags": [ + "Elastic Package Manager (EPM)" + ], "responses": { "200": { "description": "OK", @@ -291,37 +305,14 @@ }, "operationId": "packages-get-verification-key-id" }, - "parameters": [ - { - "schema": { - "type": "string" - }, - "name": "pkgName", - "in": "path", - "required": true - }, - { - "schema": { - "type": "string" - }, - "name": "pkgVersion", - "in": "path", - "required": true - }, - { - "schema": { - "type": "string" - }, - "name": "filePath", - "in": "path", - "required": true - } - ] + "parameters": [] }, "/epm/categories": { "get": { - "summary": "Package categories", - "tags": [], + "summary": "List package categories", + "tags": [ + "Elastic Package Manager (EPM)" + ], "responses": { "200": { "description": "OK", @@ -347,7 +338,7 @@ "type": "boolean", "default": false }, - "description": "Whether to include prerelease packages in categories count (e.g. beta, rc, preview) " + "description": "Whether to include prerelease packages in categories count (e.g. beta, rc, preview)" }, { "in": "query", @@ -370,8 +361,10 @@ }, "/epm/packages/limited": { "get": { - "summary": "Packages - Get limited list", - "tags": [], + "summary": "Get limited package list", + "tags": [ + "Elastic Package Manager (EPM)" + ], "responses": { "200": { "description": "OK", @@ -401,8 +394,10 @@ }, "/epm/packages": { "get": { - "summary": "Packages - List", - "tags": [], + "summary": "List packages", + "tags": [ + "Elastic Package Manager (EPM)" + ], "responses": { "200": { "description": "OK", @@ -436,7 +431,7 @@ "type": "boolean", "default": false }, - "description": "Whether to return prerelease versions of packages (e.g. beta, rc, preview) " + "description": "Whether to return prerelease versions of packages (e.g. beta, rc, preview)" }, { "in": "query", @@ -457,8 +452,10 @@ ] }, "post": { - "summary": "Packages - Install by upload", - "tags": [], + "summary": "Install by package by direct upload", + "tags": [ + "Elastic Package Manager (EPM)" + ], "responses": { "200": { "description": "OK", @@ -544,8 +541,10 @@ }, "/epm/packages/_bulk": { "post": { - "summary": "Packages - Bulk install", - "tags": [], + "summary": "Bulk install packages", + "tags": [ + "Elastic Package Manager (EPM)" + ], "responses": { "200": { "description": "OK", @@ -570,7 +569,7 @@ "type": "boolean", "default": false }, - "description": "Whether to return prerelease versions of packages (e.g. beta, rc, preview) " + "description": "Whether to return prerelease versions of packages (e.g. beta, rc, preview)" } ], "requestBody": { @@ -602,8 +601,10 @@ }, "/epm/packages/{pkgkey}": { "get": { - "summary": "Packages - Info", - "tags": [], + "summary": "Get package", + "tags": [ + "Elastic Package Manager (EPM)" + ], "responses": { "200": { "description": "OK", @@ -670,14 +671,16 @@ "type": "boolean", "default": false }, - "description": "Whether to return prerelease versions of packages (e.g. beta, rc, preview) " + "description": "Whether to return prerelease versions of packages (e.g. beta, rc, preview)" } ], "deprecated": true }, "post": { - "summary": "Packages - Install", - "tags": [], + "summary": "Install package", + "tags": [ + "Elastic Package Manager (EPM)" + ], "responses": { "200": { "description": "OK", @@ -755,8 +758,10 @@ "deprecated": true }, "delete": { - "summary": "Packages - Delete", - "tags": [], + "summary": "Delete ackage", + "tags": [ + "Elastic Package Manager (EPM)" + ], "responses": { "200": { "description": "OK", @@ -835,8 +840,10 @@ }, "/epm/packages/{pkgName}/{pkgVersion}": { "get": { - "summary": "Packages - Info", - "tags": [], + "summary": "Get package", + "tags": [ + "Elastic Package Manager (EPM)" + ], "responses": { "200": { "description": "OK", @@ -940,12 +947,14 @@ "type": "boolean", "default": false }, - "description": "Whether to return prerelease versions of packages (e.g. beta, rc, preview) " + "description": "Whether to return prerelease versions of packages (e.g. beta, rc, preview)" } ], "post": { - "summary": "Packages - Install", - "tags": [], + "summary": "Install package", + "tags": [ + "Elastic Package Manager (EPM)" + ], "responses": { "200": { "description": "OK", @@ -1030,8 +1039,10 @@ } }, "put": { - "summary": "Packages - Update", - "tags": [], + "summary": "Update package settings", + "tags": [ + "Elastic Package Manager (EPM)" + ], "responses": { "200": { "description": "OK", @@ -1095,8 +1106,10 @@ } }, "delete": { - "summary": "Packages - Delete", - "tags": [], + "summary": "Delete package", + "tags": [ + "Elastic Package Manager (EPM)" + ], "responses": { "200": { "description": "OK", @@ -1166,8 +1179,10 @@ }, "/epm/packages/{pkgName}/{pkgVersion}/{filePath}": { "get": { - "summary": "Packages - Get file from registry", - "tags": [], + "summary": "Get package file", + "tags": [ + "Elastic Package Manager (EPM)" + ], "responses": { "200": { "description": "OK", @@ -1225,8 +1240,10 @@ }, "/epm/packages/{pkgName}/stats": { "get": { - "summary": "Get stats for a package", - "tags": [], + "summary": "Get package stats", + "tags": [ + "Elastic Package Manager (EPM)" + ], "responses": { "200": { "description": "OK", @@ -1270,8 +1287,10 @@ }, "/agents/setup": { "get": { - "summary": "Agents setup - Info", - "tags": [], + "summary": "Get agent setup info", + "tags": [ + "Agents" + ], "responses": { "200": { "description": "OK", @@ -1295,7 +1314,10 @@ ] }, "post": { - "summary": "Agents setup - Create", + "summary": "Initiate agent setup", + "tags": [ + "Agents" + ], "operationId": "setup-agents", "responses": { "200": { @@ -1342,8 +1364,10 @@ }, "/agent-status": { "get": { - "summary": "Agents - Summary stats", - "tags": [], + "summary": "Get agent status summary", + "tags": [ + "Agent status" + ], "responses": { "200": { "description": "OK", @@ -1411,8 +1435,10 @@ }, "/agent_status": { "get": { - "summary": "Agents - Summary stats", - "tags": [], + "summary": "Get agent status summary", + "tags": [ + "Agent status" + ], "responses": { "200": { "description": "OK", @@ -1499,8 +1525,10 @@ }, "/agent_status/data": { "get": { - "summary": "Agents - Get incoming data", - "tags": [], + "summary": "Get incoming agent data", + "tags": [ + "Agent status" + ], "responses": { "200": { "description": "OK", @@ -1550,8 +1578,10 @@ }, "/agents": { "get": { - "summary": "Agents - List", - "tags": [], + "summary": "List agents", + "tags": [ + "Agents" + ], "responses": { "200": { "description": "OK", @@ -1611,8 +1641,10 @@ }, "/agents/bulk_upgrade": { "post": { - "summary": "Agents - Bulk Upgrade", - "tags": [], + "summary": "Bulk upgrade agents", + "tags": [ + "Agents" + ], "responses": { "200": { "description": "OK", @@ -1663,7 +1695,10 @@ }, "/agents/action_status": { "get": { - "summary": "Agents - Action status", + "summary": "Get agent action status", + "tags": [ + "Agent actions" + ], "parameters": [ { "$ref": "#/components/parameters/page_size" @@ -1774,8 +1809,10 @@ } ], "get": { - "summary": "Agent - Info", - "tags": [], + "summary": "Get agent by ID", + "tags": [ + "Agents" + ], "responses": { "200": { "description": "OK", @@ -1807,8 +1844,10 @@ ] }, "put": { - "summary": "Agent - Update", - "tags": [], + "summary": "Update agent by ID", + "tags": [ + "Agents" + ], "responses": { "200": { "description": "OK", @@ -1861,8 +1900,10 @@ } }, "delete": { - "summary": "Agent - Delete", - "tags": [], + "summary": "Delete agent by ID", + "tags": [ + "Agents" + ], "responses": { "200": { "description": "OK", @@ -1909,8 +1950,10 @@ } ], "post": { - "summary": "Agent - Actions", - "tags": [], + "summary": "Create agent action", + "tags": [ + "Agent actions" + ], "responses": { "200": { "description": "OK", @@ -1983,8 +2026,10 @@ } ], "post": { - "summary": "Agent - Cancel Action", - "tags": [], + "summary": "Cancel agent action", + "tags": [ + "Agent actions" + ], "responses": { "200": { "description": "OK", @@ -2033,8 +2078,10 @@ } ], "get": { - "summary": "Get agent upload file", - "tags": [], + "summary": "Get file uploaded by agent", + "tags": [ + "Agents" + ], "responses": { "200": { "description": "OK", @@ -2079,8 +2126,10 @@ } ], "post": { - "summary": "Agent - Reassign", - "tags": [], + "summary": "Reassign agent", + "tags": [ + "Agents" + ], "responses": { "200": { "description": "OK", @@ -2122,8 +2171,10 @@ } }, "put": { - "summary": "Agent - Reassign", - "tags": [], + "summary": "Reassign agent", + "tags": [ + "Agents" + ], "responses": { "200": { "description": "OK", @@ -2178,8 +2229,10 @@ } ], "post": { - "summary": "Agent - Unenroll", - "tags": [], + "summary": "Unenroll agent", + "tags": [ + "Agents" + ], "responses": { "200": { "description": "OK", @@ -2253,8 +2306,10 @@ } ], "post": { - "summary": "Agent - Upgrade", - "tags": [], + "summary": "Upgrade agent", + "tags": [ + "Agents" + ], "responses": { "200": { "description": "OK", @@ -2301,7 +2356,9 @@ ], "get": { "summary": "List agent uploads", - "tags": [], + "tags": [ + "Agents" + ], "responses": { "200": { "description": "OK", @@ -2335,8 +2392,10 @@ }, "/agents/bulk_reassign": { "post": { - "summary": "Agents - Bulk reassign", - "tags": [], + "summary": "Bulk reassign agents", + "tags": [ + "Agents" + ], "responses": { "200": { "description": "OK", @@ -2405,8 +2464,10 @@ }, "/agents/bulk_unenroll": { "post": { - "summary": "Agents - Bulk unenroll", - "tags": [], + "summary": "Bulk unenroll agents", + "tags": [ + "Agents" + ], "responses": { "200": { "description": "OK", @@ -2482,8 +2543,10 @@ }, "/agents/bulk_update_agent_tags": { "post": { - "summary": "Agents - Bulk update tags", - "tags": [], + "summary": "Bulk update agent tags", + "tags": [ + "Agents" + ], "responses": { "200": { "description": "OK", @@ -2570,8 +2633,10 @@ }, "/agents/tags": { "get": { - "summary": "Agent Tags - List", - "description": "List all agent tags", + "summary": "List agent tags", + "tags": [ + "Agents" + ], "responses": { "200": { "description": "OK", @@ -2602,8 +2667,10 @@ } ], "post": { - "summary": "Agent - Request Diagnostics", - "tags": [], + "summary": "Request agent diagnostics", + "tags": [ + "Agents" + ], "responses": { "200": { "description": "OK", @@ -2634,8 +2701,10 @@ }, "/agents/bulk_request_diagnostics": { "post": { - "summary": "Agent - Bulk Request Diagnostics", - "tags": [], + "summary": "Bulk request diagnostics from agents", + "tags": [ + "Agents" + ], "responses": { "200": { "description": "OK", @@ -2701,8 +2770,10 @@ }, "/agent_policies": { "get": { - "summary": "Agent policies - List", - "tags": [], + "summary": "List agent policies", + "tags": [ + "Agent policies" + ], "responses": { "200": { "description": "OK", @@ -2772,8 +2843,10 @@ "description": "" }, "post": { - "summary": "Agent policy - Create", - "tags": [], + "summary": "Create agent policy", + "tags": [ + "Agent policies" + ], "responses": { "200": { "description": "OK", @@ -2824,8 +2897,10 @@ } ], "get": { - "summary": "Agent policy - Info", - "tags": [], + "summary": "Get agent policy by ID", + "tags": [ + "Agent policies" + ], "responses": { "200": { "description": "OK", @@ -2854,8 +2929,10 @@ "parameters": [] }, "put": { - "summary": "Agent policy - Update", - "tags": [], + "summary": "Update agent policy by ID", + "tags": [ + "Agent policies" + ], "responses": { "200": { "description": "OK", @@ -2908,7 +2985,10 @@ } ], "post": { - "summary": "Agent policy - copy one policy", + "summary": "Copy agent policy by ID", + "tags": [ + "Agent policies" + ], "operationId": "agent-policy-copy", "parameters": [ { @@ -2963,7 +3043,10 @@ }, "/agent_policies/{agentPolicyId}/full": { "get": { - "summary": "Agent policy - Get full policy", + "summary": "Get full agent policy by ID", + "tags": [ + "Agent policies" + ], "operationId": "agent-policy-full", "responses": { "200": { @@ -3030,7 +3113,10 @@ }, "/agent_policies/{agentPolicyId}/download": { "get": { - "summary": "Agent policy - Download", + "summary": "Download agent policy by ID", + "tags": [ + "Agent policies" + ], "operationId": "agent-policy-download", "responses": { "200": { @@ -3090,8 +3176,10 @@ }, "/agent_policies/_bulk_get": { "post": { - "summary": "Agent policies - Bulk Get", - "tags": [], + "summary": "Bulk get agent policies", + "tags": [ + "Agent policies" + ], "requestBody": { "content": { "application/json": { @@ -3153,7 +3241,10 @@ }, "/agent_policies/delete": { "post": { - "summary": "Agent policy - Delete", + "summary": "Delete agent policy by ID", + "tags": [ + "Agent policies" + ], "operationId": "delete-agent-policy", "responses": { "200": { @@ -3209,8 +3300,10 @@ }, "/data_streams": { "get": { - "summary": "Data streams - List", - "tags": [], + "summary": "List data streams", + "tags": [ + "Data streams" + ], "responses": { "200": { "description": "OK", @@ -3240,8 +3333,10 @@ }, "/enrollment-api-keys": { "get": { - "summary": "Enrollment API Keys - List", - "tags": [], + "summary": "List enrollment API keys", + "tags": [ + "Enrollment API keys" + ], "responses": { "200": { "description": "OK", @@ -3292,8 +3387,10 @@ "deprecated": true }, "post": { - "summary": "Enrollment API Key - Create", - "tags": [], + "summary": "Create enrollment API key", + "tags": [ + "Enrollment API keys" + ], "responses": { "200": { "description": "OK", @@ -3341,8 +3438,10 @@ } ], "get": { - "summary": "Enrollment API Key - Info", - "tags": [], + "summary": "Get enrollment API key by ID", + "tags": [ + "Enrollment API keys" + ], "responses": { "200": { "description": "OK", @@ -3370,8 +3469,10 @@ "deprecated": true }, "delete": { - "summary": "Enrollment API Key - Delete", - "tags": [], + "summary": "Delete enrollment API key by ID", + "tags": [ + "Enrollment API keys" + ], "responses": { "200": { "description": "OK", @@ -3409,8 +3510,10 @@ }, "/enrollment_api_keys": { "get": { - "summary": "Enrollment API Keys - List", - "tags": [], + "summary": "List enrollment API keys", + "tags": [ + "Enrollment API keys" + ], "responses": { "200": { "description": "OK", @@ -3460,8 +3563,10 @@ "parameters": [] }, "post": { - "summary": "Enrollment API Key - Create", - "tags": [], + "summary": "Create enrollment API key", + "tags": [ + "Enrollment API keys" + ], "responses": { "200": { "description": "OK", @@ -3508,8 +3613,10 @@ } ], "get": { - "summary": "Enrollment API Key - Info", - "tags": [], + "summary": "Get enrollment API key by ID", + "tags": [ + "Enrollment API keys" + ], "responses": { "200": { "description": "OK", @@ -3536,8 +3643,10 @@ "operationId": "get-enrollment-api-key" }, "delete": { - "summary": "Enrollment API Key - Delete", - "tags": [], + "summary": "Delete enrollment API key by ID", + "tags": [ + "Enrollment API keys" + ], "responses": { "200": { "description": "OK", @@ -3574,8 +3683,10 @@ }, "/package_policies": { "get": { - "summary": "Package policies - List", - "tags": [], + "summary": "List package policies", + "tags": [ + "Package policies" + ], "responses": { "200": { "description": "OK", @@ -3617,7 +3728,10 @@ }, "parameters": [], "post": { - "summary": "Package policy - Create", + "summary": "Create package policy", + "tags": [ + "Package policies" + ], "operationId": "create-package-policy", "responses": { "200": { @@ -3661,8 +3775,10 @@ }, "/package_policies/_bulk_get": { "post": { - "summary": "Package policies - Bulk Get", - "tags": [], + "summary": "Bulk get package policies", + "tags": [ + "Package policies" + ], "requestBody": { "content": { "application/json": { @@ -3720,7 +3836,10 @@ }, "/package_policies/delete": { "post": { - "summary": "Package policy - Delete", + "summary": "Delete package policy", + "tags": [ + "Package policies" + ], "operationId": "post-delete-package-policy", "requestBody": { "content": { @@ -3787,7 +3906,10 @@ }, "/package_policies/upgrade": { "post": { - "summary": "Package policy - Upgrade", + "summary": "Upgrade package policy to a newer package version", + "tags": [ + "Package policies" + ], "operationId": "upgrade-package-policy", "requestBody": { "content": { @@ -3846,7 +3968,10 @@ }, "/package_policies/upgrade/dryrun": { "post": { - "summary": "Package policy - Upgrade Dry run", + "summary": "Dry run package policy upgrade", + "tags": [ + "Package policies" + ], "operationId": "upgrade-package-policy-dry-run", "requestBody": { "content": { @@ -3907,8 +4032,10 @@ }, "/package_policies/{packagePolicyId}": { "get": { - "summary": "Package policy - Info", - "tags": [], + "summary": "Get package policy by ID", + "tags": [ + "Package policies" + ], "responses": { "200": { "description": "OK", @@ -3945,7 +4072,10 @@ } ], "put": { - "summary": "Package policy - Update", + "summary": "Update package policy by ID", + "tags": [ + "Package policies" + ], "operationId": "update-package-policy", "requestBody": { "content": { @@ -3990,8 +4120,10 @@ ] }, "delete": { - "summary": "Package policy - Delete", - "tags": [], + "summary": "Delete package policy by ID", + "tags": [ + "Package policies" + ], "operationId": "delete-package-policy", "responses": { "200": { @@ -4029,8 +4161,10 @@ }, "/outputs": { "get": { - "summary": "Outputs", - "tags": [], + "summary": "List outputs", + "tags": [ + "Outputs" + ], "responses": { "200": { "description": "OK", @@ -4066,9 +4200,10 @@ "operationId": "get-outputs" }, "post": { - "summary": "Outputs", - "description": "Create a new output", - "tags": [], + "summary": "Create output", + "tags": [ + "Outputs" + ], "responses": { "200": { "description": "OK", @@ -4139,8 +4274,10 @@ }, "/outputs/{outputId}": { "get": { - "summary": "Output - Info", - "tags": [], + "summary": "Get output by ID", + "tags": [ + "Outputs" + ], "responses": { "200": { "description": "OK", @@ -4177,7 +4314,10 @@ } ], "delete": { - "summary": "Output - Delete", + "summary": "Delete output by ID", + "tags": [ + "Outputs" + ], "operationId": "delete-output", "responses": { "200": { @@ -4209,7 +4349,10 @@ ] }, "put": { - "summary": "Output - Update", + "summary": "Update output by ID", + "tags": [ + "Outputs" + ], "operationId": "update-output", "requestBody": { "content": { @@ -4286,10 +4429,46 @@ ] } }, + "/logstash_api_keys": { + "post": { + "summary": "Generate Logstash API key", + "tags": [ + "Outputs" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "api_key": { + "type": "string" + } + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "generate-logstash-api-key", + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ] + } + }, "/agent_download_sources": { "get": { - "summary": "Agent Download Sources", - "tags": [], + "summary": "List agent binary download sources", + "tags": [ + "Agent binary download sources" + ], "responses": { "200": { "description": "OK", @@ -4325,9 +4504,10 @@ "operationId": "get-download-sources" }, "post": { - "summary": "Agent Download Sources", - "description": "Create a new agent download source", - "tags": [], + "summary": "Create agent binary download source", + "tags": [ + "Agent binary download sources" + ], "responses": { "200": { "description": "OK", @@ -4381,8 +4561,10 @@ }, "/agent_download_sources/{sourceId}": { "get": { - "summary": "Agent Download Sources - Info", - "tags": [], + "summary": "Get agent binary download source by ID", + "tags": [ + "Agent binary download sources" + ], "responses": { "200": { "description": "OK", @@ -4419,7 +4601,10 @@ } ], "delete": { - "summary": "Agent Download Sources - Delete", + "summary": "Delete agent binary download source by ID", + "tags": [ + "Agent binary download sources" + ], "operationId": "delete-download-source", "responses": { "200": { @@ -4451,7 +4636,10 @@ ] }, "put": { - "summary": "Agent Download Sources - Update", + "summary": "Update agent binary download source by ID", + "tags": [ + "Agent binary download sources" + ], "operationId": "update-download-source", "requestBody": { "content": { @@ -4508,43 +4696,12 @@ ] } }, - "/logstash_api_keys": { - "post": { - "summary": "Generate Logstash API key", - "tags": [], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "api_key": { - "type": "string" - } - } - } - } - } - }, - "400": { - "$ref": "#/components/responses/error" - } - }, - "operationId": "generate-logstash-api-key", - "parameters": [ - { - "$ref": "#/components/parameters/kbn_xsrf" - } - ] - } - }, "/fleet_server_hosts": { "get": { - "summary": "Fleet Server Hosts - List", - "description": "Return a list of Fleet server hosts", - "tags": [], + "summary": "List Fleet Server hosts", + "tags": [ + "Fleet Server hosts" + ], "responses": { "200": { "description": "OK", @@ -4580,9 +4737,10 @@ "operationId": "get-fleet-server-hosts" }, "post": { - "summary": "Fleet Server Hosts - Create", - "description": "Create a new Fleet Server Host", - "tags": [], + "summary": "Create Fleet Server host", + "tags": [ + "Fleet Server hosts" + ], "responses": { "200": { "description": "OK", @@ -4638,8 +4796,10 @@ }, "/fleet_server_hosts/{itemId}": { "get": { - "summary": "Fleet Server Hosts - Info", - "tags": [], + "summary": "Get Fleet Server host by ID", + "tags": [ + "Fleet Server hosts" + ], "responses": { "200": { "description": "OK", @@ -4676,7 +4836,10 @@ } ], "delete": { - "summary": "Fleet Server Hosts - Delete", + "summary": "Delete Fleet Server host by ID", + "tags": [ + "Fleet Server hosts" + ], "operationId": "delete-fleet-server-hosts", "responses": { "200": { @@ -4708,7 +4871,10 @@ ] }, "put": { - "summary": "Fleet Server Hosts - Update", + "summary": "Update Fleet Server host by ID", + "tags": [ + "Fleet Server hosts" + ], "operationId": "update-fleet-server-hosts", "requestBody": { "content": { @@ -4765,9 +4931,10 @@ }, "/proxies": { "get": { - "summary": "Fleet Proxies - List", - "description": "Return a list of Proxies", - "tags": [], + "summary": "List proxies", + "tags": [ + "Proxies" + ], "responses": { "200": { "description": "OK", @@ -4803,9 +4970,10 @@ "operationId": "get-fleet-proxies" }, "post": { - "summary": "Fleet Proxies - Create", - "description": "Create a new Fleet Server Host", - "tags": [], + "summary": "Create proxy", + "tags": [ + "Proxies" + ], "responses": { "200": { "description": "OK", @@ -4867,8 +5035,10 @@ }, "/proxies/{itemId}": { "get": { - "summary": "Fleet Proxies - Info", - "tags": [], + "summary": "Get proxy by ID", + "tags": [ + "Proxies" + ], "responses": { "200": { "description": "OK", @@ -4905,7 +5075,10 @@ } ], "delete": { - "summary": "Fleet Proxies - Delete", + "summary": "Delete proxy by ID", + "tags": [ + "Proxies" + ], "operationId": "delete-fleet-proxies", "responses": { "200": { @@ -4937,7 +5110,10 @@ ] }, "put": { - "summary": "Fleet Proxies - Update", + "summary": "Update proxy by ID", + "tags": [ + "Proxies" + ], "operationId": "update-fleet-proxies", "requestBody": { "content": { @@ -5000,8 +5176,10 @@ }, "/kubernetes": { "get": { - "summary": "Get K8s Full Agent Manifest", - "tags": [], + "summary": "Get full K8s agent manifest", + "tags": [ + "Kubernetes" + ], "responses": { "200": { "description": "OK", @@ -5154,6 +5332,29 @@ } } }, + "responses": { + "error": { + "description": "Generic Error", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "statusCode": { + "type": "number" + }, + "error": { + "type": "string" + }, + "message": { + "type": "string" + } + } + } + } + } + } + }, "schemas": { "fleet_setup_response": { "title": "Fleet Setup response", @@ -7151,29 +7352,6 @@ "url" ] } - }, - "responses": { - "error": { - "description": "Generic Error", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "statusCode": { - "type": "number" - }, - "error": { - "type": "string" - }, - "message": { - "type": "string" - } - } - } - } - } - } } }, "security": [ diff --git a/x-pack/plugins/fleet/common/openapi/bundled.yaml b/x-pack/plugins/fleet/common/openapi/bundled.yaml index 5f67c8630b0dc..9d6ae17a04a41 100644 --- a/x-pack/plugins/fleet/common/openapi/bundled.yaml +++ b/x-pack/plugins/fleet/common/openapi/bundled.yaml @@ -13,10 +13,44 @@ servers: - url: http://localhost:5601/api/fleet description: local paths: + /health_check: + post: + summary: Fleet Server health check + tags: + - Fleet internals + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + properties: + name: + type: string + status: + type: string + host: + type: string + '400': + $ref: '#/components/responses/error' + operationId: fleet-server-health-check + parameters: + - $ref: '#/components/parameters/kbn_xsrf' + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + host: + type: string /setup: post: - summary: Setup - tags: [] + summary: Initiate Fleet setup + tags: + - Fleet internals responses: '200': description: OK @@ -40,8 +74,9 @@ paths: - $ref: '#/components/parameters/kbn_xsrf' /settings: get: - summary: Settings - tags: [] + summary: Get settings + tags: + - Fleet internals responses: '200': description: OK @@ -53,8 +88,9 @@ paths: $ref: '#/components/responses/error' operationId: get-settings put: - summary: Settings - Update - tags: [] + summary: Update settings + tags: + - Fleet internals requestBody: content: application/json: @@ -80,42 +116,11 @@ paths: '400': $ref: '#/components/responses/error' operationId: update-settings - /health_check: - post: - summary: Fleet Server Health Check - tags: [] - responses: - '200': - description: OK - content: - application/json: - schema: - type: object - properties: - name: - type: string - status: - type: string - host: - type: string - '400': - $ref: '#/components/responses/error' - operationId: fleet-server-health-check - parameters: - - $ref: '#/components/parameters/kbn_xsrf' - requestBody: - required: true - content: - application/json: - schema: - type: object - properties: - host: - type: string /service-tokens: post: - summary: Generate service tokens - tags: [] + summary: Create service token + tags: + - Service tokens responses: '200': description: OK @@ -136,8 +141,9 @@ paths: deprecated: true /service_tokens: post: - summary: Generate service tokens - tags: [] + summary: Create service token + tags: + - Service tokens responses: '200': description: OK @@ -158,7 +164,8 @@ paths: /epm/verification_key_id: get: summary: Get package signature verification key ID - tags: [] + tags: + - Elastic Package Manager (EPM) responses: '200': description: OK @@ -183,26 +190,12 @@ paths: '400': $ref: '#/components/responses/error' operationId: packages-get-verification-key-id - parameters: - - schema: - type: string - name: pkgName - in: path - required: true - - schema: - type: string - name: pkgVersion - in: path - required: true - - schema: - type: string - name: filePath - in: path - required: true + parameters: [] /epm/categories: get: - summary: Package categories - tags: [] + summary: List package categories + tags: + - Elastic Package Manager (EPM) responses: '200': description: OK @@ -221,7 +214,7 @@ paths: default: false description: >- Whether to include prerelease packages in categories count (e.g. beta, - rc, preview) + rc, preview) - in: query name: experimental deprecated: true @@ -235,8 +228,9 @@ paths: default: false /epm/packages/limited: get: - summary: Packages - Get limited list - tags: [] + summary: Get limited package list + tags: + - Elastic Package Manager (EPM) responses: '200': description: OK @@ -255,8 +249,9 @@ paths: parameters: [] /epm/packages: get: - summary: Packages - List - tags: [] + summary: List packages + tags: + - Elastic Package Manager (EPM) responses: '200': description: OK @@ -286,7 +281,7 @@ paths: default: false description: >- Whether to return prerelease versions of packages (e.g. beta, rc, - preview) + preview) - in: query name: experimental deprecated: true @@ -298,8 +293,9 @@ paths: schema: type: string post: - summary: Packages - Install by upload - tags: [] + summary: Install by package by direct upload + tags: + - Elastic Package Manager (EPM) responses: '200': description: OK @@ -351,8 +347,9 @@ paths: format: binary /epm/packages/_bulk: post: - summary: Packages - Bulk install - tags: [] + summary: Bulk install packages + tags: + - Elastic Package Manager (EPM) responses: '200': description: OK @@ -371,7 +368,7 @@ paths: default: false description: >- Whether to return prerelease versions of packages (e.g. beta, rc, - preview) + preview) requestBody: content: application/json: @@ -390,8 +387,9 @@ paths: - packages /epm/packages/{pkgkey}: get: - summary: Packages - Info - tags: [] + summary: Get package + tags: + - Elastic Package Manager (EPM) responses: '200': description: OK @@ -434,11 +432,12 @@ paths: default: false description: >- Whether to return prerelease versions of packages (e.g. beta, rc, - preview) + preview) deprecated: true post: - summary: Packages - Install - tags: [] + summary: Install package + tags: + - Elastic Package Manager (EPM) responses: '200': description: OK @@ -484,8 +483,9 @@ paths: type: boolean deprecated: true delete: - summary: Packages - Delete - tags: [] + summary: Delete ackage + tags: + - Elastic Package Manager (EPM) responses: '200': description: OK @@ -531,8 +531,9 @@ paths: deprecated: true /epm/packages/{pkgName}/{pkgVersion}: get: - summary: Packages - Info - tags: [] + summary: Get package + tags: + - Elastic Package Manager (EPM) responses: '200': description: OK @@ -600,10 +601,11 @@ paths: default: false description: >- Whether to return prerelease versions of packages (e.g. beta, rc, - preview) + preview) post: - summary: Packages - Install - tags: [] + summary: Install package + tags: + - Elastic Package Manager (EPM) responses: '200': description: OK @@ -654,8 +656,9 @@ paths: ignore_constraints: type: boolean put: - summary: Packages - Update - tags: [] + summary: Update package settings + tags: + - Elastic Package Manager (EPM) responses: '200': description: OK @@ -693,8 +696,9 @@ paths: keepPoliciesUpToDate: type: boolean delete: - summary: Packages - Delete - tags: [] + summary: Delete package + tags: + - Elastic Package Manager (EPM) responses: '200': description: OK @@ -734,8 +738,9 @@ paths: type: boolean /epm/packages/{pkgName}/{pkgVersion}/{filePath}: get: - summary: Packages - Get file from registry - tags: [] + summary: Get package file + tags: + - Elastic Package Manager (EPM) responses: '200': description: OK @@ -771,8 +776,9 @@ paths: required: true /epm/packages/{pkgName}/stats: get: - summary: Get stats for a package - tags: [] + summary: Get package stats + tags: + - Elastic Package Manager (EPM) responses: '200': description: OK @@ -798,8 +804,9 @@ paths: required: true /agents/setup: get: - summary: Agents setup - Info - tags: [] + summary: Get agent setup info + tags: + - Agents responses: '200': description: OK @@ -813,7 +820,9 @@ paths: security: - basicAuth: [] post: - summary: Agents setup - Create + summary: Initiate agent setup + tags: + - Agents operationId: setup-agents responses: '200': @@ -841,8 +850,9 @@ paths: - $ref: '#/components/parameters/kbn_xsrf' /agent-status: get: - summary: Agents - Summary stats - tags: [] + summary: Get agent status summary + tags: + - Agent status responses: '200': description: OK @@ -888,8 +898,9 @@ paths: deprecated: true /agent_status: get: - summary: Agents - Summary stats - tags: [] + summary: Get agent status summary + tags: + - Agent status responses: '200': description: OK @@ -948,8 +959,9 @@ paths: required: false /agent_status/data: get: - summary: Agents - Get incoming data - tags: [] + summary: Get incoming agent data + tags: + - Agent status responses: '200': description: OK @@ -980,8 +992,9 @@ paths: required: true /agents: get: - summary: Agents - List - tags: [] + summary: List agents + tags: + - Agents responses: '200': description: OK @@ -1010,8 +1023,9 @@ paths: - basicAuth: [] /agents/bulk_upgrade: post: - summary: Agents - Bulk Upgrade - tags: [] + summary: Bulk upgrade agents + tags: + - Agents responses: '200': description: OK @@ -1043,7 +1057,9 @@ paths: start_time: '2022-08-03T14:00:00.000Z' /agents/action_status: get: - summary: Agents - Action status + summary: Get agent action status + tags: + - Agent actions parameters: - $ref: '#/components/parameters/page_size' - $ref: '#/components/parameters/page_index' @@ -1116,8 +1132,9 @@ paths: in: path required: true get: - summary: Agent - Info - tags: [] + summary: Get agent by ID + tags: + - Agents responses: '200': description: OK @@ -1136,8 +1153,9 @@ paths: parameters: - $ref: '#/components/parameters/with_metrics' put: - summary: Agent - Update - tags: [] + summary: Update agent by ID + tags: + - Agents responses: '200': description: OK @@ -1169,8 +1187,9 @@ paths: items: type: string delete: - summary: Agent - Delete - tags: [] + summary: Delete agent by ID + tags: + - Agents responses: '200': description: OK @@ -1198,8 +1217,9 @@ paths: in: path required: true post: - summary: Agent - Actions - tags: [] + summary: Create agent action + tags: + - Agent actions responses: '200': description: OK @@ -1243,8 +1263,9 @@ paths: in: path required: true post: - summary: Agent - Cancel Action - tags: [] + summary: Cancel agent action + tags: + - Agent actions responses: '200': description: OK @@ -1273,8 +1294,9 @@ paths: in: path required: true get: - summary: Get agent upload file - tags: [] + summary: Get file uploaded by agent + tags: + - Agents responses: '200': description: OK @@ -1302,8 +1324,9 @@ paths: in: path required: true post: - summary: Agent - Reassign - tags: [] + summary: Reassign agent + tags: + - Agents responses: '200': description: OK @@ -1328,8 +1351,9 @@ paths: required: - policy_id put: - summary: Agent - Reassign - tags: [] + summary: Reassign agent + tags: + - Agents responses: '200': description: OK @@ -1362,8 +1386,9 @@ paths: in: path required: true post: - summary: Agent - Unenroll - tags: [] + summary: Unenroll agent + tags: + - Agents responses: '200': description: OK @@ -1407,8 +1432,9 @@ paths: in: path required: true post: - summary: Agent - Upgrade - tags: [] + summary: Upgrade agent + tags: + - Agents responses: '200': description: OK @@ -1436,7 +1462,8 @@ paths: required: true get: summary: List agent uploads - tags: [] + tags: + - Agents responses: '200': description: OK @@ -1457,8 +1484,9 @@ paths: operationId: list-agent-uploads /agents/bulk_reassign: post: - summary: Agents - Bulk reassign - tags: [] + summary: Bulk reassign agents + tags: + - Agents responses: '200': description: OK @@ -1499,8 +1527,9 @@ paths: agents: 'fleet-agents.policy_id : ("policy1" or "policy2")' /agents/bulk_unenroll: post: - summary: Agents - Bulk unenroll - tags: [] + summary: Bulk unenroll agents + tags: + - Agents responses: '200': description: OK @@ -1546,8 +1575,9 @@ paths: - agent2 /agents/bulk_update_agent_tags: post: - summary: Agents - Bulk update tags - tags: [] + summary: Bulk update agent tags + tags: + - Agents responses: '200': description: OK @@ -1599,8 +1629,9 @@ paths: - existingTag /agents/tags: get: - summary: Agent Tags - List - description: List all agent tags + summary: List agent tags + tags: + - Agents responses: '200': description: OK @@ -1619,8 +1650,9 @@ paths: in: path required: true post: - summary: Agent - Request Diagnostics - tags: [] + summary: Request agent diagnostics + tags: + - Agents responses: '200': description: OK @@ -1638,8 +1670,9 @@ paths: - $ref: '#/components/parameters/kbn_xsrf' /agents/bulk_request_diagnostics: post: - summary: Agent - Bulk Request Diagnostics - tags: [] + summary: Bulk request diagnostics from agents + tags: + - Agents responses: '200': description: OK @@ -1677,8 +1710,9 @@ paths: agents: 'fleet-agents.policy_id : ("policy1" or "policy2")' /agent_policies: get: - summary: Agent policies - List - tags: [] + summary: List agent policies + tags: + - Agent policies responses: '200': description: OK @@ -1727,8 +1761,9 @@ paths: 0 if set to true. description: '' post: - summary: Agent policy - Create - tags: [] + summary: Create agent policy + tags: + - Agent policies responses: '200': description: OK @@ -1758,8 +1793,9 @@ paths: in: path required: true get: - summary: Agent policy - Info - tags: [] + summary: Get agent policy by ID + tags: + - Agent policies responses: '200': description: OK @@ -1778,8 +1814,9 @@ paths: description: Get one agent policy parameters: [] put: - summary: Agent policy - Update - tags: [] + summary: Update agent policy by ID + tags: + - Agent policies responses: '200': description: OK @@ -1810,7 +1847,9 @@ paths: in: path required: true post: - summary: Agent policy - copy one policy + summary: Copy agent policy by ID + tags: + - Agent policies operationId: agent-policy-copy parameters: - $ref: '#/components/parameters/kbn_xsrf' @@ -1843,7 +1882,9 @@ paths: description: '' /agent_policies/{agentPolicyId}/full: get: - summary: Agent policy - Get full policy + summary: Get full agent policy by ID + tags: + - Agent policies operationId: agent-policy-full responses: '200': @@ -1882,7 +1923,9 @@ paths: required: false /agent_policies/{agentPolicyId}/download: get: - summary: Agent policy - Download + summary: Download agent policy by ID + tags: + - Agent policies operationId: agent-policy-download responses: '200': @@ -1919,8 +1962,9 @@ paths: required: false /agent_policies/_bulk_get: post: - summary: Agent policies - Bulk Get - tags: [] + summary: Bulk get agent policies + tags: + - Agent policies requestBody: content: application/json: @@ -1960,7 +2004,9 @@ paths: parameters: [] /agent_policies/delete: post: - summary: Agent policy - Delete + summary: Delete agent policy by ID + tags: + - Agent policies operationId: delete-agent-policy responses: '200': @@ -1994,8 +2040,9 @@ paths: parameters: [] /data_streams: get: - summary: Data streams - List - tags: [] + summary: List data streams + tags: + - Data streams responses: '200': description: OK @@ -2014,8 +2061,9 @@ paths: parameters: [] /enrollment-api-keys: get: - summary: Enrollment API Keys - List - tags: [] + summary: List enrollment API keys + tags: + - Enrollment API keys responses: '200': description: OK @@ -2050,8 +2098,9 @@ paths: parameters: [] deprecated: true post: - summary: Enrollment API Key - Create - tags: [] + summary: Create enrollment API key + tags: + - Enrollment API keys responses: '200': description: OK @@ -2080,8 +2129,9 @@ paths: in: path required: true get: - summary: Enrollment API Key - Info - tags: [] + summary: Get enrollment API key by ID + tags: + - Enrollment API keys responses: '200': description: OK @@ -2099,8 +2149,9 @@ paths: operationId: get-enrollment-api-key-deprecated deprecated: true delete: - summary: Enrollment API Key - Delete - tags: [] + summary: Delete enrollment API key by ID + tags: + - Enrollment API keys responses: '200': description: OK @@ -2123,8 +2174,9 @@ paths: deprecated: true /enrollment_api_keys: get: - summary: Enrollment API Keys - List - tags: [] + summary: List enrollment API keys + tags: + - Enrollment API keys responses: '200': description: OK @@ -2158,8 +2210,9 @@ paths: operationId: get-enrollment-api-keys parameters: [] post: - summary: Enrollment API Key - Create - tags: [] + summary: Create enrollment API key + tags: + - Enrollment API keys responses: '200': description: OK @@ -2187,8 +2240,9 @@ paths: in: path required: true get: - summary: Enrollment API Key - Info - tags: [] + summary: Get enrollment API key by ID + tags: + - Enrollment API keys responses: '200': description: OK @@ -2205,8 +2259,9 @@ paths: $ref: '#/components/responses/error' operationId: get-enrollment-api-key delete: - summary: Enrollment API Key - Delete - tags: [] + summary: Delete enrollment API key by ID + tags: + - Enrollment API keys responses: '200': description: OK @@ -2228,8 +2283,9 @@ paths: - $ref: '#/components/parameters/kbn_xsrf' /package_policies: get: - summary: Package policies - List - tags: [] + summary: List package policies + tags: + - Package policies responses: '200': description: OK @@ -2257,7 +2313,9 @@ paths: parameters: [] parameters: [] post: - summary: Package policy - Create + summary: Create package policy + tags: + - Package policies operationId: create-package-policy responses: '200': @@ -2285,8 +2343,9 @@ paths: - $ref: '#/components/parameters/kbn_xsrf' /package_policies/_bulk_get: post: - summary: Package policies - Bulk Get - tags: [] + summary: Bulk get package policies + tags: + - Package policies requestBody: content: application/json: @@ -2323,7 +2382,9 @@ paths: parameters: [] /package_policies/delete: post: - summary: Package policy - Delete + summary: Delete package policy + tags: + - Package policies operationId: post-delete-package-policy requestBody: content: @@ -2364,7 +2425,9 @@ paths: - $ref: '#/components/parameters/kbn_xsrf' /package_policies/upgrade: post: - summary: Package policy - Upgrade + summary: Upgrade package policy to a newer package version + tags: + - Package policies operationId: upgrade-package-policy requestBody: content: @@ -2401,7 +2464,9 @@ paths: $ref: '#/components/responses/error' /package_policies/upgrade/dryrun: post: - summary: Package policy - Upgrade Dry run + summary: Dry run package policy upgrade + tags: + - Package policies operationId: upgrade-package-policy-dry-run requestBody: content: @@ -2439,8 +2504,9 @@ paths: $ref: '#/components/responses/error' /package_policies/{packagePolicyId}: get: - summary: Package policy - Info - tags: [] + summary: Get package policy by ID + tags: + - Package policies responses: '200': description: OK @@ -2463,7 +2529,9 @@ paths: in: path required: true put: - summary: Package policy - Update + summary: Update package policy by ID + tags: + - Package policies operationId: update-package-policy requestBody: content: @@ -2490,8 +2558,9 @@ paths: parameters: - $ref: '#/components/parameters/kbn_xsrf' delete: - summary: Package policy - Delete - tags: [] + summary: Delete package policy by ID + tags: + - Package policies operationId: delete-package-policy responses: '200': @@ -2514,8 +2583,9 @@ paths: in: query /outputs: get: - summary: Outputs - tags: [] + summary: List outputs + tags: + - Outputs responses: '200': description: OK @@ -2538,9 +2608,9 @@ paths: $ref: '#/components/responses/error' operationId: get-outputs post: - summary: Outputs - description: Create a new output - tags: [] + summary: Create output + tags: + - Outputs responses: '200': description: OK @@ -2585,8 +2655,9 @@ paths: operationId: post-outputs /outputs/{outputId}: get: - summary: Output - Info - tags: [] + summary: Get output by ID + tags: + - Outputs responses: '200': description: OK @@ -2609,7 +2680,9 @@ paths: in: path required: true delete: - summary: Output - Delete + summary: Delete output by ID + tags: + - Outputs operationId: delete-output responses: '200': @@ -2628,7 +2701,9 @@ paths: parameters: - $ref: '#/components/parameters/kbn_xsrf' put: - summary: Output - Update + summary: Update output by ID + tags: + - Outputs operationId: update-output requestBody: content: @@ -2675,10 +2750,31 @@ paths: $ref: '#/components/responses/error' parameters: - $ref: '#/components/parameters/kbn_xsrf' + /logstash_api_keys: + post: + summary: Generate Logstash API key + tags: + - Outputs + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + properties: + api_key: + type: string + '400': + $ref: '#/components/responses/error' + operationId: generate-logstash-api-key + parameters: + - $ref: '#/components/parameters/kbn_xsrf' /agent_download_sources: get: - summary: Agent Download Sources - tags: [] + summary: List agent binary download sources + tags: + - Agent binary download sources responses: '200': description: OK @@ -2701,9 +2797,9 @@ paths: $ref: '#/components/responses/error' operationId: get-download-sources post: - summary: Agent Download Sources - description: Create a new agent download source - tags: [] + summary: Create agent binary download source + tags: + - Agent binary download sources responses: '200': description: OK @@ -2737,8 +2833,9 @@ paths: operationId: post-download-sources /agent_download_sources/{sourceId}: get: - summary: Agent Download Sources - Info - tags: [] + summary: Get agent binary download source by ID + tags: + - Agent binary download sources responses: '200': description: OK @@ -2761,7 +2858,9 @@ paths: in: path required: true delete: - summary: Agent Download Sources - Delete + summary: Delete agent binary download source by ID + tags: + - Agent binary download sources operationId: delete-download-source responses: '200': @@ -2780,7 +2879,9 @@ paths: parameters: - $ref: '#/components/parameters/kbn_xsrf' put: - summary: Agent Download Sources - Update + summary: Update agent binary download source by ID + tags: + - Agent binary download sources operationId: update-download-source requestBody: content: @@ -2814,30 +2915,11 @@ paths: $ref: '#/components/responses/error' parameters: - $ref: '#/components/parameters/kbn_xsrf' - /logstash_api_keys: - post: - summary: Generate Logstash API key - tags: [] - responses: - '200': - description: OK - content: - application/json: - schema: - type: object - properties: - api_key: - type: string - '400': - $ref: '#/components/responses/error' - operationId: generate-logstash-api-key - parameters: - - $ref: '#/components/parameters/kbn_xsrf' /fleet_server_hosts: get: - summary: Fleet Server Hosts - List - description: Return a list of Fleet server hosts - tags: [] + summary: List Fleet Server hosts + tags: + - Fleet Server hosts responses: '200': description: OK @@ -2860,9 +2942,9 @@ paths: $ref: '#/components/responses/error' operationId: get-fleet-server-hosts post: - summary: Fleet Server Hosts - Create - description: Create a new Fleet Server Host - tags: [] + summary: Create Fleet Server host + tags: + - Fleet Server hosts responses: '200': description: OK @@ -2897,8 +2979,9 @@ paths: operationId: post-fleet-server-hosts /fleet_server_hosts/{itemId}: get: - summary: Fleet Server Hosts - Info - tags: [] + summary: Get Fleet Server host by ID + tags: + - Fleet Server hosts responses: '200': description: OK @@ -2921,7 +3004,9 @@ paths: in: path required: true delete: - summary: Fleet Server Hosts - Delete + summary: Delete Fleet Server host by ID + tags: + - Fleet Server hosts operationId: delete-fleet-server-hosts responses: '200': @@ -2940,7 +3025,9 @@ paths: parameters: - $ref: '#/components/parameters/kbn_xsrf' put: - summary: Fleet Server Hosts - Update + summary: Update Fleet Server host by ID + tags: + - Fleet Server hosts operationId: update-fleet-server-hosts requestBody: content: @@ -2974,9 +3061,9 @@ paths: - $ref: '#/components/parameters/kbn_xsrf' /proxies: get: - summary: Fleet Proxies - List - description: Return a list of Proxies - tags: [] + summary: List proxies + tags: + - Proxies responses: '200': description: OK @@ -2999,9 +3086,9 @@ paths: $ref: '#/components/responses/error' operationId: get-fleet-proxies post: - summary: Fleet Proxies - Create - description: Create a new Fleet Server Host - tags: [] + summary: Create proxy + tags: + - Proxies responses: '200': description: OK @@ -3040,8 +3127,9 @@ paths: operationId: post-fleet-proxies /proxies/{itemId}: get: - summary: Fleet Proxies - Info - tags: [] + summary: Get proxy by ID + tags: + - Proxies responses: '200': description: OK @@ -3064,7 +3152,9 @@ paths: in: path required: true delete: - summary: Fleet Proxies - Delete + summary: Delete proxy by ID + tags: + - Proxies operationId: delete-fleet-proxies responses: '200': @@ -3083,7 +3173,9 @@ paths: parameters: - $ref: '#/components/parameters/kbn_xsrf' put: - summary: Fleet Proxies - Update + summary: Update proxy by ID + tags: + - Proxies operationId: update-fleet-proxies requestBody: content: @@ -3121,8 +3213,9 @@ paths: - $ref: '#/components/parameters/kbn_xsrf' /kubernetes: get: - summary: Get K8s Full Agent Manifest - tags: [] + summary: Get full K8s agent manifest + tags: + - Kubernetes responses: '200': description: OK @@ -3230,6 +3323,20 @@ components: required: false schema: type: boolean + responses: + error: + description: Generic Error + content: + application/json: + schema: + type: object + properties: + statusCode: + type: number + error: + type: string + message: + type: string schemas: fleet_setup_response: title: Fleet Setup response @@ -4612,19 +4719,5 @@ components: required: - name - url - responses: - error: - description: Generic Error - content: - application/json: - schema: - type: object - properties: - statusCode: - type: number - error: - type: string - message: - type: string security: - basicAuth: [] diff --git a/x-pack/plugins/fleet/common/openapi/entrypoint.yaml b/x-pack/plugins/fleet/common/openapi/entrypoint.yaml index 37c33c28b1053..ca9d1cd3c8e19 100644 --- a/x-pack/plugins/fleet/common/openapi/entrypoint.yaml +++ b/x-pack/plugins/fleet/common/openapi/entrypoint.yaml @@ -13,18 +13,18 @@ servers: - url: 'http://localhost:5601/api/fleet' description: local paths: - # plugin-wide endpoint(s) + # Fleet internals + /health_check: + $ref: paths/health_check.yaml /setup: $ref: paths/setup.yaml /settings: $ref: paths/settings.yaml - # App endpoints - /health_check: - $ref: paths/health_check.yaml /service-tokens: $ref: paths/service_tokens_deprecated.yaml /service_tokens: $ref: paths/service_tokens.yaml + # EPM / integrations endpoints /epm/verification_key_id: $ref: paths/epm@verification_key_id.yaml @@ -44,7 +44,8 @@ paths: $ref: paths/epm@get_file.yaml '/epm/packages/{pkgName}/stats': $ref: 'paths/epm@packages@{pkg_name}@stats.yaml' - # Agent-related endpoints + + # Agent endpoints /agents/setup: $ref: paths/agents@setup.yaml /agent-status: @@ -87,6 +88,7 @@ paths: $ref: 'paths/agents@{agent_id}@request_diagnostics.yaml' /agents/bulk_request_diagnostics: $ref: 'paths/agents@bulk_request_diagnostics.yaml' + # Agent policies endpoints /agent_policies: $ref: paths/agent_policies.yaml @@ -102,9 +104,11 @@ paths: $ref: paths/agent_policies@_bulk_get.yaml /agent_policies/delete: $ref: paths/agent_policies@delete.yaml + # Data streams endpoints /data_streams: $ref: paths/data_streams.yaml + # Enrollment endpoints /enrollment-api-keys: $ref: paths/enrollment_api_keys_deprecated.yaml @@ -114,6 +118,7 @@ paths: $ref: paths/enrollment_api_keys.yaml '/enrollment_api_keys/{keyId}': $ref: 'paths/enrollment_api_keys@{key_id}.yaml' + # Package policies endpoints /package_policies: $ref: paths/package_policies.yaml @@ -127,27 +132,33 @@ paths: $ref: paths/package_policies@upgrade_dryrun.yaml '/package_policies/{packagePolicyId}': $ref: 'paths/package_policies@{package_policy_id}.yaml' + # Outputs /outputs: $ref: paths/outputs.yaml /outputs/{outputId}: $ref: paths/outputs@{output_id}.yaml + /logstash_api_keys: + $ref: paths/logstash_api_keys.yaml + + # Agent binary download sources /agent_download_sources: $ref: paths/agent_download_sources.yaml /agent_download_sources/{sourceId}: $ref: paths/agent_download_sources@{source_id}.yaml - /logstash_api_keys: - $ref: paths/logstash_api_keys.yaml + # Fleet server hosts /fleet_server_hosts: $ref: paths/fleet_server_hosts.yaml /fleet_server_hosts/{itemId}: $ref: paths/fleet_server_hosts@{item_id}.yaml + # Fleet proxies /proxies: $ref: paths/proxies.yaml /proxies/{itemId}: $ref: paths/proxies@{item_id}.yaml + # K8s /kubernetes: $ref: paths/kubernetes.yaml diff --git a/x-pack/plugins/fleet/common/openapi/paths/agent_download_sources.yaml b/x-pack/plugins/fleet/common/openapi/paths/agent_download_sources.yaml index 619b3c626ac66..89a69c9adfdaf 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/agent_download_sources.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/agent_download_sources.yaml @@ -1,6 +1,7 @@ get: - summary: Agent Download Sources - tags: [] + summary: List agent binary download sources + tags: + - Agent binary download sources responses: '200': description: OK @@ -23,9 +24,9 @@ get: $ref: ../components/responses/error.yaml operationId: get-download-sources post: - summary: Agent Download Sources - description: 'Create a new agent download source' - tags: [] + summary: Create agent binary download source + tags: + - Agent binary download sources responses: '200': description: OK diff --git a/x-pack/plugins/fleet/common/openapi/paths/agent_download_sources@{source_id}.yaml b/x-pack/plugins/fleet/common/openapi/paths/agent_download_sources@{source_id}.yaml index 364d292082c8b..afb7771283e59 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/agent_download_sources@{source_id}.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/agent_download_sources@{source_id}.yaml @@ -1,6 +1,7 @@ get: - summary: Agent Download Sources - Info - tags: [] + summary: Get agent binary download source by ID + tags: + - Agent binary download sources responses: '200': description: OK @@ -23,7 +24,9 @@ parameters: in: path required: true delete: - summary: Agent Download Sources - Delete + summary: Delete agent binary download source by ID + tags: + - Agent binary download sources operationId: delete-download-source responses: '200': @@ -42,7 +45,9 @@ delete: parameters: - $ref: ../components/headers/kbn_xsrf.yaml put: - summary: Agent Download Sources - Update + summary: Update agent binary download source by ID + tags: + - Agent binary download sources operationId: update-download-source requestBody: content: diff --git a/x-pack/plugins/fleet/common/openapi/paths/agent_policies.yaml b/x-pack/plugins/fleet/common/openapi/paths/agent_policies.yaml index 33fd8a2348412..cbf29f3859519 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/agent_policies.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/agent_policies.yaml @@ -1,6 +1,7 @@ get: - summary: Agent policies - List - tags: [] + summary: List agent policies + tags: + - Agent policies responses: '200': description: OK @@ -44,8 +45,9 @@ get: description: '' post: - summary: Agent policy - Create - tags: [] + summary: Create agent policy + tags: + - Agent policies responses: '200': description: OK diff --git a/x-pack/plugins/fleet/common/openapi/paths/agent_policies@_bulk_get.yaml b/x-pack/plugins/fleet/common/openapi/paths/agent_policies@_bulk_get.yaml index 75267e2a262a9..ace09ef721677 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/agent_policies@_bulk_get.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/agent_policies@_bulk_get.yaml @@ -1,6 +1,7 @@ post: - summary: Agent policies - Bulk Get - tags: [] + summary: Bulk get agent policies + tags: + - Agent policies requestBody: content: application/json: diff --git a/x-pack/plugins/fleet/common/openapi/paths/agent_policies@delete.yaml b/x-pack/plugins/fleet/common/openapi/paths/agent_policies@delete.yaml index 51967a697cf0e..966d8abc1e328 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/agent_policies@delete.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/agent_policies@delete.yaml @@ -1,5 +1,7 @@ post: - summary: Agent policy - Delete + summary: Delete agent policy by ID + tags: + - Agent policies operationId: delete-agent-policy responses: '200': diff --git a/x-pack/plugins/fleet/common/openapi/paths/agent_policies@{agent_policy_id}.yaml b/x-pack/plugins/fleet/common/openapi/paths/agent_policies@{agent_policy_id}.yaml index 4a7e88abcbab8..55d644ab0aab2 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/agent_policies@{agent_policy_id}.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/agent_policies@{agent_policy_id}.yaml @@ -5,8 +5,9 @@ parameters: in: path required: true get: - summary: Agent policy - Info - tags: [] + summary: Get agent policy by ID + tags: + - Agent policies responses: '200': description: OK @@ -25,8 +26,9 @@ get: description: Get one agent policy parameters: [] put: - summary: Agent policy - Update - tags: [] + summary: Update agent policy by ID + tags: + - Agent policies responses: '200': description: OK diff --git a/x-pack/plugins/fleet/common/openapi/paths/agent_policies@{agent_policy_id}@copy.yaml b/x-pack/plugins/fleet/common/openapi/paths/agent_policies@{agent_policy_id}@copy.yaml index 21d4a1d493b01..dab79eef58dff 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/agent_policies@{agent_policy_id}@copy.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/agent_policies@{agent_policy_id}@copy.yaml @@ -5,7 +5,9 @@ parameters: in: path required: true post: - summary: Agent policy - copy one policy + summary: Copy agent policy by ID + tags: + - Agent policies operationId: agent-policy-copy parameters: - $ref: ../components/headers/kbn_xsrf.yaml @@ -36,4 +38,3 @@ post: required: - name description: '' - diff --git a/x-pack/plugins/fleet/common/openapi/paths/agent_policies@{agent_policy_id}@download.yaml b/x-pack/plugins/fleet/common/openapi/paths/agent_policies@{agent_policy_id}@download.yaml index 5c7887d6f1bb2..1748950fdaf09 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/agent_policies@{agent_policy_id}@download.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/agent_policies@{agent_policy_id}@download.yaml @@ -1,6 +1,7 @@ - get: - summary: Agent policy - Download + summary: Download agent policy by ID + tags: + - Agent policies operationId: agent-policy-download responses: '200': diff --git a/x-pack/plugins/fleet/common/openapi/paths/agent_policies@{agent_policy_id}@full.yaml b/x-pack/plugins/fleet/common/openapi/paths/agent_policies@{agent_policy_id}@full.yaml index 1a79266e27732..dc5a1b996b2e4 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/agent_policies@{agent_policy_id}@full.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/agent_policies@{agent_policy_id}@full.yaml @@ -1,6 +1,7 @@ - get: - summary: Agent policy - Get full policy + summary: Get full agent policy by ID + tags: + - Agent policies operationId: agent-policy-full responses: '200': diff --git a/x-pack/plugins/fleet/common/openapi/paths/agent_status.yaml b/x-pack/plugins/fleet/common/openapi/paths/agent_status.yaml index 46d8ac2f32ff9..6d4b1c77d991a 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/agent_status.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/agent_status.yaml @@ -1,6 +1,7 @@ get: - summary: Agents - Summary stats - tags: [] + summary: Get agent status summary + tags: + - Agent status responses: '200': description: OK @@ -29,7 +30,7 @@ get: updating: type: integer all: - type: integer + type: integer active: type: integer required: diff --git a/x-pack/plugins/fleet/common/openapi/paths/agent_status@data.yaml b/x-pack/plugins/fleet/common/openapi/paths/agent_status@data.yaml index a16fa2f71f8a8..7e90097c3b4dd 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/agent_status@data.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/agent_status@data.yaml @@ -1,6 +1,7 @@ get: - summary: Agents - Get incoming data - tags: [] + summary: Get incoming agent data + tags: + - Agent status responses: '200': description: OK diff --git a/x-pack/plugins/fleet/common/openapi/paths/agent_status_deprecated.yaml b/x-pack/plugins/fleet/common/openapi/paths/agent_status_deprecated.yaml index 874cd38632ed3..fe44311fa9801 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/agent_status_deprecated.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/agent_status_deprecated.yaml @@ -1,6 +1,7 @@ get: - summary: Agents - Summary stats - tags: [] + summary: Get agent status summary + tags: + - Agent status responses: '200': description: OK diff --git a/x-pack/plugins/fleet/common/openapi/paths/agent_tags.yaml b/x-pack/plugins/fleet/common/openapi/paths/agent_tags.yaml index f01584ef4665a..85a6f6c7ab30a 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/agent_tags.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/agent_tags.yaml @@ -1,6 +1,7 @@ get: - summary: Agent Tags - List - description: List all agent tags + summary: List agent tags + tags: + - Agents responses: '200': description: OK diff --git a/x-pack/plugins/fleet/common/openapi/paths/agents.yaml b/x-pack/plugins/fleet/common/openapi/paths/agents.yaml index b9b62f23552e1..cd74ff0a56636 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/agents.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/agents.yaml @@ -1,6 +1,7 @@ get: - summary: Agents - List - tags: [] + summary: List agents + tags: + - Agents responses: '200': description: OK diff --git a/x-pack/plugins/fleet/common/openapi/paths/agents@action_status.yaml b/x-pack/plugins/fleet/common/openapi/paths/agents@action_status.yaml index 50494a29f4096..1c2d013457d6f 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/agents@action_status.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/agents@action_status.yaml @@ -1,8 +1,10 @@ get: - summary: Agents - Action status + summary: Get agent action status + tags: + - Agent actions parameters: - - $ref: ../components/parameters/page_size.yaml - - $ref: ../components/parameters/page_index.yaml + - $ref: ../components/parameters/page_size.yaml + - $ref: ../components/parameters/page_index.yaml responses: '200': description: OK @@ -33,7 +35,7 @@ get: nbAgentsAck: type: number nbAgentsFailed: - type: number + type: number version: type: string startTime: @@ -49,7 +51,7 @@ get: newPolicyId: type: string creationTime: - type: string + type: string required: - actionId - complete @@ -63,4 +65,4 @@ get: - items '400': $ref: ../components/responses/error.yaml - operationId: agents-action-status \ No newline at end of file + operationId: agents-action-status diff --git a/x-pack/plugins/fleet/common/openapi/paths/agents@bulk_reassign.yaml b/x-pack/plugins/fleet/common/openapi/paths/agents@bulk_reassign.yaml index 625aee38eafc4..b93b2bd6b9a08 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/agents@bulk_reassign.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/agents@bulk_reassign.yaml @@ -1,16 +1,17 @@ post: - summary: Agents - Bulk reassign - tags: [] + summary: Bulk reassign agents + tags: + - Agents responses: '200': - description: OK - content: - application/json: - schema: - type: object - properties: - actionId: - type: string + description: OK + content: + application/json: + schema: + type: object + properties: + actionId: + type: string '400': $ref: ../components/responses/error.yaml operationId: bulk-reassign-agents @@ -38,4 +39,4 @@ post: - agents example: policy_id: policy_id - agents: "fleet-agents.policy_id : (\"policy1\" or \"policy2\")" + agents: 'fleet-agents.policy_id : ("policy1" or "policy2")' diff --git a/x-pack/plugins/fleet/common/openapi/paths/agents@bulk_request_diagnostics.yaml b/x-pack/plugins/fleet/common/openapi/paths/agents@bulk_request_diagnostics.yaml index e2952e7ae51e0..3f0733ed8f258 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/agents@bulk_request_diagnostics.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/agents@bulk_request_diagnostics.yaml @@ -1,6 +1,7 @@ post: - summary: Agent - Bulk Request Diagnostics - tags: [] + summary: Bulk request diagnostics from agents + tags: + - Agents responses: '200': description: OK @@ -35,4 +36,4 @@ post: required: - agents example: - agents: "fleet-agents.policy_id : (\"policy1\" or \"policy2\")" + agents: 'fleet-agents.policy_id : ("policy1" or "policy2")' diff --git a/x-pack/plugins/fleet/common/openapi/paths/agents@bulk_unenroll.yaml b/x-pack/plugins/fleet/common/openapi/paths/agents@bulk_unenroll.yaml index 7527558a4cc10..1ab9e4038b978 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/agents@bulk_unenroll.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/agents@bulk_unenroll.yaml @@ -1,16 +1,17 @@ post: - summary: Agents - Bulk unenroll - tags: [] + summary: Bulk unenroll agents + tags: + - Agents responses: '200': - description: OK - content: - application/json: - schema: - type: object - properties: - actionId: - type: string + description: OK + content: + application/json: + schema: + type: object + properties: + actionId: + type: string '400': $ref: ../components/responses/error.yaml operationId: bulk-unenroll-agents diff --git a/x-pack/plugins/fleet/common/openapi/paths/agents@bulk_update_tags.yaml b/x-pack/plugins/fleet/common/openapi/paths/agents@bulk_update_tags.yaml index 77c0c0d4cfa7c..ff4c6597b6be0 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/agents@bulk_update_tags.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/agents@bulk_update_tags.yaml @@ -1,16 +1,17 @@ post: - summary: Agents - Bulk update tags - tags: [] + summary: Bulk update agent tags + tags: + - Agents responses: '200': - description: OK - content: - application/json: - schema: - type: object - properties: - actionId: - type: string + description: OK + content: + application/json: + schema: + type: object + properties: + actionId: + type: string '400': $ref: ../components/responses/error.yaml operationId: bulk-update-agent-tags @@ -39,10 +40,10 @@ post: items: type: string batchSize: - type: number + type: number required: - agents example: agents: [agent1, agent2] tagsToAdd: [newTag] - tagsToRemove: [existingTag] + tagsToRemove: [existingTag] diff --git a/x-pack/plugins/fleet/common/openapi/paths/agents@bulk_upgrade.yaml b/x-pack/plugins/fleet/common/openapi/paths/agents@bulk_upgrade.yaml index b8863eaf271fd..ccb55c7c62b17 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/agents@bulk_upgrade.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/agents@bulk_upgrade.yaml @@ -1,16 +1,17 @@ post: - summary: Agents - Bulk Upgrade - tags: [] + summary: Bulk upgrade agents + tags: + - Agents responses: '200': description: OK content: application/json: schema: - type: object - properties: - actionId: - type: string + type: object + properties: + actionId: + type: string '400': $ref: ../components/responses/error.yaml operationId: bulk-upgrade-agents diff --git a/x-pack/plugins/fleet/common/openapi/paths/agents@current_upgrades.yaml b/x-pack/plugins/fleet/common/openapi/paths/agents@current_upgrades.yaml index 162c9e4cb5bc3..36ae723527f9b 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/agents@current_upgrades.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/agents@current_upgrades.yaml @@ -1,6 +1,7 @@ get: - summary: Agents - Current Bulk Upgrades - tags: [] + summary: List current bulk upgrade operations + tags: + - Agents responses: '200': description: OK diff --git a/x-pack/plugins/fleet/common/openapi/paths/agents@files@{file_id}@{file_name}.yaml b/x-pack/plugins/fleet/common/openapi/paths/agents@files@{file_id}@{file_name}.yaml index 82192ade7856b..15f6dd8a421d1 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/agents@files@{file_id}@{file_name}.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/agents@files@{file_id}@{file_name}.yaml @@ -10,8 +10,9 @@ parameters: in: path required: true get: - summary: Get agent upload file - tags: [] + summary: Get file uploaded by agent + tags: + - Agents responses: '200': description: OK diff --git a/x-pack/plugins/fleet/common/openapi/paths/agents@setup.yaml b/x-pack/plugins/fleet/common/openapi/paths/agents@setup.yaml index 104ae1ba084da..214f3a8e68240 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/agents@setup.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/agents@setup.yaml @@ -1,6 +1,7 @@ get: - summary: Agents setup - Info - tags: [] + summary: Get agent setup info + tags: + - Agents responses: '200': description: OK @@ -14,7 +15,9 @@ get: security: - basicAuth: [] post: - summary: Agents setup - Create + summary: Initiate agent setup + tags: + - Agents operationId: setup-agents responses: '200': diff --git a/x-pack/plugins/fleet/common/openapi/paths/agents@{agent_id}.yaml b/x-pack/plugins/fleet/common/openapi/paths/agents@{agent_id}.yaml index 7bf3a7d73f31b..93242e5912a17 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/agents@{agent_id}.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/agents@{agent_id}.yaml @@ -5,8 +5,9 @@ parameters: in: path required: true get: - summary: Agent - Info - tags: [] + summary: Get agent by ID + tags: + - Agents responses: '200': description: OK @@ -25,8 +26,9 @@ get: parameters: - $ref: ../components/parameters/with_metrics.yaml put: - summary: Agent - Update - tags: [] + summary: Update agent by ID + tags: + - Agents responses: '200': description: OK @@ -58,8 +60,9 @@ put: items: type: string delete: - summary: Agent - Delete - tags: [] + summary: Delete agent by ID + tags: + - Agents responses: '200': description: OK diff --git a/x-pack/plugins/fleet/common/openapi/paths/agents@{agent_id}@actions.yaml b/x-pack/plugins/fleet/common/openapi/paths/agents@{agent_id}@actions.yaml index 38cce1ea54db3..cd327e453b9a7 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/agents@{agent_id}@actions.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/agents@{agent_id}@actions.yaml @@ -5,8 +5,9 @@ parameters: in: path required: true post: - summary: Agent - Actions - tags: [] + summary: Create agent action + tags: + - Agent actions responses: '200': description: OK @@ -35,5 +36,5 @@ post: schema: type: object properties: - action: - $ref: ../components/schemas/agent_action.yaml + action: + $ref: ../components/schemas/agent_action.yaml diff --git a/x-pack/plugins/fleet/common/openapi/paths/agents@{agent_id}@actions@{action_id}@cancel.yaml b/x-pack/plugins/fleet/common/openapi/paths/agents@{agent_id}@actions@{action_id}@cancel.yaml index c9bf661d88a85..f91acd133355d 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/agents@{agent_id}@actions@{action_id}@cancel.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/agents@{agent_id}@actions@{action_id}@cancel.yaml @@ -10,8 +10,9 @@ parameters: in: path required: true post: - summary: Agent - Cancel Action - tags: [] + summary: Cancel agent action + tags: + - Agent actions responses: '200': description: OK diff --git a/x-pack/plugins/fleet/common/openapi/paths/agents@{agent_id}@reassign.yaml b/x-pack/plugins/fleet/common/openapi/paths/agents@{agent_id}@reassign.yaml index af00d1563854e..c210cee12d424 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/agents@{agent_id}@reassign.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/agents@{agent_id}@reassign.yaml @@ -5,8 +5,9 @@ parameters: in: path required: true post: - summary: Agent - Reassign - tags: [] + summary: Reassign agent + tags: + - Agents responses: '200': description: OK @@ -31,8 +32,9 @@ post: required: - policy_id put: - summary: Agent - Reassign - tags: [] + summary: Reassign agent + tags: + - Agents responses: '200': description: OK @@ -57,4 +59,3 @@ put: required: - policy_id deprecated: true - diff --git a/x-pack/plugins/fleet/common/openapi/paths/agents@{agent_id}@request_diagnostics.yaml b/x-pack/plugins/fleet/common/openapi/paths/agents@{agent_id}@request_diagnostics.yaml index 13b335ffe2300..37aed12d5f4f1 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/agents@{agent_id}@request_diagnostics.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/agents@{agent_id}@request_diagnostics.yaml @@ -5,8 +5,9 @@ parameters: in: path required: true post: - summary: Agent - Request Diagnostics - tags: [] + summary: Request agent diagnostics + tags: + - Agents responses: '200': description: OK @@ -22,4 +23,3 @@ post: operationId: request-diagnostics-agent parameters: - $ref: ../components/headers/kbn_xsrf.yaml - diff --git a/x-pack/plugins/fleet/common/openapi/paths/agents@{agent_id}@unenroll.yaml b/x-pack/plugins/fleet/common/openapi/paths/agents@{agent_id}@unenroll.yaml index b9664ae650112..c30bebfad328a 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/agents@{agent_id}@unenroll.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/agents@{agent_id}@unenroll.yaml @@ -5,30 +5,31 @@ parameters: in: path required: true post: - summary: Agent - Unenroll - tags: [] + summary: Unenroll agent + tags: + - Agents responses: '200': - description: OK - content: - application/json: - schema: - type: object + description: OK + content: + application/json: + schema: + type: object '400': - description: BAD REQUEST - content: - application/json: - schema: - type: object - properties: - error: - type: string - message: - type: string - statusCode: - type: number - enum: - - 400 + description: BAD REQUEST + content: + application/json: + schema: + type: object + properties: + error: + type: string + message: + type: string + statusCode: + type: number + enum: + - 400 operationId: unenroll-agent parameters: - $ref: ../components/headers/kbn_xsrf.yaml diff --git a/x-pack/plugins/fleet/common/openapi/paths/agents@{agent_id}@upgrade.yaml b/x-pack/plugins/fleet/common/openapi/paths/agents@{agent_id}@upgrade.yaml index c6d66f6f52386..d824d4a54f985 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/agents@{agent_id}@upgrade.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/agents@{agent_id}@upgrade.yaml @@ -5,8 +5,9 @@ parameters: in: path required: true post: - summary: Agent - Upgrade - tags: [] + summary: Upgrade agent + tags: + - Agents responses: '200': description: OK diff --git a/x-pack/plugins/fleet/common/openapi/paths/agents@{agent_id}@uploads.yaml b/x-pack/plugins/fleet/common/openapi/paths/agents@{agent_id}@uploads.yaml index de812b0e363e3..f92acc7fe5086 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/agents@{agent_id}@uploads.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/agents@{agent_id}@uploads.yaml @@ -6,7 +6,8 @@ parameters: required: true get: summary: List agent uploads - tags: [] + tags: + - Agents responses: '200': description: OK diff --git a/x-pack/plugins/fleet/common/openapi/paths/data_streams.yaml b/x-pack/plugins/fleet/common/openapi/paths/data_streams.yaml index c9e9f1be897aa..bb8c667ba933e 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/data_streams.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/data_streams.yaml @@ -1,6 +1,7 @@ get: - summary: Data streams - List - tags: [] + summary: List data streams + tags: + - Data streams responses: '200': description: OK diff --git a/x-pack/plugins/fleet/common/openapi/paths/enrollment_api_keys.yaml b/x-pack/plugins/fleet/common/openapi/paths/enrollment_api_keys.yaml index 5bc257606087f..3351b63026e57 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/enrollment_api_keys.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/enrollment_api_keys.yaml @@ -1,6 +1,7 @@ get: - summary: Enrollment API Keys - List - tags: [] + summary: List enrollment API keys + tags: + - Enrollment API keys responses: '200': description: OK @@ -34,8 +35,9 @@ get: operationId: get-enrollment-api-keys parameters: [] post: - summary: Enrollment API Key - Create - tags: [] + summary: Create enrollment API key + tags: + - Enrollment API keys responses: '200': description: OK diff --git a/x-pack/plugins/fleet/common/openapi/paths/enrollment_api_keys@{key_id}.yaml b/x-pack/plugins/fleet/common/openapi/paths/enrollment_api_keys@{key_id}.yaml index bdff9a7152e45..d64b1053f0dc4 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/enrollment_api_keys@{key_id}.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/enrollment_api_keys@{key_id}.yaml @@ -5,8 +5,9 @@ parameters: in: path required: true get: - summary: Enrollment API Key - Info - tags: [] + summary: Get enrollment API key by ID + tags: + - Enrollment API keys responses: '200': description: OK @@ -23,8 +24,9 @@ get: $ref: ../components/responses/error.yaml operationId: get-enrollment-api-key delete: - summary: Enrollment API Key - Delete - tags: [] + summary: Delete enrollment API key by ID + tags: + - Enrollment API keys responses: '200': description: OK diff --git a/x-pack/plugins/fleet/common/openapi/paths/enrollment_api_keys@{key_id}_deprecated.yaml b/x-pack/plugins/fleet/common/openapi/paths/enrollment_api_keys@{key_id}_deprecated.yaml index 36c0f7f3ef01f..c0f5be7521e8a 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/enrollment_api_keys@{key_id}_deprecated.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/enrollment_api_keys@{key_id}_deprecated.yaml @@ -5,8 +5,9 @@ parameters: in: path required: true get: - summary: Enrollment API Key - Info - tags: [] + summary: Get enrollment API key by ID + tags: + - Enrollment API keys responses: '200': description: OK @@ -24,8 +25,9 @@ get: operationId: get-enrollment-api-key-deprecated deprecated: true delete: - summary: Enrollment API Key - Delete - tags: [] + summary: Delete enrollment API key by ID + tags: + - Enrollment API keys responses: '200': description: OK diff --git a/x-pack/plugins/fleet/common/openapi/paths/enrollment_api_keys_deprecated.yaml b/x-pack/plugins/fleet/common/openapi/paths/enrollment_api_keys_deprecated.yaml index c5e378c563afc..19022a0b08223 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/enrollment_api_keys_deprecated.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/enrollment_api_keys_deprecated.yaml @@ -1,6 +1,7 @@ get: - summary: Enrollment API Keys - List - tags: [] + summary: List enrollment API keys + tags: + - Enrollment API keys responses: '200': description: OK @@ -35,8 +36,9 @@ get: parameters: [] deprecated: true post: - summary: Enrollment API Key - Create - tags: [] + summary: Create enrollment API key + tags: + - Enrollment API keys responses: '200': description: OK diff --git a/x-pack/plugins/fleet/common/openapi/paths/epm@categories.yaml b/x-pack/plugins/fleet/common/openapi/paths/epm@categories.yaml index a97c06f66c629..e733f780abe04 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/epm@categories.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/epm@categories.yaml @@ -1,6 +1,7 @@ get: - summary: Package categories - tags: [] + summary: List package categories + tags: + - Elastic Package Manager (EPM) responses: '200': description: OK @@ -12,21 +13,21 @@ get: $ref: ../components/responses/error.yaml operationId: get-package-categories parameters: - - in: query + - in: query name: prerelease schema: type: boolean default: false description: >- - Whether to include prerelease packages in categories count (e.g. beta, rc, preview) - - in: query + Whether to include prerelease packages in categories count (e.g. beta, rc, preview) + - in: query name: experimental deprecated: true schema: type: boolean default: false - - in: query + - in: query name: include_policy_templates schema: type: boolean - default: false \ No newline at end of file + default: false diff --git a/x-pack/plugins/fleet/common/openapi/paths/epm@get_file.yaml b/x-pack/plugins/fleet/common/openapi/paths/epm@get_file.yaml index 9c194ea6a8e97..b85b72938feda 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/epm@get_file.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/epm@get_file.yaml @@ -1,6 +1,7 @@ get: - summary: Packages - Get file from registry - tags: [] + summary: Get package file + tags: + - Elastic Package Manager (EPM) responses: '200': description: OK diff --git a/x-pack/plugins/fleet/common/openapi/paths/epm@limited_list.yaml b/x-pack/plugins/fleet/common/openapi/paths/epm@limited_list.yaml index ec44a20b61307..a54c45782d3ae 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/epm@limited_list.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/epm@limited_list.yaml @@ -1,6 +1,7 @@ get: - summary: Packages - Get limited list - tags: [] + summary: Get limited package list + tags: + - Elastic Package Manager (EPM) responses: '200': description: OK diff --git a/x-pack/plugins/fleet/common/openapi/paths/epm@packages.yaml b/x-pack/plugins/fleet/common/openapi/paths/epm@packages.yaml index 43819dff6d10e..7434fd2d324a5 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/epm@packages.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/epm@packages.yaml @@ -1,6 +1,7 @@ get: - summary: Packages - List - tags: [] + summary: List packages + tags: + - Elastic Package Manager (EPM) responses: '200': description: OK @@ -22,26 +23,27 @@ get: caching for the response via `cache-control` headers. If you don't need up-to-date installation info for a package, and are querying for a list of available packages, providing this flag can improve performance substantially. - - in: query + - in: query name: prerelease schema: type: boolean default: false description: >- - Whether to return prerelease versions of packages (e.g. beta, rc, preview) - - in: query + Whether to return prerelease versions of packages (e.g. beta, rc, preview) + - in: query name: experimental deprecated: true schema: type: boolean default: false - - in: query + - in: query name: category schema: type: string post: - summary: Packages - Install by upload - tags: [] + summary: Install by package by direct upload + tags: + - Elastic Package Manager (EPM) responses: '200': description: OK @@ -90,4 +92,4 @@ post: application/gzip: schema: type: string - format: binary \ No newline at end of file + format: binary diff --git a/x-pack/plugins/fleet/common/openapi/paths/epm@packages@{pkg_name}@stats.yaml b/x-pack/plugins/fleet/common/openapi/paths/epm@packages@{pkg_name}@stats.yaml index b27b4ef6729dc..f90a275cd19b6 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/epm@packages@{pkg_name}@stats.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/epm@packages@{pkg_name}@stats.yaml @@ -1,6 +1,7 @@ get: - summary: Get stats for a package - tags: [] + summary: Get package stats + tags: + - Elastic Package Manager (EPM) responses: '200': description: OK diff --git a/x-pack/plugins/fleet/common/openapi/paths/epm@packages@{pkg_name}@{pkg_version}.yaml b/x-pack/plugins/fleet/common/openapi/paths/epm@packages@{pkg_name}@{pkg_version}.yaml index 4cc2e55e9d29e..4fff7f0b21504 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/epm@packages@{pkg_name}@{pkg_version}.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/epm@packages@{pkg_name}@{pkg_version}.yaml @@ -1,6 +1,7 @@ get: - summary: Packages - Info - tags: [] + summary: Get package + tags: + - Elastic Package Manager (EPM) responses: '200': description: OK @@ -59,16 +60,17 @@ parameters: name: full description: 'Return all fields from the package manifest, not just those supported by the Elastic Package Registry' in: query - - in: query + - in: query name: prerelease schema: type: boolean default: false description: >- - Whether to return prerelease versions of packages (e.g. beta, rc, preview) + Whether to return prerelease versions of packages (e.g. beta, rc, preview) post: - summary: Packages - Install - tags: [] + summary: Install package + tags: + - Elastic Package Manager (EPM) responses: '200': description: OK @@ -119,8 +121,9 @@ post: ignore_constraints: type: boolean put: - summary: Packages - Update - tags: [] + summary: Update package settings + tags: + - Elastic Package Manager (EPM) responses: '200': description: OK @@ -158,8 +161,9 @@ put: keepPoliciesUpToDate: type: boolean delete: - summary: Packages - Delete - tags: [] + summary: Delete package + tags: + - Elastic Package Manager (EPM) responses: '200': description: OK diff --git a/x-pack/plugins/fleet/common/openapi/paths/epm@packages@{pkgkey}_deprecated.yaml b/x-pack/plugins/fleet/common/openapi/paths/epm@packages@{pkgkey}_deprecated.yaml index 2967238a467a2..035809782bc07 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/epm@packages@{pkgkey}_deprecated.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/epm@packages@{pkgkey}_deprecated.yaml @@ -1,6 +1,7 @@ get: - summary: Packages - Info - tags: [] + summary: Get package + tags: + - Elastic Package Manager (EPM) responses: '200': description: OK @@ -36,17 +37,18 @@ get: name: pkgkey in: path required: true - - in: query + - in: query name: prerelease schema: type: boolean default: false description: >- - Whether to return prerelease versions of packages (e.g. beta, rc, preview) + Whether to return prerelease versions of packages (e.g. beta, rc, preview) deprecated: true post: - summary: Packages - Install - tags: [] + summary: Install package + tags: + - Elastic Package Manager (EPM) responses: '200': description: OK @@ -92,8 +94,9 @@ post: type: boolean deprecated: true delete: - summary: Packages - Delete - tags: [] + summary: Delete ackage + tags: + - Elastic Package Manager (EPM) responses: '200': description: OK diff --git a/x-pack/plugins/fleet/common/openapi/paths/epm@packages_bulk.yaml b/x-pack/plugins/fleet/common/openapi/paths/epm@packages_bulk.yaml index 7ede68f6b545f..a3775e69a7131 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/epm@packages_bulk.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/epm@packages_bulk.yaml @@ -1,6 +1,7 @@ post: - summary: Packages - Bulk install - tags: [] + summary: Bulk install packages + tags: + - Elastic Package Manager (EPM) responses: '200': description: OK @@ -12,13 +13,13 @@ post: $ref: ../components/responses/error.yaml operationId: bulk-install-packages parameters: - - in: query + - in: query name: prerelease schema: type: boolean default: false description: >- - Whether to return prerelease versions of packages (e.g. beta, rc, preview) + Whether to return prerelease versions of packages (e.g. beta, rc, preview) requestBody: content: application/json: @@ -32,7 +33,6 @@ post: description: list of package names to install force: type: boolean - description: force install to ignore package verification errors + description: force install to ignore package verification errors required: - packages - diff --git a/x-pack/plugins/fleet/common/openapi/paths/epm@verification_key_id.yaml b/x-pack/plugins/fleet/common/openapi/paths/epm@verification_key_id.yaml index c9216b85cd78f..24de03ab52cd8 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/epm@verification_key_id.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/epm@verification_key_id.yaml @@ -1,6 +1,7 @@ get: summary: Get package signature verification key ID - tags: [] + tags: + - Elastic Package Manager (EPM) responses: '200': description: OK @@ -12,7 +13,7 @@ get: body: type: object properties: - id: + id: type: string nullable: true description: the key ID of the GPG key used to verify package signatures @@ -23,19 +24,4 @@ get: '400': $ref: ../components/responses/error.yaml operationId: packages-get-verification-key-id -parameters: - - schema: - type: string - name: pkgName - in: path - required: true - - schema: - type: string - name: pkgVersion - in: path - required: true - - schema: - type: string - name: filePath - in: path - required: true +parameters: [] diff --git a/x-pack/plugins/fleet/common/openapi/paths/fleet_server_hosts.yaml b/x-pack/plugins/fleet/common/openapi/paths/fleet_server_hosts.yaml index da599dddca1e3..d7668f3683b7b 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/fleet_server_hosts.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/fleet_server_hosts.yaml @@ -1,7 +1,7 @@ get: - summary: Fleet Server Hosts - List - description: Return a list of Fleet server hosts - tags: [] + summary: List Fleet Server hosts + tags: + - Fleet Server hosts responses: '200': description: OK @@ -24,9 +24,9 @@ get: $ref: ../components/responses/error.yaml operationId: get-fleet-server-hosts post: - summary: Fleet Server Hosts - Create - description: 'Create a new Fleet Server Host' - tags: [] + summary: Create Fleet Server host + tags: + - Fleet Server hosts responses: '200': description: OK diff --git a/x-pack/plugins/fleet/common/openapi/paths/fleet_server_hosts@{item_id}.yaml b/x-pack/plugins/fleet/common/openapi/paths/fleet_server_hosts@{item_id}.yaml index 968f81d8c6181..d46a8b86fb7f6 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/fleet_server_hosts@{item_id}.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/fleet_server_hosts@{item_id}.yaml @@ -1,6 +1,7 @@ get: - summary: Fleet Server Hosts - Info - tags: [] + summary: Get Fleet Server host by ID + tags: + - Fleet Server hosts responses: '200': description: OK @@ -23,7 +24,9 @@ parameters: in: path required: true delete: - summary: Fleet Server Hosts - Delete + summary: Delete Fleet Server host by ID + tags: + - Fleet Server hosts operationId: delete-fleet-server-hosts responses: '200': @@ -42,7 +45,9 @@ delete: parameters: - $ref: ../components/headers/kbn_xsrf.yaml put: - summary: Fleet Server Hosts - Update + summary: Update Fleet Server host by ID + tags: + - Fleet Server hosts operationId: update-fleet-server-hosts requestBody: content: diff --git a/x-pack/plugins/fleet/common/openapi/paths/health_check.yaml b/x-pack/plugins/fleet/common/openapi/paths/health_check.yaml index 84283ca80dbf0..ae87da3ff0e52 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/health_check.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/health_check.yaml @@ -1,6 +1,7 @@ post: - summary: Fleet Server Health Check - tags: [] + summary: Fleet Server health check + tags: + - Fleet internals responses: '200': description: OK diff --git a/x-pack/plugins/fleet/common/openapi/paths/kubernetes.yaml b/x-pack/plugins/fleet/common/openapi/paths/kubernetes.yaml index d7852db70fccd..41110808cd62d 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/kubernetes.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/kubernetes.yaml @@ -1,6 +1,7 @@ get: - summary: Get K8s Full Agent Manifest - tags: [] + summary: Get full K8s agent manifest + tags: + - Kubernetes responses: '200': description: OK @@ -15,18 +16,18 @@ get: $ref: ../components/responses/error.yaml operationId: get-full-k8s-manifest parameters: - - schema: - type: boolean - name: download - in: query - required: false - - schema: - type: string - name: fleetServer - in: query - required: false - - schema: - type: string - name: enrolToken - in: query - required: false + - schema: + type: boolean + name: download + in: query + required: false + - schema: + type: string + name: fleetServer + in: query + required: false + - schema: + type: string + name: enrolToken + in: query + required: false diff --git a/x-pack/plugins/fleet/common/openapi/paths/logstash_api_keys.yaml b/x-pack/plugins/fleet/common/openapi/paths/logstash_api_keys.yaml index 495d792191798..74e3bdde4cac8 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/logstash_api_keys.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/logstash_api_keys.yaml @@ -1,6 +1,7 @@ post: summary: Generate Logstash API key - tags: [] + tags: + - Outputs responses: '200': description: OK diff --git a/x-pack/plugins/fleet/common/openapi/paths/outputs.yaml b/x-pack/plugins/fleet/common/openapi/paths/outputs.yaml index 335d8ec570ca1..5ba06a5c36372 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/outputs.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/outputs.yaml @@ -1,6 +1,7 @@ get: - summary: Outputs - tags: [] + summary: List outputs + tags: + - Outputs responses: '200': description: OK @@ -23,9 +24,9 @@ get: $ref: ../components/responses/error.yaml operationId: get-outputs post: - summary: Outputs - description: 'Create a new output' - tags: [] + summary: Create output + tags: + - Outputs responses: '200': description: OK @@ -50,7 +51,7 @@ post: type: string type: type: string - enum: ["elasticsearch"] + enum: ['elasticsearch'] is_default: type: boolean is_default_monitoring: diff --git a/x-pack/plugins/fleet/common/openapi/paths/outputs@{output_id}.yaml b/x-pack/plugins/fleet/common/openapi/paths/outputs@{output_id}.yaml index ca01024288b95..8bd6ae2fc288c 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/outputs@{output_id}.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/outputs@{output_id}.yaml @@ -1,6 +1,7 @@ get: - summary: Output - Info - tags: [] + summary: Get output by ID + tags: + - Outputs responses: '200': description: OK @@ -23,7 +24,9 @@ parameters: in: path required: true delete: - summary: Output - Delete + summary: Delete output by ID + tags: + - Outputs operationId: delete-output responses: '200': @@ -33,7 +36,7 @@ delete: schema: type: object properties: - id: + id: type: string required: - id @@ -42,7 +45,9 @@ delete: parameters: - $ref: ../components/headers/kbn_xsrf.yaml put: - summary: Output - Update + summary: Update output by ID + tags: + - Outputs operationId: update-output requestBody: content: @@ -54,14 +59,14 @@ put: type: string type: type: string - enum: ["elasticsearch"] + enum: ['elasticsearch'] is_default: type: boolean is_default_monitoring: type: boolean hosts: type: array - items: + items: type: string ca_sha256: type: string diff --git a/x-pack/plugins/fleet/common/openapi/paths/package_policies.yaml b/x-pack/plugins/fleet/common/openapi/paths/package_policies.yaml index 8959339426d05..0fe987e1727de 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/package_policies.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/package_policies.yaml @@ -1,6 +1,7 @@ get: - summary: Package policies - List - tags: [] + summary: List package policies + tags: + - Package policies responses: '200': description: OK @@ -28,7 +29,9 @@ get: parameters: [] parameters: [] post: - summary: Package policy - Create + summary: Create package policy + tags: + - Package policies operationId: create-package-policy responses: '200': diff --git a/x-pack/plugins/fleet/common/openapi/paths/package_policies@_bulk_get.yaml b/x-pack/plugins/fleet/common/openapi/paths/package_policies@_bulk_get.yaml index 1ff515dc2de6a..eb22c7d997575 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/package_policies@_bulk_get.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/package_policies@_bulk_get.yaml @@ -1,6 +1,7 @@ post: - summary: Package policies - Bulk Get - tags: [] + summary: Bulk get package policies + tags: + - Package policies requestBody: content: application/json: diff --git a/x-pack/plugins/fleet/common/openapi/paths/package_policies@delete.yaml b/x-pack/plugins/fleet/common/openapi/paths/package_policies@delete.yaml index 6061267b4b2b8..f21111c23757a 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/package_policies@delete.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/package_policies@delete.yaml @@ -1,5 +1,7 @@ post: - summary: Package policy - Delete + summary: Delete package policy + tags: + - Package policies operationId: post-delete-package-policy requestBody: content: diff --git a/x-pack/plugins/fleet/common/openapi/paths/package_policies@upgrade.yaml b/x-pack/plugins/fleet/common/openapi/paths/package_policies@upgrade.yaml index 09f2727ad678c..2b6e69d49c44e 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/package_policies@upgrade.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/package_policies@upgrade.yaml @@ -1,5 +1,7 @@ post: - summary: Package policy - Upgrade + summary: Upgrade package policy to a newer package version + tags: + - Package policies operationId: upgrade-package-policy requestBody: content: diff --git a/x-pack/plugins/fleet/common/openapi/paths/package_policies@upgrade_dryrun.yaml b/x-pack/plugins/fleet/common/openapi/paths/package_policies@upgrade_dryrun.yaml index 6f51bd6812d97..5019aba15898d 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/package_policies@upgrade_dryrun.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/package_policies@upgrade_dryrun.yaml @@ -1,5 +1,7 @@ post: - summary: Package policy - Upgrade Dry run + summary: Dry run package policy upgrade + tags: + - Package policies operationId: upgrade-package-policy-dry-run requestBody: content: diff --git a/x-pack/plugins/fleet/common/openapi/paths/package_policies@{package_policy_id}.yaml b/x-pack/plugins/fleet/common/openapi/paths/package_policies@{package_policy_id}.yaml index 9e05e9516d603..30d89d271a5ff 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/package_policies@{package_policy_id}.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/package_policies@{package_policy_id}.yaml @@ -1,6 +1,7 @@ get: - summary: Package policy - Info - tags: [] + summary: Get package policy by ID + tags: + - Package policies responses: '200': description: OK @@ -23,7 +24,9 @@ parameters: in: path required: true put: - summary: Package policy - Update + summary: Update package policy by ID + tags: + - Package policies operationId: update-package-policy requestBody: content: @@ -50,8 +53,9 @@ put: parameters: - $ref: ../components/headers/kbn_xsrf.yaml delete: - summary: Package policy - Delete - tags: [] + summary: Delete package policy by ID + tags: + - Package policies operationId: delete-package-policy responses: '200': diff --git a/x-pack/plugins/fleet/common/openapi/paths/proxies.yaml b/x-pack/plugins/fleet/common/openapi/paths/proxies.yaml index a5f59ec0e7cb5..6c2844a9ac3ef 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/proxies.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/proxies.yaml @@ -1,7 +1,7 @@ get: - summary: Fleet Proxies - List - description: Return a list of Proxies - tags: [] + summary: List proxies + tags: + - Proxies responses: '200': description: OK @@ -24,9 +24,9 @@ get: $ref: ../components/responses/error.yaml operationId: get-fleet-proxies post: - summary: Fleet Proxies - Create - description: 'Create a new Fleet Server Host' - tags: [] + summary: Create proxy + tags: + - Proxies responses: '200': description: OK diff --git a/x-pack/plugins/fleet/common/openapi/paths/proxies@{item_id}.yaml b/x-pack/plugins/fleet/common/openapi/paths/proxies@{item_id}.yaml index 96a3665718753..3a0a10cb35662 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/proxies@{item_id}.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/proxies@{item_id}.yaml @@ -1,6 +1,7 @@ get: - summary: Fleet Proxies - Info - tags: [] + summary: Get proxy by ID + tags: + - Proxies responses: '200': description: OK @@ -23,7 +24,9 @@ parameters: in: path required: true delete: - summary: Fleet Proxies - Delete + summary: Delete proxy by ID + tags: + - Proxies operationId: delete-fleet-proxies responses: '200': @@ -42,7 +45,9 @@ delete: parameters: - $ref: ../components/headers/kbn_xsrf.yaml put: - summary: Fleet Proxies - Update + summary: Update proxy by ID + tags: + - Proxies operationId: update-fleet-proxies requestBody: content: diff --git a/x-pack/plugins/fleet/common/openapi/paths/service_tokens.yaml b/x-pack/plugins/fleet/common/openapi/paths/service_tokens.yaml index c57614c6c5def..e76f18c5b57d7 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/service_tokens.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/service_tokens.yaml @@ -1,6 +1,7 @@ post: - summary: Generate service tokens - tags: [] + summary: Create service token + tags: + - Service tokens responses: '200': description: OK diff --git a/x-pack/plugins/fleet/common/openapi/paths/service_tokens_deprecated.yaml b/x-pack/plugins/fleet/common/openapi/paths/service_tokens_deprecated.yaml index f081f207b4d1e..73069830be9e1 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/service_tokens_deprecated.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/service_tokens_deprecated.yaml @@ -1,6 +1,7 @@ post: - summary: Generate service tokens - tags: [] + summary: Create service token + tags: + - Service tokens responses: '200': description: OK diff --git a/x-pack/plugins/fleet/common/openapi/paths/settings.yaml b/x-pack/plugins/fleet/common/openapi/paths/settings.yaml index dc711bcefbfae..4e3d1b3af4bb7 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/settings.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/settings.yaml @@ -1,6 +1,7 @@ get: - summary: Settings - tags: [] + summary: Get settings + tags: + - Fleet internals responses: '200': description: OK @@ -12,8 +13,9 @@ get: $ref: ../components/responses/error.yaml operationId: get-settings put: - summary: Settings - Update - tags: [] + summary: Update settings + tags: + - Fleet internals requestBody: content: application/json: diff --git a/x-pack/plugins/fleet/common/openapi/paths/setup.yaml b/x-pack/plugins/fleet/common/openapi/paths/setup.yaml index 048e5cc51faf9..1f1a3cd035665 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/setup.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/setup.yaml @@ -1,6 +1,7 @@ post: - summary: Setup - tags: [] + summary: Initiate Fleet setup + tags: + - Fleet internals responses: '200': description: OK From a5b2db4604b45919a9b1e82e93b7b921c7d7ad56 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Wed, 1 Mar 2023 14:46:35 +0100 Subject: [PATCH 02/10] [Telemetry] Prepare for versioned HTTP APIs (#152111) ## Summary In this PR we ensure that we are adhering to the goals of versioned HTTP APIs to: 1. Not send SO attributes directly over the wire 2. Have a separate set of interfaces that can be referenced by public and maintained by server --- src/plugins/telemetry/common/routes.ts | 6 -- .../common/{types.ts => types/index.ts} | 5 +- src/plugins/telemetry/common/types/latest.ts | 9 +++ src/plugins/telemetry/common/types/v2.ts | 71 +++++++++++++++++++ src/plugins/telemetry/public/plugin.ts | 5 +- .../public/services/telemetry_sender.ts | 2 +- .../public/services/telemetry_service.ts | 5 +- .../server/routes/telemetry_config.ts | 5 +- .../server/routes/telemetry_last_reported.ts | 9 ++- .../server/routes/telemetry_opt_in.ts | 5 +- .../server/routes/telemetry_opt_in_stats.ts | 4 +- .../server/routes/telemetry_usage_stats.ts | 7 +- .../routes/telemetry_user_has_seen_notice.ts | 13 +++- 13 files changed, 124 insertions(+), 22 deletions(-) rename src/plugins/telemetry/common/{types.ts => types/index.ts} (66%) create mode 100644 src/plugins/telemetry/common/types/latest.ts create mode 100644 src/plugins/telemetry/common/types/v2.ts diff --git a/src/plugins/telemetry/common/routes.ts b/src/plugins/telemetry/common/routes.ts index 2161cb7dd5651..06d6f746bf2c1 100644 --- a/src/plugins/telemetry/common/routes.ts +++ b/src/plugins/telemetry/common/routes.ts @@ -10,9 +10,3 @@ * Fetch Telemetry Config */ export const FetchTelemetryConfigRoute = '/api/telemetry/v2/config'; -export interface FetchTelemetryConfigResponse { - allowChangingOptInStatus: boolean; - optIn: boolean | null; - sendUsageFrom: 'server' | 'browser'; - telemetryNotifyUserAboutOptInDefault: boolean; -} diff --git a/src/plugins/telemetry/common/types.ts b/src/plugins/telemetry/common/types/index.ts similarity index 66% rename from src/plugins/telemetry/common/types.ts rename to src/plugins/telemetry/common/types/index.ts index aefbbd2358861..14b2d3cbefcf4 100644 --- a/src/plugins/telemetry/common/types.ts +++ b/src/plugins/telemetry/common/types/index.ts @@ -6,5 +6,6 @@ * Side Public License, v 1. */ -export type EncryptedTelemetryPayload = Array<{ clusterUuid: string; stats: string }>; -export type UnencryptedTelemetryPayload = Array<{ clusterUuid: string; stats: object }>; +export * from './latest'; + +export * as v2 from './v2'; diff --git a/src/plugins/telemetry/common/types/latest.ts b/src/plugins/telemetry/common/types/latest.ts new file mode 100644 index 0000000000000..557f34eac9ee2 --- /dev/null +++ b/src/plugins/telemetry/common/types/latest.ts @@ -0,0 +1,9 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +export * from './v2'; diff --git a/src/plugins/telemetry/common/types/v2.ts b/src/plugins/telemetry/common/types/v2.ts new file mode 100644 index 0000000000000..dc90ad3d242a6 --- /dev/null +++ b/src/plugins/telemetry/common/types/v2.ts @@ -0,0 +1,71 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +export interface Telemetry { + /** Whether telemetry is enabled */ + enabled?: boolean | null; + lastVersionChecked?: string; + /** Whether to send usage from the server or browser. */ + sendUsageFrom?: 'browser' | 'server'; + lastReported?: number; + allowChangingOptInStatus?: boolean; + userHasSeenNotice?: boolean; + reportFailureCount?: number; + reportFailureVersion?: string; +} + +export interface FetchTelemetryConfigResponse { + allowChangingOptInStatus: boolean; + optIn: boolean | null; + sendUsageFrom: 'server' | 'browser'; + telemetryNotifyUserAboutOptInDefault: boolean; +} + +export interface FetchLastReportedResponse { + lastReported: undefined | number; +} + +export type UpdateLastReportedResponse = undefined; + +export interface OptInStatsBody { + enabled: boolean; + /** @default true */ + unencrypted?: boolean; +} + +export interface StatsPayload { + cluster_uuid: string; + opt_in_status: boolean; +} + +export type OptInStatsResponse = Array<{ + clusterUuid: string; + stats: StatsPayload; +}>; + +export interface OptInBody { + enabled: boolean; +} + +export type OptInResponse = Array<{ + clusterUuid: string; + stats: string; +}>; + +export interface UsageStatsBody { + /** @default false */ + unencrypted: boolean; + /** @default false */ + refreshCache: boolean; +} + +export type UseHasSeenNoticeResponse = Telemetry; + +export type EncryptedTelemetryPayload = Array<{ clusterUuid: string; stats: string }>; + +export type UnencryptedTelemetryPayload = Array<{ clusterUuid: string; stats: object }>; diff --git a/src/plugins/telemetry/public/plugin.ts b/src/plugins/telemetry/public/plugin.ts index d28868a6dd286..15b581c498366 100644 --- a/src/plugins/telemetry/public/plugin.ts +++ b/src/plugins/telemetry/public/plugin.ts @@ -21,7 +21,8 @@ import type { HomePublicPluginSetup } from '@kbn/home-plugin/public'; import { ElasticV3BrowserShipper } from '@kbn/analytics-shippers-elastic-v3-browser'; import { of } from 'rxjs'; -import { FetchTelemetryConfigResponse, FetchTelemetryConfigRoute } from '../common/routes'; +import { FetchTelemetryConfigRoute } from '../common/routes'; +import type { v2 } from '../common/types'; import { TelemetrySender, TelemetryService, TelemetryNotifications } from './services'; import { renderWelcomeTelemetryNotice } from './render_welcome_telemetry_notice'; @@ -322,7 +323,7 @@ export class TelemetryPlugin implements Plugin { const { allowChangingOptInStatus, optIn, sendUsageFrom, telemetryNotifyUserAboutOptInDefault } = - await http.get(FetchTelemetryConfigRoute); + await http.get(FetchTelemetryConfigRoute); return { ...this.config, diff --git a/src/plugins/telemetry/public/services/telemetry_sender.ts b/src/plugins/telemetry/public/services/telemetry_sender.ts index 6ffed583ec95c..3006a328fb620 100644 --- a/src/plugins/telemetry/public/services/telemetry_sender.ts +++ b/src/plugins/telemetry/public/services/telemetry_sender.ts @@ -12,7 +12,7 @@ import { exhaustMap } from 'rxjs/operators'; import { Storage } from '@kbn/kibana-utils-plugin/public'; import { LOCALSTORAGE_KEY, PAYLOAD_CONTENT_ENCODING } from '../../common/constants'; import { TelemetryService } from './telemetry_service'; -import type { EncryptedTelemetryPayload } from '../../common/types'; +import type { EncryptedTelemetryPayload } from '../../common/types/latest'; import { isReportIntervalExpired } from '../../common/is_report_interval_expired'; export class TelemetrySender { diff --git a/src/plugins/telemetry/public/services/telemetry_service.ts b/src/plugins/telemetry/public/services/telemetry_service.ts index 189df46b2328b..c1b96f4749067 100644 --- a/src/plugins/telemetry/public/services/telemetry_service.ts +++ b/src/plugins/telemetry/public/services/telemetry_service.ts @@ -10,7 +10,10 @@ import { i18n } from '@kbn/i18n'; import { CoreStart } from '@kbn/core/public'; import { TelemetryPluginConfig } from '../plugin'; import { getTelemetryChannelEndpoint } from '../../common/telemetry_config/get_telemetry_channel_endpoint'; -import type { UnencryptedTelemetryPayload, EncryptedTelemetryPayload } from '../../common/types'; +import type { + UnencryptedTelemetryPayload, + EncryptedTelemetryPayload, +} from '../../common/types/latest'; import { PAYLOAD_CONTENT_ENCODING } from '../../common/constants'; interface TelemetryServiceConstructor { diff --git a/src/plugins/telemetry/server/routes/telemetry_config.ts b/src/plugins/telemetry/server/routes/telemetry_config.ts index 4bcf1d1f4c811..60a34d80aad2e 100644 --- a/src/plugins/telemetry/server/routes/telemetry_config.ts +++ b/src/plugins/telemetry/server/routes/telemetry_config.ts @@ -9,7 +9,8 @@ import { type Observable, firstValueFrom } from 'rxjs'; import type { IRouter, SavedObjectsClient } from '@kbn/core/server'; import type { TelemetryConfigType } from '../config'; -import { FetchTelemetryConfigResponse, FetchTelemetryConfigRoute } from '../../common/routes'; +import { v2 } from '../../common/types'; +import { FetchTelemetryConfigRoute } from '../../common/routes'; import { getTelemetrySavedObject } from '../saved_objects'; import { getNotifyUserAboutOptInDefault, @@ -64,7 +65,7 @@ export function registerTelemetryConfigRoutes({ telemetryOptedIn: optIn, }); - const body: FetchTelemetryConfigResponse = { + const body: v2.FetchTelemetryConfigResponse = { allowChangingOptInStatus, optIn, sendUsageFrom, diff --git a/src/plugins/telemetry/server/routes/telemetry_last_reported.ts b/src/plugins/telemetry/server/routes/telemetry_last_reported.ts index 80037761895b2..2e21785b9296d 100644 --- a/src/plugins/telemetry/server/routes/telemetry_last_reported.ts +++ b/src/plugins/telemetry/server/routes/telemetry_last_reported.ts @@ -9,6 +9,7 @@ import type { IRouter, SavedObjectsClient } from '@kbn/core/server'; import type { Observable } from 'rxjs'; import { firstValueFrom } from 'rxjs'; +import { v2 } from '../../common/types'; import { getTelemetrySavedObject, updateTelemetrySavedObject } from '../saved_objects'; export function registerTelemetryLastReported( @@ -25,10 +26,12 @@ export function registerTelemetryLastReported( const savedObjectsInternalClient = await firstValueFrom(savedObjectsInternalClient$); const telemetrySavedObject = await getTelemetrySavedObject(savedObjectsInternalClient); + const body: v2.FetchLastReportedResponse = { + lastReported: telemetrySavedObject && telemetrySavedObject?.lastReported, + }; + return res.ok({ - body: { - lastReported: telemetrySavedObject && telemetrySavedObject?.lastReported, - }, + body, }); } ); diff --git a/src/plugins/telemetry/server/routes/telemetry_opt_in.ts b/src/plugins/telemetry/server/routes/telemetry_opt_in.ts index e26e8c596b53a..cc477c4f23198 100644 --- a/src/plugins/telemetry/server/routes/telemetry_opt_in.ts +++ b/src/plugins/telemetry/server/routes/telemetry_opt_in.ts @@ -14,6 +14,7 @@ import type { StatsGetterConfig, TelemetryCollectionManagerPluginSetup, } from '@kbn/telemetry-collection-manager-plugin/server'; +import { v2 } from '../../common/types'; import { sendTelemetryOptInStatus } from './telemetry_opt_in_stats'; import { getTelemetrySavedObject, @@ -109,7 +110,9 @@ export function registerTelemetryOptInRoutes({ return res.forbidden(); } } - return res.ok({ body: optInStatus }); + + const body: v2.OptInResponse = optInStatus; + return res.ok({ body }); } ); } diff --git a/src/plugins/telemetry/server/routes/telemetry_opt_in_stats.ts b/src/plugins/telemetry/server/routes/telemetry_opt_in_stats.ts index d8ec9d4922fc1..8c9c85172ced6 100644 --- a/src/plugins/telemetry/server/routes/telemetry_opt_in_stats.ts +++ b/src/plugins/telemetry/server/routes/telemetry_opt_in_stats.ts @@ -14,6 +14,7 @@ import type { TelemetryCollectionManagerPluginSetup, StatsGetterConfig, } from '@kbn/telemetry-collection-manager-plugin/server'; +import type { v2 } from '../../common/types'; import { EncryptedTelemetryPayload, UnencryptedTelemetryPayload } from '../../common/types'; import { getTelemetryChannelEndpoint } from '../../common/telemetry_config'; import { PAYLOAD_CONTENT_ENCODING } from '../../common/constants'; @@ -90,7 +91,8 @@ export function registerTelemetryOptInStatsRoutes( newOptInStatus, statsGetterConfig ); - return res.ok({ body: optInStatus }); + const body: v2.OptInStatsResponse = optInStatus; + return res.ok({ body }); } catch (err) { return res.ok({ body: [] }); } diff --git a/src/plugins/telemetry/server/routes/telemetry_usage_stats.ts b/src/plugins/telemetry/server/routes/telemetry_usage_stats.ts index fd613e1318966..53169367b965e 100644 --- a/src/plugins/telemetry/server/routes/telemetry_usage_stats.ts +++ b/src/plugins/telemetry/server/routes/telemetry_usage_stats.ts @@ -13,6 +13,7 @@ import type { StatsGetterConfig, } from '@kbn/telemetry-collection-manager-plugin/server'; import type { SecurityPluginStart } from '@kbn/security-plugin/server'; +import { v2 } from '../../common/types'; export type SecurityGetter = () => SecurityPluginStart | undefined; @@ -64,8 +65,10 @@ export function registerTelemetryUsageStatsRoutes( refreshCache: unencrypted || refreshCache, }; - const stats = await telemetryCollectionManager.getStats(statsConfig); - return res.ok({ body: stats }); + const body: v2.UnencryptedTelemetryPayload = await telemetryCollectionManager.getStats( + statsConfig + ); + return res.ok({ body }); } catch (err) { if (isDev) { // don't ignore errors when running in dev mode diff --git a/src/plugins/telemetry/server/routes/telemetry_user_has_seen_notice.ts b/src/plugins/telemetry/server/routes/telemetry_user_has_seen_notice.ts index 7686aa4100755..eeac24c0f5a07 100644 --- a/src/plugins/telemetry/server/routes/telemetry_user_has_seen_notice.ts +++ b/src/plugins/telemetry/server/routes/telemetry_user_has_seen_notice.ts @@ -8,6 +8,7 @@ import type { IRouter } from '@kbn/core/server'; import { TELEMETRY_SAVED_OBJECT_TYPE } from '../saved_objects'; +import { v2 } from '../../common/types'; import { type TelemetrySavedObjectAttributes, getTelemetrySavedObject, @@ -33,7 +34,17 @@ export function registerTelemetryUserHasSeenNotice(router: IRouter) { }; await updateTelemetrySavedObject(soClient, updatedAttributes); - return res.ok({ body: updatedAttributes }); + const body: v2.Telemetry = { + allowChangingOptInStatus: updatedAttributes.allowChangingOptInStatus, + enabled: updatedAttributes.enabled, + lastReported: updatedAttributes.lastReported, + lastVersionChecked: updatedAttributes.lastVersionChecked, + reportFailureCount: updatedAttributes.reportFailureCount, + reportFailureVersion: updatedAttributes.reportFailureVersion, + sendUsageFrom: updatedAttributes.sendUsageFrom, + userHasSeenNotice: updatedAttributes.userHasSeenNotice, + }; + return res.ok({ body }); } ); } From f6a0b886b143dea6b3b6f8101e21be5c1816558a Mon Sep 17 00:00:00 2001 From: Carlos Crespo Date: Wed, 1 Mar 2023 15:31:35 +0100 Subject: [PATCH 03/10] [Infrastructure UI] Filter out null bucket items from average calculation (#152333) ## Summary Closes [#152328](https://github.com/elastic/kibana/issues/152328) This PR fixes the average calculation in the Snapshot API, filtering out buckets with null values from it, which are more likely to appear with queries that use small data ranges. The results after this change are equal to what Elasticsearch would calculate in the avg aggregation ### How to test - Make sure you have metrics data (either through enabling the system module in metricbeat or connecting your local kibana to an oblt-cli cluster) - Navigate to `Infrastructure` > `Hosts` - Filter the results to see a single host - Change the data range filter and compare the KPIs against the table. - Validate other pages that use the Snapshot API (Inventory UI and Metrics UI to see if the results there are still correct --------- Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- x-pack/plugins/infra/common/http_api/snapshot_api.ts | 1 + .../pages/metrics/hosts/components/kpi_charts/tile.tsx | 1 + .../public/pages/metrics/inventory_view/hooks/use_snaphot.ts | 2 ++ .../routes/snapshot/lib/transform_metrics_ui_response.ts | 5 +++-- .../snapshot/lib/transform_request_to_metrics_api_request.ts | 2 +- x-pack/test/api_integration/apis/metrics_ui/snapshot.ts | 2 +- 6 files changed, 9 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/infra/common/http_api/snapshot_api.ts b/x-pack/plugins/infra/common/http_api/snapshot_api.ts index 3f8e4b5597f31..6b3a683ef7d26 100644 --- a/x-pack/plugins/infra/common/http_api/snapshot_api.ts +++ b/x-pack/plugins/infra/common/http_api/snapshot_api.ts @@ -115,6 +115,7 @@ export const SnapshotRequestRT = rt.intersection([ region: rt.string, filterQuery: rt.union([rt.string, rt.null]), overrideCompositeSize: rt.number, + dropPartialBuckets: rt.boolean, }), ]); diff --git a/x-pack/plugins/infra/public/pages/metrics/hosts/components/kpi_charts/tile.tsx b/x-pack/plugins/infra/public/pages/metrics/hosts/components/kpi_charts/tile.tsx index ed5d0f5831ca6..1b86c5a543d06 100644 --- a/x-pack/plugins/infra/public/pages/metrics/hosts/components/kpi_charts/tile.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/hosts/components/kpi_charts/tile.tsx @@ -22,6 +22,7 @@ export const Tile = ({ type, ...props }: Props) => { metrics: [{ type }], groupBy: null, includeTimeseries: true, + dropPartialBuckets: false, }); return ; diff --git a/x-pack/plugins/infra/public/pages/metrics/inventory_view/hooks/use_snaphot.ts b/x-pack/plugins/infra/public/pages/metrics/inventory_view/hooks/use_snaphot.ts index 8818fac0e39ee..ae39a5f03ea7e 100644 --- a/x-pack/plugins/infra/public/pages/metrics/inventory_view/hooks/use_snaphot.ts +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/hooks/use_snaphot.ts @@ -34,6 +34,7 @@ export function useSnapshot({ groupBy = null, sendRequestImmediately = true, includeTimeseries = true, + dropPartialBuckets = true, requestTs, ...args }: UseSnapshotRequest) { @@ -56,6 +57,7 @@ export function useSnapshot({ lookbackSize: 5, }, includeTimeseries, + dropPartialBuckets, }; const { error, loading, response, makeRequest } = useHTTPRequest( diff --git a/x-pack/plugins/infra/server/routes/snapshot/lib/transform_metrics_ui_response.ts b/x-pack/plugins/infra/server/routes/snapshot/lib/transform_metrics_ui_response.ts index 4b3682db3d1f6..f11a67ecb4a0c 100644 --- a/x-pack/plugins/infra/server/routes/snapshot/lib/transform_metrics_ui_response.ts +++ b/x-pack/plugins/infra/server/routes/snapshot/lib/transform_metrics_ui_response.ts @@ -23,7 +23,7 @@ import { applyMetadataToLastPath } from './apply_metadata_to_last_path'; const getMetricValue = (row: MetricsAPIRow) => { if (!isNumber(row.metric_0)) return null; const value = row.metric_0; - return isFinite(value) ? value : null; + return Number.isFinite(value) ? value : null; }; const calculateMax = (rows: MetricsAPIRow[]) => { @@ -31,7 +31,8 @@ const calculateMax = (rows: MetricsAPIRow[]) => { }; const calculateAvg = (rows: MetricsAPIRow[]): number => { - return sum(rows.map(getMetricValue)) / rows.length || 0; + const values = rows.map(getMetricValue).filter(Number.isFinite); + return sum(values) / Math.max(values.length, 1); }; const getLastValue = (rows: MetricsAPIRow[]) => { diff --git a/x-pack/plugins/infra/server/routes/snapshot/lib/transform_request_to_metrics_api_request.ts b/x-pack/plugins/infra/server/routes/snapshot/lib/transform_request_to_metrics_api_request.ts index ae342cfad7b28..890295561e3a7 100644 --- a/x-pack/plugins/infra/server/routes/snapshot/lib/transform_request_to_metrics_api_request.ts +++ b/x-pack/plugins/infra/server/routes/snapshot/lib/transform_request_to_metrics_api_request.ts @@ -45,7 +45,7 @@ export const transformRequestToMetricsAPIRequest = async ({ ? snapshotRequest.overrideCompositeSize : compositeSize, alignDataToEnd: true, - dropPartialBuckets: true, + dropPartialBuckets: snapshotRequest.dropPartialBuckets ?? true, includeTimeseries: snapshotRequest.includeTimeseries, }; diff --git a/x-pack/test/api_integration/apis/metrics_ui/snapshot.ts b/x-pack/test/api_integration/apis/metrics_ui/snapshot.ts index 9fa041108964e..8eef4dc32df1c 100644 --- a/x-pack/test/api_integration/apis/metrics_ui/snapshot.ts +++ b/x-pack/test/api_integration/apis/metrics_ui/snapshot.ts @@ -248,7 +248,7 @@ export default function ({ getService }: FtrProviderContext) { name: 'cpu', value: null, max: 0.47105555555555556, - avg: 0.0672936507936508, + avg: 0.47105555555555556, }; expect(snapshot).to.have.property('nodes'); From f23346e4a61fcbce8d0678edb76a7d3055852dde Mon Sep 17 00:00:00 2001 From: Justin Kambic Date: Wed, 1 Mar 2023 09:38:42 -0500 Subject: [PATCH 04/10] [Synthetics] Hide location and enabled toggle on `MonitorDetailsPanel` for test run details (#152373) Co-authored-by: Shahzad --- .../components/monitor_details_panel.tsx | 40 +++++++++++++------ .../error_details/error_details_page.tsx | 4 +- ...sx => monitor_details_panel_container.tsx} | 8 +++- .../monitor_summary/monitor_summary.tsx | 2 +- .../overview/monitor_detail_flyout.tsx | 1 + .../test_run_details/test_run_details.tsx | 4 +- 6 files changed, 40 insertions(+), 19 deletions(-) rename x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/{monitor_details_panel.tsx => monitor_details_panel_container.tsx} (85%) diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/common/components/monitor_details_panel.tsx b/x-pack/plugins/synthetics/public/apps/synthetics/components/common/components/monitor_details_panel.tsx index 2bfd04fa26d57..9aa9d90e29ee9 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/common/components/monitor_details_panel.tsx +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/common/components/monitor_details_panel.tsx @@ -40,19 +40,25 @@ const DescriptionLabel = euiStyled(EuiDescriptionListDescription)` width: 60%; `; +export interface MonitorDetailsPanelProps { + latestPing?: Ping; + loading: boolean; + configId: string; + monitor: EncryptedSyntheticsSavedMonitor | null; + hideEnabled?: boolean; + hideLocations?: boolean; + hasBorder?: boolean; +} + export const MonitorDetailsPanel = ({ monitor, latestPing, loading, configId, hideEnabled = false, -}: { - latestPing?: Ping; - loading: boolean; - configId: string; - monitor: EncryptedSyntheticsSavedMonitor | null; - hideEnabled?: boolean; -}) => { + hideLocations = false, + hasBorder = true, +}: MonitorDetailsPanelProps) => { const dispatch = useDispatch(); if (!monitor) { @@ -60,7 +66,12 @@ export const MonitorDetailsPanel = ({ } return ( - + @@ -116,10 +127,15 @@ export const MonitorDetailsPanel = ({ {FREQUENCY_LABEL} {frequencyStr(monitor[ConfigKey.SCHEDULE])} - {LOCATIONS_LABEL} - - - + + {!hideLocations && ( + <> + {LOCATIONS_LABEL} + + + + + )} {TAGS_LABEL} diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/error_details/error_details_page.tsx b/x-pack/plugins/synthetics/public/apps/synthetics/components/error_details/error_details_page.tsx index 3174d85776733..084dd68934626 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/error_details/error_details_page.tsx +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/error_details/error_details_page.tsx @@ -21,7 +21,7 @@ import { FailedTestsList } from './components/failed_tests_list'; import { ErrorTimeline } from './components/error_timeline'; import { useErrorDetailsBreadcrumbs } from './hooks/use_error_details_breadcrumbs'; import { StepImage } from '../step_details_page/step_screenshot/step_image'; -import { MonitorDetailsPanelContainer } from '../monitor_details/monitor_summary/monitor_details_panel'; +import { MonitorDetailsPanelContainer } from '../monitor_details/monitor_summary/monitor_details_panel_container'; export function ErrorDetailsPage() { const { failedTests, loading } = useErrorFailedTests(); @@ -80,7 +80,7 @@ export function ErrorDetailsPage() { - + diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/monitor_details_panel.tsx b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/monitor_details_panel_container.tsx similarity index 85% rename from x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/monitor_details_panel.tsx rename to x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/monitor_details_panel_container.tsx index c2a26f5242f0f..99885ac30fb87 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/monitor_details_panel.tsx +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/monitor_details_panel_container.tsx @@ -9,12 +9,15 @@ import React from 'react'; import { EuiLoadingContent } from '@elastic/eui'; import { useParams } from 'react-router-dom'; import { euiStyled } from '@kbn/kibana-react-plugin/common'; -import { MonitorDetailsPanel } from '../../common/components/monitor_details_panel'; +import { + MonitorDetailsPanelProps, + MonitorDetailsPanel, +} from '../../common/components/monitor_details_panel'; import { useSelectedMonitor } from '../hooks/use_selected_monitor'; import { ConfigKey } from '../../../../../../common/runtime_types'; import { useMonitorLatestPing } from '../hooks/use_monitor_latest_ping'; -export const MonitorDetailsPanelContainer = () => { +export const MonitorDetailsPanelContainer = (props: Partial) => { const { latestPing } = useMonitorLatestPing(); const { monitorId: configId } = useParams<{ monitorId: string }>(); @@ -34,6 +37,7 @@ export const MonitorDetailsPanelContainer = () => { monitor={monitor} loading={loading} configId={configId} + {...props} /> ); }; diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/monitor_summary.tsx b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/monitor_summary.tsx index b087da10f767c..ebaaee6e44e50 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/monitor_summary.tsx +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/monitor_summary.tsx @@ -21,7 +21,7 @@ import { MonitorDurationTrend } from './duration_trend'; import { StepDurationPanel } from './step_duration_panel'; import { AvailabilityPanel } from './availability_panel'; import { DurationPanel } from './duration_panel'; -import { MonitorDetailsPanelContainer } from './monitor_details_panel'; +import { MonitorDetailsPanelContainer } from './monitor_details_panel_container'; import { AvailabilitySparklines } from './availability_sparklines'; import { LastTestRun } from './last_test_run'; import { LAST_10_TEST_RUNS, TestRunsTable } from './test_runs_table'; diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitors_page/overview/overview/monitor_detail_flyout.tsx b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitors_page/overview/overview/monitor_detail_flyout.tsx index b34f4f6fe421a..187f590c9b360 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitors_page/overview/overview/monitor_detail_flyout.tsx +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitors_page/overview/overview/monitor_detail_flyout.tsx @@ -325,6 +325,7 @@ export function MonitorDetailFlyout(props: Props) { { - + )} From 0c2e2c9b6f96cd936e53f72d13f4934c5bcffa3b Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Wed, 1 Mar 2023 08:00:59 -0700 Subject: [PATCH 05/10] [maps] fix layers are not displayed in offline environment and map.includeElasticMapsService not set to false (#152396) Fixes https://github.com/elastic/kibana/issues/152389 PR adds check to ensure client has access to EMS before using EMS fonts. If the client does not have access to EMS fonts then a warning is logged and map falls back to open sans fonts served from Kibana server. --- .../connected_components/mb_map/mb_map.tsx | 3 +- x-pack/plugins/maps/public/util.test.js | 66 +++++++++++++------ x-pack/plugins/maps/public/util.ts | 42 +++++++++++- 3 files changed, 89 insertions(+), 22 deletions(-) diff --git a/x-pack/plugins/maps/public/connected_components/mb_map/mb_map.tsx b/x-pack/plugins/maps/public/connected_components/mb_map/mb_map.tsx index 639c8fe5a20db..ab98b69a79f0b 100644 --- a/x-pack/plugins/maps/public/connected_components/mb_map/mb_map.tsx +++ b/x-pack/plugins/maps/public/connected_components/mb_map/mb_map.tsx @@ -155,12 +155,13 @@ export class MbMap extends Component { async _createMbMapInstance(initialView: MapCenterAndZoom | null): Promise { this._reportUsage(); + const glyphsUrlTemplate = await getGlyphUrl(); return new Promise((resolve) => { const mbStyle = { version: 8 as 8, sources: {}, layers: [], - glyphs: getGlyphUrl(), + glyphs: glyphsUrlTemplate, }; const options: MapOptions = { diff --git a/x-pack/plugins/maps/public/util.test.js b/x-pack/plugins/maps/public/util.test.js index 7fc88578b378a..48498f87fe7c0 100644 --- a/x-pack/plugins/maps/public/util.test.js +++ b/x-pack/plugins/maps/public/util.test.js @@ -5,60 +5,88 @@ * 2.0. */ -import { getGlyphUrl, makePublicExecutionContext } from './util'; - -const MOCK_EMS_SETTINGS = { - isEMSEnabled: () => true, -}; +import { + getGlyphUrl, + makePublicExecutionContext, + testOnlyClearCanAccessEmsFontsPromise, +} from './util'; describe('getGlyphUrl', () => { describe('EMS enabled', () => { - beforeAll(() => { + beforeEach(() => { require('./kibana_services').getHttp = () => ({ basePath: { - prepend: (url) => url, // No need to actually prepend a dev basepath for test + prepend: (path) => `abc${path}`, }, }); + testOnlyClearCanAccessEmsFontsPromise(); }); - describe('EMS proxy disabled', () => { + describe('offline', () => { beforeAll(() => { require('./kibana_services').getEMSSettings = () => { return { getEMSFontLibraryUrl() { - return 'foobar'; + return 'https://tiles.maps.elastic.co/fonts/{fontstack}/{range}.pbf'; }, isEMSEnabled() { return true; }, }; }; + require('node-fetch').default = () => { + throw new Error('Simulated offline environment with no EMS access'); + }; }); - test('should return EMS fonts URL', async () => { - expect(getGlyphUrl()).toBe('foobar'); + test('should return kibana fonts template URL', async () => { + expect(await getGlyphUrl()).toBe('abc/api/maps/fonts/{fontstack}/{range}'); + }); + }); + + describe('online', () => { + beforeAll(() => { + require('./kibana_services').getEMSSettings = () => { + return { + getEMSFontLibraryUrl() { + return 'https://tiles.maps.elastic.co/fonts/{fontstack}/{range}.pbf'; + }, + isEMSEnabled() { + return true; + }, + }; + }; + require('node-fetch').default = () => { + return Promise.resolve({ status: 200 }); + }; + }); + + test('should return EMS fonts template URL', async () => { + expect(await getGlyphUrl()).toBe( + 'https://tiles.maps.elastic.co/fonts/{fontstack}/{range}.pbf' + ); }); }); }); describe('EMS disabled', () => { beforeAll(() => { - const mockHttp = { - basePath: { - prepend: (path) => `abc${path}`, - }, + require('./kibana_services').getHttp = () => { + return { + basePath: { + prepend: (path) => `abc${path}`, + }, + }; }; - require('./kibana_services').getHttp = () => mockHttp; require('./kibana_services').getEMSSettings = () => { return { - ...MOCK_EMS_SETTINGS, isEMSEnabled: () => false, }; }; }); - test('should return kibana fonts URL', async () => { - expect(getGlyphUrl()).toBe('abc/api/maps/fonts/{fontstack}/{range}'); + test('should return kibana fonts template URL', async () => { + expect(await getGlyphUrl()).toBe('abc/api/maps/fonts/{fontstack}/{range}'); }); }); }); diff --git a/x-pack/plugins/maps/public/util.ts b/x-pack/plugins/maps/public/util.ts index d63072b163599..3243c8a95cf74 100644 --- a/x-pack/plugins/maps/public/util.ts +++ b/x-pack/plugins/maps/public/util.ts @@ -5,6 +5,7 @@ * 2.0. */ +import fetch from 'node-fetch'; import { EMSClient, FileLayer, TMSService } from '@elastic/ems-client'; import type { KibanaExecutionContext } from '@kbn/core/public'; import { FONTS_API_PATH } from '../common/constants'; @@ -60,9 +61,46 @@ async function getEMSClient(): Promise { return emsClient; } -export function getGlyphUrl(): string { +let canAccessEmsFontsPromise: Promise | null = null; +async function canAccessEmsFonts(): Promise { + if (!canAccessEmsFontsPromise) { + canAccessEmsFontsPromise = new Promise(async (resolve) => { + try { + const emsSettings = getEMSSettings(); + if (!emsSettings!.isEMSEnabled()) { + resolve(false); + } + const emsFontUrlTemplate = emsSettings!.getEMSFontLibraryUrl(); + + const emsFontUrl = emsFontUrlTemplate + .replace('{fontstack}', 'Open Sans') + .replace('{range}', '0-255'); + const resp = await fetch(emsFontUrl, { + method: 'HEAD', + }); + if (resp.status >= 400) { + throw new Error(`status: ${resp.status}`); + } + resolve(true); + } catch (error) { + // eslint-disable-next-line no-console + console.warn( + `Unable to access fonts from Elastic Maps Service (EMS). Set kibana.yml 'map.includeElasticMapsService: false' to avoid unnecessary EMS requests.` + ); + resolve(false); + } + }); + } + return canAccessEmsFontsPromise; +} +// test only function to reset singleton for different test cases. +export function testOnlyClearCanAccessEmsFontsPromise() { + canAccessEmsFontsPromise = null; +} + +export async function getGlyphUrl(): Promise { const emsSettings = getEMSSettings(); - if (!emsSettings!.isEMSEnabled()) { + if (!emsSettings!.isEMSEnabled() || !(await canAccessEmsFonts())) { return getHttp().basePath.prepend(`/${FONTS_API_PATH}/{fontstack}/{range}`); } From 5612da95fe5052af1a51ee7ba537ae355124c1ad Mon Sep 17 00:00:00 2001 From: Xavier Mouligneau Date: Wed, 1 Mar 2023 10:29:17 -0500 Subject: [PATCH 06/10] [RAM] Fix flaky test on rule find api integration (#152455) ## Summary Fix https://github.com/elastic/kibana/issues/148660 ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --- .../security_and_spaces/group1/tests/alerting/find.ts | 4 ++-- .../group1/tests/alerting/find_with_post.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/group1/tests/alerting/find.ts b/x-pack/test/alerting_api_integration/security_and_spaces/group1/tests/alerting/find.ts index a75751d6df66f..be950eedb8c18 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/group1/tests/alerting/find.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/group1/tests/alerting/find.ts @@ -95,7 +95,7 @@ const findTestUtils = ( name: 'abc', tags: ['foo'], rule_type_id: 'test.noop', - running: false, + running: match.running ?? false, consumer: 'alertsFixture', schedule: { interval: '1m' }, enabled: true, @@ -311,7 +311,7 @@ const findTestUtils = ( name: 'abc', tags: ['foo'], rule_type_id: 'test.noop', - running: false, + running: match.running ?? false, consumer: 'alertsFixture', schedule: { interval: '1m' }, enabled: false, diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/group1/tests/alerting/find_with_post.ts b/x-pack/test/alerting_api_integration/security_and_spaces/group1/tests/alerting/find_with_post.ts index 4bb1c43a29b52..0708d098d81fe 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/group1/tests/alerting/find_with_post.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/group1/tests/alerting/find_with_post.ts @@ -74,7 +74,7 @@ const findTestUtils = ( name: 'abc', tags: ['foo'], rule_type_id: 'test.noop', - running: false, + running: match.running ?? false, consumer: 'alertsFixture', schedule: { interval: '1m' }, enabled: true, @@ -287,7 +287,7 @@ const findTestUtils = ( name: 'abc', tags: ['foo'], rule_type_id: 'test.noop', - running: false, + running: match.running ?? false, consumer: 'alertsFixture', schedule: { interval: '1m' }, enabled: false, From 570eb381c5d20ebd4d1f8b1391683fc5ae492409 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Wed, 1 Mar 2023 16:45:43 +0100 Subject: [PATCH 07/10] [Versioned APIs] Versioned interfaces dev docs guide (#150705) ## Summary Adds a dev docs guide for the core-approved versioning strategy. This strategy is subject to some iteration but is based on the work we did for the Saved Objects Management plugin in https://github.com/elastic/kibana/pull/149495. Closes https://github.com/elastic/kibana/issues/149929 ## How to test 1. Run `./scripts/dev_docs.sh` 2. Navigate to "Versioning interfaces" in the side nav menu --------- Co-authored-by: Luke Elmers --- dev_docs/tutorials/versioning_interfaces.mdx | 442 +++++++++++++++++++ nav-kibana-dev.docnav.json | 4 + 2 files changed, 446 insertions(+) create mode 100644 dev_docs/tutorials/versioning_interfaces.mdx diff --git a/dev_docs/tutorials/versioning_interfaces.mdx b/dev_docs/tutorials/versioning_interfaces.mdx new file mode 100644 index 0000000000000..d8ffdb333294a --- /dev/null +++ b/dev_docs/tutorials/versioning_interfaces.mdx @@ -0,0 +1,442 @@ +--- +id: kibDevTutorialVersioningInterfaces +slug: /kibana-dev-docs/versioning-interfaces +title: Versioning interfaces +description: We need to keep old versions of interfaces available. This tutorial describes a strategy for managing versions of your interfaces over time. +date: 2023-02-09 +tags: ['kibana', 'onboarding', 'dev', 'architecture'] +--- + +To support versioned APIs we need to keep past versions of interfaces around. This tutorial presents one strategy to manage your interfaces. + +## The strategy + +Every plugin has a _domain_. A domain consists of one or more concepts, usually objects, that are related in some logical way. + +At a high level the strategy for versioning our interfaces is: + +> Version a collection of related interfaces together. Whenever a single interface changes, increment the version of the entire collection of interfaces. + +Characteristics of this strategy: + +1. Avoid the `extends` keyword for referencing past interfaces. This results in cleaner API docs being generated. +2. Leverage `* as` to create versioned namespaces rather than versioned interfaces. +3. Verbosity is intentional: for a single change in a collection, we create a new version of the related collection. + +### An example: Weather insights unversioned +Consider a fictional Kibana plugin called "Weather insights". It allows users to easily create and curate dashboards that house visualisations and metrics for weather data. The domain contains the following: + +1. **Data source**: an endpoint that is scraped and ingested into ES for aggregation and search. +2. **Weather dashboard**: a set of visualisations and metrics that draws from a data source. + +We have the following `common` interfaces: + +```ts +export interface DataSource { + /** Some URL that provides weather data in an expected format for scraping */ + url: string; + /** The data view data is stored in */ + dataViewId: string; + /** Username to use with source URL */ + username?: string; + /** Password to use with source URL */ + password?: string; +} + +/** Fictional type, only used for this example as an external type */ +import type { PortableDashboard } from '@kbn/dashboard/common'; + +export interface WeatherDashboard { + /** A unique ID for this weather dashboard */ + id: string; + /** Definition of a dashboard imported from the `dashboard` plugin */ + dashboard: PortableDashboard; + /** Data source to use with this dashboard */ + source: DataSource; +} + +type UnsavedWeatherDashboard = Omit; + +/** Below are the HTTP APIs based on the domain types */ + +export interface GetWeatherDashboardHTTPResponse { + weatherDashboard: WeatherDashboard; +} + +export interface CreateWeatherDashboardHTTPBody { + weatherDashboard: UnsavedWeatherDashboard; +} + +export interface CreateWeatherDashboardHTTPResponse { + weatherDashboard: WeatherDashboard; +} + +// Imagine this pattern for the update and list endpoints too. +``` + +These interfaces might be in use by an unversioned HTTP route such as: + +```ts +import type { GetWeatherDashboardHTTPResponse } from '../common'; + +const handler = (ctx, req, res) => { + const body: GetWeatherDashboardHTTPResponse = { ... }; + return res.ok({ body }); +} +``` + +### An example: Weather insights versioned + +The following product requirements are added to the Weather insights plugin: + +1. Data sources need a more user-friendly `name`, currently we just show a URL +2. Some users have said they'd like to give data sources a short `description` too +3. New feature: **Predictions** that will generate forecasts based on past and current weather data + +Before we make these changes, we need to make sure that our current interfaces are not lost. + +#### Preparing our interfaces for versions + +We are going to make our current set of interfaces `v1`. Let's reflect this in our code by creating this file structure in `common`: + +``` +common + index.ts + latest.ts + data_source + v1.ts + weather_dashboard + v1.ts +public + ... +server + ... +``` + +By placing `DataSource` and `WeatherDashboard` in two folders we indicate that they _could_ version independently. Specifically, +`WeatherDashboard` may version independently of `DataSource`. + +**Note:** At this stage, splitting these concepts may be overkill if we expect `WeatherDashboard` to _rarely_ change, but for this example we would like the ability to version them separately. + +The `latest.ts` file is going to act as an alias to the latest set of interfaces. It will look like this: + +```ts +// "export *" is considered safe here because we ONLY have types in these files. +export * from './data_source/v1'; +export * from './weather_data/v1'; +``` + +Our `index.ts` file will contain: + +```ts +// Explicit export of everything from latest +export { DataSource, WeatherDashboard, GetWeatherDashboardHTTPResponse } from './latest'; + +export * as weatherDashboardV1 from './weather_dashboard/v1'; +export * as dataSourceV1 from './data_source/v1'; +``` + +How we use these types depends on whether the code is aware of versions or not. Generally, code that is aware of multiple versions will lead to greater complexity. We might have a logger function that expects the latest dashboards: + +```ts +// This type is being pulled from "latest", so whenever a new latest is linked, +// it will also point to the latest WeatherDashboard. +import type { WeatherDashboard } from '../common'; + +function logIt(dashboard: WeatherDashboard) { + logger.debug(dashboard); +} +``` + +Or we might have a route handler that expects a specific version our domain objects: + +```ts +// Now we bring it all together by using our versioned types in our handler from before: +import type { weatherDashboardV1 } from '../common'; + +const handler = (ctx, req, res) => { + const body: weatherDashboardV1.GetWeatherDashboardHTTPResponse = { ... }; + return res.ok({ body }); +} +``` + + + By referencing types linked from `latest.ts` we will not have to refactor all our app code to point to the latest version of `WeatherDashboard`. This happens by simply re-exporting the newest types from `latest.ts`. Otherwise, code that needs to know about a specific version or versions will have access to it by using the appropriate namespace. + + +### Introducing a new field to `DataSource` + +Now that we have prepared our interfaces to be versioned, let's introduce the `name` field to `DataSource`. + +Create a new `v2.ts` file under the `data_source` directory: + +``` +common + data_source + v1.ts + v2.ts +``` + +The `v2.ts` file will contain: + +```ts +export interface DataSource { + /** Some URL that provides weather data in an expected format for scraping */ + url: string; + /** A user-friendly name */ + name: string; + /** A longer description of this data source */ + description?: string; + /** The data view data is stored in */ + dataViewId: string; + /** Username to use with source URL */ + username?: string; + /** Password to use with source URL */ + password?: string; +} +``` + + + If we had only added the optional `description` field to `DataSource` this would be a backwards-compatible change that does not require a new version. We could have remained on `v1` of the `DataSource` interface. + + +We also need to update the `WeatherDashboard` interface to use our new `DataSource` interface: + +``` +common + weather_dashboard + v1.ts + v2.ts +``` + +```ts +// common/weather_dashboard/v2.ts + +// This is largely a copy of v1.ts, but using a new WeatherDashboard type in all +// the relevant places + +/** Fictional type, only used for this example as an external type */ +import type { PortableDashboard } from '@kbn/dashboard/common'; +import type { DataSource } from '../data_source/v2'; + +// Optionally, re-export the entire set of types. Interfaces and types declared after this will override v1 declarations. +export * from './v1'; + +export interface WeatherDashboard { + /** A unique ID for this weather dashboard */ + id: string; + /** Definition of a dashboard imported from the `dashboard` plugin */ + dashboard: PortableDashboard; + /** Data source to use with this dashboard */ + source: DataSource; +} + +type UnsavedWeatherDashboard = Omit; + +/** Below are the HTTP APIs based on the domain types */ + +export interface GetWeatherDashboardHTTPResponse { + weatherDashboard: WeatherDashboard; +} + +export interface CreateWeatherDashboardHTTPBody { + weatherDashboard: UnsavedWeatherDashboard; +} + +export interface CreateWeatherDashboardHTTPResponse { + weatherDashboard: WeatherDashboard; +} + +// Imagine this pattern for the update and list endpoints too. + +``` + + + It is possible to add `export * from './v1';` to the top of our `weather_dashboard/v2.ts` file to re-export unchanged types and avoid copying the whole file. + + However, copying and adapting the entire set of types is OK too. If we have correctly grouped our sub-domains we should be versioning all collections of types together. + + +Now we update the `latest.ts` and `index.ts` files accordingly: + +```ts +// latest.ts +export * from './data_source/v2'; +export * from './weather_dashboard/v2'; +``` + +```ts +// index.ts +// Explicit export of everything from latest +export { DataSource, WeatherDashboard, GetWeatherDashboardHTTPResponse } from './latest'; + +export * as weatherDashboardV1 from './weather_dashboard/v1'; +export * as dataSourceV1 from './data_source/v1'; + +export * as weatherDashboardV2 from './weather_dashboard/v2'; +export * as dataSourceV2 from './data_source/v2'; +``` + +### Introduce a new sub-domain: `Prediction` + +For our second product requirement we are going to introduce a new concept. Let's start by updating our folder structure: + +``` +common + index.ts + latest.ts + data_source + weather_dashboard + prediction + v1.ts +``` + +```ts +// common/prediction/v1.ts + +import type { DataSource } from '../data_source/v2'; + +/** Random set of weather models, just for illustration */ +type Model = 'GFS' | 'ECMWF' | 'GEM'; + +/** Limited set of options rather than "string" so we can more easily version */ +type TimeFrame = '1d' | '2d' | '3d' | '4d' | '5d' | '6d' | '1w' | '2w'; + +export interface PredictionInput { + /** How far back we should look in our data */ + start_date: string; // !! Introduction of inconsistent snake case naming convention, will need a new version to fix + /** How far out to predict. Note, longer time frames result in lower accuracy */ + timeFrame: TimeFrame; + /** Choice of weather model to use */ + model: Model; + /** Data source for this prediction */ + dataSource: DataSource; +} + +export interface PredictionOutput { ... } + +// Below are HTTP APIs for predictions + +export interface CreatePredictionHTTPBody { + input: PredictionInput; +} + +export interface CreatePredictionHTTPResponse { + result: PredictionOutput; +} + +// And so forth... +``` + + + Both `WeatherDashboard` and `Prediction` reference `DataSource`. Therefore, both will increment their version whenever `DataSource` changes. + + +## Challenge + +Normalize our domain objects by only holding a reference to `DataSource` in `WeatherDashboard` and `Prediction` domain objects. + +
+ Solution +
+ 1. We will add a way to uniquely identify a `DataSource` + 2. `DataSource` is currently specified in both `WeatherDashboard` and `Prediction`, therefore both will need to be updated as well. + + Let's start by updating our folder structure to introduce the new versions. + + ``` + common + data_source + v1.ts + v2.ts + v3.ts + weather_dashboard + v1.ts + v2.ts + v3.ts + prediction + v1.ts + v2.ts + ``` + + Now, let's add our new types : + + ```ts + // common/data_source/v3.ts + export interface DataSource { + /** A string that uniquely identifies a DataSource */ + id: string; + /** Some URL that provides weather data in an expected format for scraping */ + url: string; + /** A user-friendly name */ + name: string; + /** A longer description of this data source */ + description?: string; + /** The data view data is stored in */ + dataViewId: string; + /** Username to use with source URL */ + username?: string; + /** Password to use with source URL */ + password?: string; + } + // ...followed by all other HTTP related interfaces + + // common/weather_dashboard/v3.ts + export interface WeatherDashboard { + /** A unique ID for this weather dashboard */ + id: string; + /** Definition of a dashboard imported from the `dashboard` plugin */ + dashboard: PortableDashboard; + /** ID of the data source to use with this dashboard */ + dataSourceId: string; + } + // ...followed by all other HTTP related interfaces + + // common/prediction/v3.ts + export interface PredictionInput { + /** How far back we should look in our data */ + startDate: string; // Fixed inconsistent naming + /** How far out to predict. Note, longer time frames result in lower accuracy */ + timeFrame: TimeFrame; + /** Choice of weather model to use */ + model: Model; + /** Data source for this prediction */ + dataSourceId: string; + } + // ...followed by all other HTTP related interfaces + ``` + + Next let's update `latest.ts` and `index.ts`: + + ```ts + // latest.ts + export * from './data_source/v3'; + export * from './weather_dashboard/v3'; + export * from './prediction/v3'; + + // index.ts + export { DataSource, WeatherDashboard, GetWeatherDashboardHTTPResponse, Prediction } from './latest'; + export * as weatherDashboardV1 from './weather_dashboard/v1'; + export * as dataSourceV1 from './data_source/v1'; + export * as predictionV1 from './prediction/v1'; + + export * as weatherDashboardV2 from './weather_dashboard/v2'; + export * as dataSourceV2 from './data_source/v2'; + export * as predictionV2 from './prediction/v2'; + + export * as weatherDashboardV3 from './weather_dashboard/v3'; + export * as dataSourceV3 from './data_source/v3'; + ``` + + Refactoring interfaces in this way creates a much larger maintenance burden because: + + 1. application code must now translate between the denormalized and normalized versions of these interfaces + 2. code must remember to support both old and new naming conventions + + ...for as long as these APIs are in use. We will not cover deprecation strategies in this tutorial (incoming). Sufficed to + say: _take care when designing public APIs_. +
+ +## Additional resources + +* [PR to prepare Saved Objects Management](https://github.com/elastic/kibana/pull/149495) for versioning \ No newline at end of file diff --git a/nav-kibana-dev.docnav.json b/nav-kibana-dev.docnav.json index 490718262a816..cfee44522daad 100644 --- a/nav-kibana-dev.docnav.json +++ b/nav-kibana-dev.docnav.json @@ -128,6 +128,10 @@ { "id": "kibDevTutorialSavedObject" }, + { + "id": "kibDevTutorialVersioningInterfaces", + "label": "Versioning interfaces" + }, { "id": "kibDevTutorialSubmitPullRequest" }, From d051183adee6328ef86a8124b835ae69bfbae802 Mon Sep 17 00:00:00 2001 From: Shahzad Date: Wed, 1 Mar 2023 16:46:25 +0100 Subject: [PATCH 08/10] [Synthetics] Error timeline date range (#151965) --- .../common/runtime_types/ping/error_state.ts | 16 +++- .../synthetics/test_run_details.journey.ts | 2 +- .../browser_steps_list.tsx | 51 ++++++++----- .../components/error_duration.tsx | 39 ++++++++-- .../components/error_timeline.tsx | 28 ++++++- .../error_details/components/resolved_at.tsx | 8 +- .../error_details/error_details_page.tsx | 20 +++-- .../hooks/use_error_details_breadcrumbs.ts | 7 +- .../hooks/use_error_failed_tests.tsx | 3 +- .../hooks/use_find_my_killer_state.ts | 76 +++++++++++++++++++ .../components/error_details/route_config.tsx | 2 +- .../hooks/use_monitor_errors.tsx | 9 ++- .../monitor_errors/errors_list.tsx | 74 +++++++++++------- .../monitor_errors/failed_tests.tsx | 33 +++++--- .../monitor_errors/monitor_errors.tsx | 6 +- .../test_time_formats.test.ts | 20 ++--- .../monitor_test_result/test_time_formats.ts | 30 +++++++- 17 files changed, 320 insertions(+), 104 deletions(-) create mode 100644 x-pack/plugins/synthetics/public/apps/synthetics/components/error_details/hooks/use_find_my_killer_state.ts diff --git a/x-pack/plugins/synthetics/common/runtime_types/ping/error_state.ts b/x-pack/plugins/synthetics/common/runtime_types/ping/error_state.ts index 86b0b07052eac..cf09da6eb92fc 100644 --- a/x-pack/plugins/synthetics/common/runtime_types/ping/error_state.ts +++ b/x-pack/plugins/synthetics/common/runtime_types/ping/error_state.ts @@ -6,14 +6,26 @@ */ import * as t from 'io-ts'; +export const StateEndsCodec = t.type({ + duration_ms: t.union([t.string, t.number]), + checks: t.number, + ends: t.union([t.string, t.null]), + started_at: t.string, + id: t.string, + up: t.number, + down: t.number, + status: t.string, +}); export const ErrorStateCodec = t.type({ - duration_ms: t.string, + duration_ms: t.union([t.string, t.number]), checks: t.number, - ends: t.union([t.string, t.null]), + ends: t.union([StateEndsCodec, t.null]), started_at: t.string, id: t.string, up: t.number, down: t.number, status: t.string, }); + +export type ErrorState = t.TypeOf; diff --git a/x-pack/plugins/synthetics/e2e/journeys/synthetics/test_run_details.journey.ts b/x-pack/plugins/synthetics/e2e/journeys/synthetics/test_run_details.journey.ts index ea8f70742f578..e9f931e64bf04 100644 --- a/x-pack/plugins/synthetics/e2e/journeys/synthetics/test_run_details.journey.ts +++ b/x-pack/plugins/synthetics/e2e/journeys/synthetics/test_run_details.journey.ts @@ -65,6 +65,6 @@ journey(`TestRunDetailsPage`, async ({ page, params }) => { await page.waitForSelector('text=Test run details'); await page.waitForSelector('text=Go to https://www.google.com'); - await page.waitForSelector('text=After 2.1 s'); + await page.waitForSelector('text=After 2.12 s'); }); }); diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/common/monitor_test_result/browser_steps_list.tsx b/x-pack/plugins/synthetics/public/apps/synthetics/components/common/monitor_test_result/browser_steps_list.tsx index c90a00710f32f..a9341eae5fa69 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/common/monitor_test_result/browser_steps_list.tsx +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/common/monitor_test_result/browser_steps_list.tsx @@ -6,7 +6,7 @@ */ import { i18n } from '@kbn/i18n'; -import React, { CSSProperties, ReactElement, useState } from 'react'; +import React, { CSSProperties, ReactElement, useCallback, useEffect, useState } from 'react'; import { EuiBasicTable, EuiBasicTableColumn, @@ -62,25 +62,38 @@ export const BrowserStepsList = ({ Record >({}); - const toggleDetails = (item: JourneyStep) => { - const itemIdToExpandedRowMapValues = { ...itemIdToExpandedRowMap }; - if (itemIdToExpandedRowMapValues[item._id]) { - delete itemIdToExpandedRowMapValues[item._id]; - } else { - if (testNowMode) { - itemIdToExpandedRowMapValues[item._id] = ( - - - - - - ); - } else { - itemIdToExpandedRowMapValues[item._id] = <>; - } + const toggleDetails = useCallback( + (item: JourneyStep) => { + setItemIdToExpandedRowMap((prevState) => { + const itemIdToExpandedRowMapValues = { ...prevState }; + if (itemIdToExpandedRowMapValues[item._id]) { + delete itemIdToExpandedRowMapValues[item._id]; + } else { + if (testNowMode) { + itemIdToExpandedRowMapValues[item._id] = ( + + + + + + ); + } else { + itemIdToExpandedRowMapValues[item._id] = <>; + } + } + return itemIdToExpandedRowMapValues; + }); + }, + [steps, testNowMode] + ); + + const failedStep = stepEnds?.find((step) => step.synthetics.step?.status === 'failed'); + + useEffect(() => { + if (failedStep && showExpand) { + toggleDetails(failedStep); } - setItemIdToExpandedRowMap(itemIdToExpandedRowMapValues); - }; + }, [failedStep, showExpand, toggleDetails]); const columns: Array> = [ ...(showExpand diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/error_details/components/error_duration.tsx b/x-pack/plugins/synthetics/public/apps/synthetics/components/error_details/components/error_duration.tsx index 9b65149be3ad0..bac7b09ecbf84 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/error_details/components/error_duration.tsx +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/error_details/components/error_duration.tsx @@ -8,7 +8,8 @@ import React from 'react'; import { EuiDescriptionList } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import moment from 'moment'; +import moment, { Moment } from 'moment'; +import { useFindMyKillerState } from '../hooks/use_find_my_killer_state'; import { useErrorFailedTests } from '../hooks/use_last_error_state'; export const ErrorDuration: React.FC = () => { @@ -16,13 +17,41 @@ export const ErrorDuration: React.FC = () => { const state = failedTests?.[0]?.state; - const duration = state ? moment().diff(moment(state?.started_at), 'minutes') : 0; + const { killerState } = useFindMyKillerState(); - return ( - - ); + const endsAt = killerState?.timestamp ? moment(killerState?.timestamp) : moment(); + const startedAt = moment(state?.started_at); + + const duration = state ? getErrorDuration(startedAt, endsAt) : 0; + + return ; }; const ERROR_DURATION = i18n.translate('xpack.synthetics.errorDetails.errorDuration', { defaultMessage: 'Error duration', }); + +const getErrorDuration = (startedAt: Moment, endsAt: Moment) => { + // const endsAt = state.ends ? moment(state.ends) : moment(); + // const startedAt = moment(state?.started_at); + + const diffInDays = endsAt.diff(startedAt, 'days'); + if (diffInDays > 1) { + return i18n.translate('xpack.synthetics.errorDetails.errorDuration.days', { + defaultMessage: '{value} days', + values: { value: diffInDays }, + }); + } + const diffInHours = endsAt.diff(startedAt, 'hours'); + if (diffInHours > 1) { + return i18n.translate('xpack.synthetics.errorDetails.errorDuration.hours', { + defaultMessage: '{value} hours', + values: { value: diffInHours }, + }); + } + const diffInMinutes = endsAt.diff(startedAt, 'minutes'); + return i18n.translate('xpack.synthetics.errorDetails.errorDuration.mins', { + defaultMessage: '{value} mins', + values: { value: diffInMinutes }, + }); +}; diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/error_details/components/error_timeline.tsx b/x-pack/plugins/synthetics/public/apps/synthetics/components/error_details/components/error_timeline.tsx index 30461842e963f..d2e0b12793bc6 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/error_details/components/error_timeline.tsx +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/error_details/components/error_timeline.tsx @@ -5,8 +5,32 @@ * 2.0. */ import React from 'react'; +import { EuiLoadingContent } from '@elastic/eui'; +import moment from 'moment'; +import { Ping } from '../../../../../../common/runtime_types'; import { MonitorFailedTests } from '../../monitor_details/monitor_errors/failed_tests'; -export const ErrorTimeline = () => { - return ; +export const ErrorTimeline = ({ lastTestRun }: { lastTestRun?: Ping }) => { + if (!lastTestRun) { + return ; + } + const diff = moment(lastTestRun.monitor.timespan?.lt).diff( + moment(lastTestRun.monitor.timespan?.gte), + 'minutes' + ); + const startedAt = lastTestRun?.state?.started_at; + + return ( + + ); }; diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/error_details/components/resolved_at.tsx b/x-pack/plugins/synthetics/public/apps/synthetics/components/error_details/components/resolved_at.tsx index 75b1f9a31690b..76e8ca2ebaea1 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/error_details/components/resolved_at.tsx +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/error_details/components/resolved_at.tsx @@ -8,15 +8,13 @@ import React, { ReactElement } from 'react'; import { EuiDescriptionList } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { useErrorFailedTests } from '../hooks/use_last_error_state'; import { useFormatTestRunAt } from '../../../utils/monitor_test_result/test_time_formats'; +import { useFindMyKillerState } from '../hooks/use_find_my_killer_state'; export const ResolvedAt: React.FC = () => { - const { failedTests } = useErrorFailedTests(); + const { killerState } = useFindMyKillerState(); - const state = failedTests?.[0]?.state; - - let endsAt: string | ReactElement = useFormatTestRunAt(state?.ends ?? ''); + let endsAt: string | ReactElement = useFormatTestRunAt(killerState?.timestamp); if (!endsAt) { endsAt = 'N/A'; diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/error_details/error_details_page.tsx b/x-pack/plugins/synthetics/public/apps/synthetics/components/error_details/error_details_page.tsx index 084dd68934626..4a6ea2d3f34e1 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/error_details/error_details_page.tsx +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/error_details/error_details_page.tsx @@ -43,7 +43,7 @@ export function ErrorDetailsPage() { return (
- + @@ -71,13 +71,19 @@ export function ErrorDetailsPage() { - - {data?.details?.journey && failedStep && ( - - )} - + {data?.details?.journey && failedStep && ( + <> + + + + + + )} - diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/error_details/hooks/use_error_details_breadcrumbs.ts b/x-pack/plugins/synthetics/public/apps/synthetics/components/error_details/hooks/use_error_details_breadcrumbs.ts index 61cef2b818615..c96df76b40456 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/error_details/hooks/use_error_details_breadcrumbs.ts +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/error_details/hooks/use_error_details_breadcrumbs.ts @@ -6,6 +6,7 @@ */ import { i18n } from '@kbn/i18n'; import { useKibana } from '@kbn/kibana-react-plugin/public'; +import { useSelectedLocation } from '../../monitor_details/hooks/use_selected_location'; import { useTestRunDetailsBreadcrumbs } from '../../test_run_details/hooks/use_test_run_details_breadcrumbs'; import { useSelectedMonitor } from '../../monitor_details/hooks/use_selected_monitor'; import { ConfigKey } from '../../../../../../common/runtime_types'; @@ -19,10 +20,14 @@ export const useErrorDetailsBreadcrumbs = ( const { monitor } = useSelectedMonitor(); + const selectedLocation = useSelectedLocation(); + const errorsBreadcrumbs = [ { text: ERRORS_CRUMB, - href: `${appPath}/monitor/${monitor?.[ConfigKey.CONFIG_ID]}/errors`, + href: `${appPath}/monitor/${monitor?.[ConfigKey.CONFIG_ID]}/errors?locationId=${ + selectedLocation?.id + }`, }, ...(extraCrumbs ?? []), ]; diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/error_details/hooks/use_error_failed_tests.tsx b/x-pack/plugins/synthetics/public/apps/synthetics/components/error_details/hooks/use_error_failed_tests.tsx index 241c410038276..8b061d7c587f7 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/error_details/hooks/use_error_failed_tests.tsx +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/error_details/hooks/use_error_failed_tests.tsx @@ -57,7 +57,8 @@ export function useErrorFailedTests() { return useMemo(() => { const failedTests = data?.hits.hits?.map((doc) => { - return doc._source as Ping; + const source = doc._source as any; + return { ...source, timestamp: source['@timestamp'] } as Ping; }) ?? []; return { diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/error_details/hooks/use_find_my_killer_state.ts b/x-pack/plugins/synthetics/public/apps/synthetics/components/error_details/hooks/use_find_my_killer_state.ts new file mode 100644 index 0000000000000..33f923c94d2ba --- /dev/null +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/error_details/hooks/use_find_my_killer_state.ts @@ -0,0 +1,76 @@ +/* + * 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 { useParams } from 'react-router-dom'; +import { useMemo } from 'react'; +import { useReduxEsSearch } from '../../../hooks/use_redux_es_search'; +import { Ping } from '../../../../../../common/runtime_types'; +import { + EXCLUDE_RUN_ONCE_FILTER, + SUMMARY_FILTER, +} from '../../../../../../common/constants/client_defaults'; +import { SYNTHETICS_INDEX_PATTERN } from '../../../../../../common/constants'; +import { useSyntheticsRefreshContext } from '../../../contexts'; +import { useGetUrlParams } from '../../../hooks'; + +export function useFindMyKillerState() { + const { lastRefresh } = useSyntheticsRefreshContext(); + + const { errorStateId, monitorId } = useParams<{ errorStateId: string; monitorId: string }>(); + + const { dateRangeStart, dateRangeEnd } = useGetUrlParams(); + + const { data, loading } = useReduxEsSearch( + { + index: SYNTHETICS_INDEX_PATTERN, + + body: { + // TODO: remove this once we have a better way to handle this mapping + runtime_mappings: { + 'state.ends.id': { + type: 'keyword', + }, + }, + size: 1, + query: { + bool: { + filter: [ + SUMMARY_FILTER, + EXCLUDE_RUN_ONCE_FILTER, + { + term: { + 'state.ends.id': errorStateId, + }, + }, + { + term: { + config_id: monitorId, + }, + }, + ], + }, + }, + sort: [{ '@timestamp': 'desc' }], + }, + }, + [lastRefresh, monitorId, dateRangeStart, dateRangeEnd], + { name: 'getStateWhichEndTheState' } + ); + + return useMemo(() => { + const killerStates = + data?.hits.hits?.map((doc) => { + const source = doc._source as any; + return { ...source, timestamp: source['@timestamp'] } as Ping; + }) ?? []; + + return { + loading, + killerState: killerStates?.[0], + }; + }, [data, loading]); +} diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/error_details/route_config.tsx b/x-pack/plugins/synthetics/public/apps/synthetics/components/error_details/route_config.tsx index c53de93fa5123..3e2d0f39000fe 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/error_details/route_config.tsx +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/error_details/route_config.tsx @@ -39,7 +39,7 @@ export const getErrorDetailsRouteConfig = ( ), rightSideItems: [ , - , + , , , ], diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/hooks/use_monitor_errors.tsx b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/hooks/use_monitor_errors.tsx index 6f6052af64a3f..e45e64dab1c15 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/hooks/use_monitor_errors.tsx +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/hooks/use_monitor_errors.tsx @@ -87,12 +87,15 @@ export function useMonitorErrors(monitorIdArg?: string) { }, }, }, - [lastRefresh, monitorId, monitorIdArg, dateRangeStart, dateRangeEnd], - { name: 'getMonitorErrors', isRequestReady: Boolean(selectedLocation?.label) } + [lastRefresh, monitorId, monitorIdArg, dateRangeStart, dateRangeEnd, selectedLocation?.label], + { + name: `getMonitorErrors/${dateRangeStart}/${dateRangeEnd}`, + isRequestReady: Boolean(selectedLocation?.label), + } ); return useMemo(() => { - const errorStates = (data?.aggregations?.errorStates.buckets ?? []).map((loc) => { + const errorStates = data?.aggregations?.errorStates.buckets?.map((loc) => { return loc.summary.hits.hits?.[0]._source as PingState; }); diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_errors/errors_list.tsx b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_errors/errors_list.tsx index ecd1f6141c7f4..d8fb9cc827fcd 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_errors/errors_list.tsx +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_errors/errors_list.tsx @@ -50,6 +50,10 @@ export const ErrorsList = ({ const selectedLocation = useSelectedLocation(); + const lastTestRun = errorStates?.sort((a, b) => { + return moment(b.state.started_at).valueOf() - moment(a.state.started_at).valueOf(); + })?.[0]; + const columns = [ { field: 'item.state.started_at', @@ -67,49 +71,56 @@ export const ErrorsList = ({ /> ); const isActive = isActiveState(item); - if (!isActive) { + if (!isActive || lastTestRun.state.id !== item.state.id) { return link; } return ( - {link} + + {link} + - Active + {ACTIVE_LABEL} ); }, }, + ...(isBrowserType + ? [ + { + field: 'monitor.check_group', + name: FAILED_STEP_LABEL, + truncateText: true, + sortable: (a: PingState) => { + const failedStep = failedSteps.find( + (step) => step.monitor.check_group === a.monitor.check_group + ); + if (!failedStep) { + return a.monitor.check_group; + } + return failedStep.synthetics?.step?.name; + }, + render: (value: string, item: PingState) => { + const failedStep = failedSteps.find((step) => step.monitor.check_group === value); + if (!failedStep) { + return <>--; + } + return ( + + {failedStep.synthetics?.step?.index}. {failedStep.synthetics?.step?.name} + + ); + }, + }, + ] + : []), { - field: 'monitor.check_group', - name: !isBrowserType ? ERROR_MESSAGE_LABEL : FAILED_STEP_LABEL, - truncateText: true, - sortable: (a: PingState) => { - const failedStep = failedSteps.find( - (step) => step.monitor.check_group === a.monitor.check_group - ); - if (!failedStep) { - return a.monitor.check_group; - } - return failedStep.synthetics?.step?.name; - }, - render: (value: string, item: PingState) => { - if (!isBrowserType) { - return {item.error.message ?? '--'}; - } - const failedStep = failedSteps.find((step) => step.monitor.check_group === value); - if (!failedStep) { - return <>--; - } - return ( - - {failedStep.synthetics?.step?.index}. {failedStep.synthetics?.step?.name} - - ); - }, + field: 'error.message', + name: ERROR_MESSAGE_LABEL, }, { field: 'state.duration_ms', @@ -157,6 +168,7 @@ export const ErrorsList = ({
{ +export const MonitorFailedTests = ({ + time, + allowBrushing = true, +}: { + time: { to: string; from: string }; + allowBrushing?: boolean; +}) => { const { observability } = useKibana().services; const { ExploratoryViewEmbeddable } = observability; @@ -41,7 +47,8 @@ export const MonitorFailedTests = ({ time }: { time: { to: string; from: string { time, reportDefinitions: { - ...(monitorId ? { 'monitor.id': [monitorId] } : { 'state.id': [errorStateId] }), + ...(monitorId ? { 'monitor.id': [monitorId] } : {}), + ...(errorStateId ? { 'state.id': [errorStateId] } : {}), }, dataType: 'synthetics', selectedMetricField: 'failed_tests', @@ -49,21 +56,25 @@ export const MonitorFailedTests = ({ time }: { time: { to: string; from: string }, ]} onBrushEnd={({ range }) => { - updateUrl({ - dateRangeStart: moment(range[0]).toISOString(), - dateRangeEnd: moment(range[1]).toISOString(), - }); + if (allowBrushing) { + updateUrl({ + dateRangeStart: moment(range[0]).toISOString(), + dateRangeEnd: moment(range[1]).toISOString(), + }); + } }} /> {FAILED_TESTS_LABEL} - - - {BRUSH_LABEL} - - + {allowBrushing && ( + + + {BRUSH_LABEL} + + + )} ); diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_errors/monitor_errors.tsx b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_errors/monitor_errors.tsx index 4d2794e9da995..04930af018152 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_errors/monitor_errors.tsx +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_errors/monitor_errors.tsx @@ -23,9 +23,9 @@ import { ErrorsTabContent } from './errors_tab_content'; export const MonitorErrors = () => { const { errorStates, loading, data } = useMonitorErrors(); - const initialLoading = loading && !data; + const initialLoading = !data; - const emptyState = !loading && errorStates.length === 0; + const emptyState = !loading && errorStates && errorStates?.length === 0; const redirect = useMonitorDetailsPage(); if (redirect) { @@ -39,7 +39,7 @@ export const MonitorErrors = () => { {initialLoading && } {emptyState && }
- +
); diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/utils/monitor_test_result/test_time_formats.test.ts b/x-pack/plugins/synthetics/public/apps/synthetics/utils/monitor_test_result/test_time_formats.test.ts index 5337468f6e730..b1e808d748d76 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/utils/monitor_test_result/test_time_formats.test.ts +++ b/x-pack/plugins/synthetics/public/apps/synthetics/utils/monitor_test_result/test_time_formats.test.ts @@ -9,16 +9,16 @@ import { formatTestDuration } from './test_time_formats'; describe('formatTestDuration', () => { it.each` - duration | expected | isMilli - ${undefined} | ${'0 ms'} | ${undefined} - ${120_000_000} | ${'2 min'} | ${undefined} - ${6_200_000} | ${'6.2 s'} | ${false} - ${500_000} | ${'500 ms'} | ${undefined} - ${100} | ${'0 ms'} | ${undefined} - ${undefined} | ${'0 ms'} | ${true} - ${600_000} | ${'10 min'} | ${true} - ${6_200} | ${'6.2 s'} | ${true} - ${500} | ${'500 ms'} | ${true} + duration | expected | isMilli + ${undefined} | ${'0 ms'} | ${undefined} + ${120_000_000} | ${'2 mins'} | ${undefined} + ${6_200_000} | ${'6.2 sec'} | ${false} + ${500_000} | ${'500 ms'} | ${undefined} + ${100} | ${'0 ms'} | ${undefined} + ${undefined} | ${'0 ms'} | ${true} + ${600_000} | ${'10 mins'} | ${true} + ${6_200} | ${'6.2 sec'} | ${true} + ${500} | ${'500 ms'} | ${true} `( 'returns $expected when `duration` is $duration and `isMilli` $isMilli', ({ diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/utils/monitor_test_result/test_time_formats.ts b/x-pack/plugins/synthetics/public/apps/synthetics/utils/monitor_test_result/test_time_formats.ts index 5d605ad4c2192..efae8b1652738 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/utils/monitor_test_result/test_time_formats.ts +++ b/x-pack/plugins/synthetics/public/apps/synthetics/utils/monitor_test_result/test_time_formats.ts @@ -6,6 +6,7 @@ */ import moment from 'moment'; +import { i18n } from '@kbn/i18n'; import { useKibanaDateFormat } from '../../../../hooks/use_kibana_date_format'; /** @@ -16,19 +17,40 @@ import { useKibanaDateFormat } from '../../../../hooks/use_kibana_date_format'; export const formatTestDuration = (duration = 0, isMilli = false) => { const secs = isMilli ? duration / 1e3 : duration / 1e6; + const hours = Math.floor(secs / 3600); + + if (hours >= 1) { + return i18n.translate('xpack.synthetics.errorDetails.errorDuration.hours', { + defaultMessage: '{value} hours', + values: { value: hours }, + }); + } + if (secs >= 60) { - return `${parseFloat((secs / 60).toFixed(1))} min`; + return i18n.translate('xpack.synthetics.errorDetails.errorDuration.minutes', { + defaultMessage: '{value} mins', + values: { value: parseFloat((secs / 60).toFixed(1)) }, + }); } if (secs >= 1) { - return `${parseFloat(secs.toFixed(1))} s`; + return i18n.translate('xpack.synthetics.errorDetails.errorDuration.seconds', { + defaultMessage: '{value} sec', + values: { value: parseFloat(secs.toFixed(1)) }, + }); } if (isMilli) { - return `${duration.toFixed(0)} ms`; + return i18n.translate('xpack.synthetics.errorDetails.errorDuration.milliseconds', { + defaultMessage: '{value} ms', + values: { value: duration.toFixed(0) }, + }); } - return `${(duration / 1000).toFixed(0)} ms`; + return i18n.translate('xpack.synthetics.errorDetails.errorDuration.microseconds', { + defaultMessage: '{value} ms', + values: { value: (duration / 1000).toFixed(0) }, + }); }; export function formatTestRunAt(timestamp: string, format: string) { From 5e397c4b609ae9dfc874103621d28f591124b90d Mon Sep 17 00:00:00 2001 From: Jason Rhodes Date: Wed, 1 Mar 2023 10:54:41 -0500 Subject: [PATCH 09/10] Makes spaces optional in observability plugin (#151147) ## Summary This PR makes spaces optional in the "observability" plugin as requested in https://github.com/elastic/kibana/issues/149687 To test this, use the following setting in your kibana.yml config file: ```yaml xpack.spaces.enabled: false ``` When you log in, there will be no spaces choice. Screenshot 2023-02-21 at 11 53 18 AM --- x-pack/plugins/observability/kibana.jsonc | 3 +-- .../public/hooks/use_kibana_space.tsx | 2 +- .../overview_page/helpers/use_metrics.ts | 17 +++++++++++++++-- x-pack/plugins/observability/public/plugin.ts | 2 +- x-pack/plugins/observability/server/plugin.ts | 2 ++ 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/x-pack/plugins/observability/kibana.jsonc b/x-pack/plugins/observability/kibana.jsonc index ad5fac050d671..d49e3ea870a62 100644 --- a/x-pack/plugins/observability/kibana.jsonc +++ b/x-pack/plugins/observability/kibana.jsonc @@ -24,8 +24,7 @@ "unifiedSearch", "security", "guidedOnboarding", - "share", - "spaces" + "share" ], "optionalPlugins": [ "discover", diff --git a/x-pack/plugins/observability/public/hooks/use_kibana_space.tsx b/x-pack/plugins/observability/public/hooks/use_kibana_space.tsx index 11716e948d855..8f2ebf187dc77 100644 --- a/x-pack/plugins/observability/public/hooks/use_kibana_space.tsx +++ b/x-pack/plugins/observability/public/hooks/use_kibana_space.tsx @@ -15,7 +15,7 @@ export const useKibanaSpace = () => { data: space, loading, error, - } = useFetcher>(() => { + } = useFetcher | undefined>(() => { return services.spaces?.getActiveSpace(); }, [services.spaces]); diff --git a/x-pack/plugins/observability/public/pages/overview/containers/overview_page/helpers/use_metrics.ts b/x-pack/plugins/observability/public/pages/overview/containers/overview_page/helpers/use_metrics.ts index 78fffde25d629..dd9581bd67867 100644 --- a/x-pack/plugins/observability/public/pages/overview/containers/overview_page/helpers/use_metrics.ts +++ b/x-pack/plugins/observability/public/pages/overview/containers/overview_page/helpers/use_metrics.ts @@ -29,9 +29,22 @@ export const useOverviewMetrics = ({ hasAnyData }: { hasAnyData: boolean | undef } CAPABILITIES_KEYS.forEach((feature) => { - if (capabilities[feature].show === false) { + const name = feature === 'infrastructure' ? 'metrics' : feature; + + // Track metric if the feature has been disabled, either because it + // is missing or has show === false (manual disabling may not be + // possible in all versions of Kibana) + if (!capabilities[feature] || capabilities[feature]?.show === false) { + trackMetric({ + metric: `oblt_disabled_feature_${name}`, + }); + } + + // Track a separate metric if the feature is missing from the capabilities + // (This usually means the plugin was auto-disabled by Kibana) + if (!capabilities[feature]) { trackMetric({ - metric: `oblt_disabled_feature_${feature === 'infrastructure' ? 'metrics' : feature}`, + metric: `oblt_missing_feature_${name}`, }); } }); diff --git a/x-pack/plugins/observability/public/plugin.ts b/x-pack/plugins/observability/public/plugin.ts index e43725d0c5681..6af40e9a4345f 100644 --- a/x-pack/plugins/observability/public/plugin.ts +++ b/x-pack/plugins/observability/public/plugin.ts @@ -105,7 +105,7 @@ export interface ObservabilityPublicPluginsStart { ruleTypeRegistry: RuleTypeRegistryContract; security: SecurityPluginStart; share: SharePluginStart; - spaces: SpacesPluginStart; + spaces?: SpacesPluginStart; triggersActionsUi: TriggersAndActionsUIPublicPluginStart; usageCollection: UsageCollectionSetup; unifiedSearch: UnifiedSearchPublicPluginStart; diff --git a/x-pack/plugins/observability/server/plugin.ts b/x-pack/plugins/observability/server/plugin.ts index 39a69d7fa1666..e570fd7887952 100644 --- a/x-pack/plugins/observability/server/plugin.ts +++ b/x-pack/plugins/observability/server/plugin.ts @@ -17,6 +17,7 @@ import { PluginSetupContract } from '@kbn/alerting-plugin/server'; import { Dataset, RuleRegistryPluginSetupContract } from '@kbn/rule-registry-plugin/server'; import { PluginSetupContract as FeaturesSetup } from '@kbn/features-plugin/server'; import { createUICapabilities } from '@kbn/cases-plugin/common'; +import { SpacesPluginSetup } from '@kbn/spaces-plugin/server'; import { experimentalRuleFieldMap } from '@kbn/rule-registry-plugin/common/assets/field_maps/experimental_rule_field_map'; import { ECS_COMPONENT_TEMPLATE_NAME } from '@kbn/alerting-plugin/server'; import type { GuidedOnboardingPluginSetup } from '@kbn/guided-onboarding-plugin/server'; @@ -50,6 +51,7 @@ interface PluginSetup { features: FeaturesSetup; guidedOnboarding: GuidedOnboardingPluginSetup; ruleRegistry: RuleRegistryPluginSetupContract; + spaces?: SpacesPluginSetup; usageCollection?: UsageCollectionSetup; } From 06c70d96c6a3f5cd2e88235a109228639e6a137b Mon Sep 17 00:00:00 2001 From: Coen Warmer Date: Wed, 1 Mar 2023 16:56:23 +0100 Subject: [PATCH 10/10] [SLO] Alternative split to remote indices (#152463) ## Summary This updates the utility to process a string of one or more indices. It assumed when one part of the string passed contained `remote:`, all remaining indices would also have to contain `remote`, but this isn't necessary. --- .../services/slo/transform_generators/common.test.ts | 4 +++- .../services/slo/transform_generators/common.ts | 12 +++--------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/x-pack/plugins/observability/server/services/slo/transform_generators/common.test.ts b/x-pack/plugins/observability/server/services/slo/transform_generators/common.test.ts index ba9856860ec84..fa34496573338 100644 --- a/x-pack/plugins/observability/server/services/slo/transform_generators/common.test.ts +++ b/x-pack/plugins/observability/server/services/slo/transform_generators/common.test.ts @@ -13,7 +13,9 @@ describe('common', () => { ['foo-*', 'foo-*'], ['foo-*,bar-*', ['foo-*', 'bar-*']], ['remote:foo-*', 'remote:foo-*'], - ['remote:foo*,bar-*', ['remote:foo*', 'remote:bar-*']], + ['remote:foo*,bar-*', ['remote:foo*', 'bar-*']], + ['remote:foo*,remote:bar-*', ['remote:foo*', 'remote:bar-*']], + ['remote:foo*,bar-*,remote:baz-*', ['remote:foo*', 'bar-*', 'remote:baz-*']], ])("parses the index '%s' correctly", (index, expected) => { expect(parseIndex(index)).toEqual(expected); }); diff --git a/x-pack/plugins/observability/server/services/slo/transform_generators/common.ts b/x-pack/plugins/observability/server/services/slo/transform_generators/common.ts index 54197076d359f..ea64f23662695 100644 --- a/x-pack/plugins/observability/server/services/slo/transform_generators/common.ts +++ b/x-pack/plugins/observability/server/services/slo/transform_generators/common.ts @@ -17,15 +17,9 @@ export function getElastichsearchQueryOrThrow(kuery: string) { } export function parseIndex(index: string): string | string[] { - if (index.indexOf(',') > -1) { - if (index.indexOf(':') > -1) { - const indexParts = index.split(':'); // "remote_name:foo-*,bar*" - const remoteName = indexParts[0]; - return indexParts[1].split(',').map((idx) => `${remoteName}:${idx}`); // [ "remote_name:foo-*", "remote_name:bar-*"] - } - - return index.split(','); + if (index.indexOf(',') === -1) { + return index; } - return index; + return index.split(','); }