### Run Kibana with Developer Examples Source: https://www.elastic.co/guide/en/kibana/8.19/development-getting-started.html Start Kibana for development. Include developer examples by adding the --run-examples flag. ```bash yarn start --run-examples ``` -------------------------------- ### Install Kibana Plugin from Local File Path Source: https://www.elastic.co/guide/en/kibana/8.19/kibana-plugins.html You can install plugins by providing a file path to a specific plugin. This example demonstrates installing a plugin from a local zip file. ```bash or $ bin/kibana-plugin install file:///local/path/to/custom_plugin.zip ``` -------------------------------- ### Get Monitor API Example Source: https://www.elastic.co/guide/en/kibana/8.19/get-monitor-api.html This example demonstrates how to retrieve a monitor's configuration using its config_id. Ensure you have the necessary read privileges for the Synthetics feature. ```http GET /api/synthetics/monitors/ { "type": "http", "enabled": true, "alert": { "status": { "enabled": true }, "tls": { "enabled": true } }, "schedule": { "number": "3", "unit": "m" }, "config_id": "a8188705-d01e-4bb6-87a1-64fa5e4b07ec", "timeout": "16", "name": "am i something", "locations": [ { "id": "us_central", "label": "North America - US Central", "geo": { "lat": 41.25, "lon": -95.86 }, "isServiceManaged": true } ], "namespace": "default", "origin": "ui", "id": "a8188705-d01e-4bb6-87a1-64fa5e4b07ec", "max_attempts": 2, "__ui": { "is_tls_enabled": false }, "max_redirects": "0", "response.include_body": "on_error", "response.include_headers": true, "check.request.method": "GET", "mode": "any", "response.include_body_max_bytes": "1024", "ipv4": true, "ipv6": true, "ssl.verification_mode": "full", "ssl.supported_protocols": [ "TLSv1.1", "TLSv1.2", "TLSv1.3" ], "revision": 13, "created_at": "2023-11-08T08:45:29.334Z", "updated_at": "2023-12-18T20:31:44.770Z", "url": "https://example.com" } ``` -------------------------------- ### Start Kibana from command line (Windows) Source: https://www.elastic.co/guide/en/kibana/8.19/start-stop.html Use this command to start Kibana when installed via a .zip package on Windows. Kibana runs in the foreground and logs to STDOUT. Stop with Ctrl-C. ```batch .\bin\kibana.bat ``` -------------------------------- ### Start Kibana from command line (Linux/Darwin) Source: https://www.elastic.co/guide/en/kibana/8.19/start-stop.html Use this command to start Kibana when installed via a .tar.gz package on Linux or Darwin. Kibana runs in the foreground and logs to stdout. Stop with Ctrl-C. ```bash ./bin/kibana ``` -------------------------------- ### Setup Package Testing Environment Source: https://www.elastic.co/guide/en/kibana/8.19/development-tests.html Navigates to the package testing directory and sets up the virtual machine and networking. ```bash cd src/platform/test/package # Setup virtual machine and networking vagrant up --no-provision ``` -------------------------------- ### Registering an HTTP Route Handler in Plugin Setup Source: https://www.elastic.co/guide/en/kibana/8.19/kibana-platform-plugin-api.html Use the `core.http.createRouter()` function within the `setup` phase to register HTTP route handlers. This example shows how to define a GET route for '/path'. ```typescript import type { CoreSetup } from '@kbn/core/server'; export class MyPlugin { public setup(core: CoreSetup) { const router = core.http.createRouter(); // handler is called when '/path' resource is requested with `GET` method router.get({ path: '/path', validate: false }, (context, req, res) => res.ok({ content: 'ok' })); } } ``` -------------------------------- ### Example Response for Get Features API Source: https://www.elastic.co/guide/en/kibana/8.19/features-api-get.html This is an example of the JSON response returned by the Get Features API, detailing the 'discover' feature. ```json { "id": "discover", "name": "Discover", "app": [ "kibana" ], "catalogue": [ "discover" ], "privileges": { "all": { "savedObject": { "all": [ "search", "url" ], "read": [ "config", "index-pattern" ] }, "ui": [ "show", "createShortUrl", "save" ] }, "read": { "savedObject": { "all": [], "read": [ "config", "index-pattern", "search", "url" ] }, "ui": [ "show" ] } } } ``` -------------------------------- ### Install Plugin with Timeout (1 minute) Source: https://www.elastic.co/guide/en/kibana/8.19/kibana-plugins.html Installs a sample plugin, setting a timeout of 1 minute for the operation. If the installation does not complete within this period, the command will fail. ```bash bin/kibana-plugin install --timeout 1m sample-plugin ``` -------------------------------- ### Start or resume reindex API Response Example Source: https://www.elastic.co/guide/en/kibana/8.19/start-resume-reindex.html This is an example of a successful response from the reindex API. It includes details about the new index name, status, and progress if the reindexing has started. ```json { "indexName": ".ml-state", "newIndexName": ".reindexed-v7-ml-state", "status": 0, "lastCompletedStep": 0, "reindexTaskId": null, "reindexTaskPercComplete": null, "errorMessage": null } ``` -------------------------------- ### Install apt-transport-https Source: https://www.elastic.co/guide/en/kibana/8.19/deb.html Ensure the apt-transport-https package is installed on Debian systems before proceeding with APT repository setup. ```bash sudo apt-get install apt-transport-https ``` -------------------------------- ### Install Plugin with Timeout (30 seconds) Source: https://www.elastic.co/guide/en/kibana/8.19/kibana-plugins.html Installs a sample plugin, setting a timeout of 30 seconds for the operation. If the installation does not complete within this period, the command will fail. ```bash bin/kibana-plugin install --timeout 30s sample-plugin ``` -------------------------------- ### Example xpack.fleet.outputs Configuration Source: https://www.elastic.co/guide/en/kibana/8.19/fleet-settings-kb.html Demonstrates how to configure pre-defined outputs for Fleet, including settings for SSL and secrets. ```yaml xpack.fleet.outputs: - id: my-logstash-output-with-a-secret name: preconfigured logstash output with a secret type: logstash hosts: ["localhost:9999"] ssl: certificate: xxxxxxxxxx secrets: ssl: key: securekey ``` -------------------------------- ### Excluding Specific Indices from Cross-Cluster Search Source: https://www.elastic.co/guide/en/kibana/8.19/data-views.html Example of matching indices starting with 'logstash-' but excluding those starting with 'logstash-old', from all clusters whose names start with 'cluster_'. ```text cluster_*:logstash-*,cluster_*:-logstash-old* ``` -------------------------------- ### Example Fleet Preconfiguration Source: https://www.elastic.co/guide/en/kibana/8.19/fleet-settings-kb.html This snippet shows how to preconfigure integrations and agent policies, including specific input settings and variables. ```yaml xpack.fleet.packages: - name: apache version: 0.5.0 xpack.fleet.agentPolicies: - name: Preconfigured Policy id: preconfigured-policy namespace: test package_policies: - package: name: system name: System Integration namespace: test id: preconfigured-system inputs: system-system/metrics: enabled: true vars: '[system.hostfs]': home/test system-winlog: enabled: false ``` -------------------------------- ### Client-side GET Request Source: https://www.elastic.co/guide/en/kibana/8.19/http-service.html Example of how client-side code can use the HttpService to make a GET request to a Kibana server endpoint. ```APIDOC ## GET /api/my_plugin/ ### Description Makes a GET request to the '/api/my_plugin/' endpoint on the Kibana server. This is a preconfigured wrapper around `window.fetch`. ### Method GET ### Endpoint /api/my_plugin/ ### Parameters #### Query Parameters - **query** (object) - Optional - Query parameters for the request. ### Request Example ```json { "example": "request body" } ``` ### Response #### Success Response (200) - **body** (ResponseType) - The response data from the server, typed as ResponseType. #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### List available actions with kbn-action Source: https://www.elastic.co/guide/en/kibana/8.19/testing-connectors.html Use this command to list all configured actions. Ensure KBN_URLBASE is set correctly for your deployment. ```bash $ npm -g install pmuellr/kbn-action $ export KBN_URLBASE=https://elastic:@.us-east-1.aws.found.io:9243 $ kbn-action ls [ { "id": "a692dc89-15b9-4a3c-9e47-9fb6872e49ce", "actionTypeId": ".email", "name": "gmail", "config": { "from": "test@gmail.com", "host": "smtp.gmail.com", "port": 465, "secure": true, "service": null }, "isPreconfigured": false, "isDeprecated": false, "referencedByCount": 0 } ] ``` -------------------------------- ### Example UI Settings Migrations Source: https://www.elastic.co/guide/en/kibana/8.19/ui-settings-service.html Demonstrates how to define migration entries for UI settings. This includes removing specific settings and renaming others based on version. ```typescript export const migrations = { ... '8.1.0': (doc: SavedObjectUnsanitizedDoc): SavedObjectSanitizedDoc => ({ ...doc, ...(doc.attributes && { attributes: Object.keys(doc.attributes).reduce( (acc, key) => [ // other settings to remove for 8.1.0... 'custom', ].includes(key) ? { ...acc, } : { ...acc, [key]: doc.attributes[key], }, {} ), }), references: doc.references || [], }), '8.2.0': (doc: SavedObjectUnsanitizedDoc): SavedObjectSanitizedDoc => ({ ...doc, ...(doc.attributes && { attributes: Object.keys(doc.attributes).reduce( (acc, key) => key.startsWith('my_setting:') ? { ...acc, [key.replace('my_setting', 'my_other_setting')]: doc.attributes[key], } : { ...acc, [key]: doc.attributes[key], }, {} ), }), references: doc.references || [], }), … } ``` -------------------------------- ### Example Response for Dashboard Feature Source: https://www.elastic.co/guide/en/kibana/8.19/features-api-get.html This is an example of the JSON response returned by the Get Features API, detailing the 'dashboard' feature. ```json { "id": "dashboard", "name": "Dashboard", "app": [ "kibana" ], "catalogue": [ "dashboard" ], "privileges": { "all": { "savedObject": { "all": [ "dashboard", "url" ], "read": [ "config", "index-pattern", "search", "visualization", "canvas-workpad" ] }, "ui": [ "createNew", "show", "showWriteControls" ] }, "read": { "savedObject": { "all": [], "read": [ "config", "index-pattern", "search", "visualization", "canvas-workpad", "dashboard" ] }, "ui": [ "show" ] } } } ``` -------------------------------- ### Example Response for Visualize Feature Source: https://www.elastic.co/guide/en/kibana/8.19/features-api-get.html This is an example of the JSON response returned by the Get Features API, detailing the 'visualize' feature. ```json { "id": "visualize", "name": "Visualize", "app": [ "kibana" ], "catalogue": [ "visualize" ], "privileges": { "all": { "savedObject": { "all": [ "visualization", "url" ], "read": [ "config", "index-pattern", "search" ] }, "ui": [ "show", "createShortUrl", "delete", "save" ] }, "read": { "savedObject": { "all": [], "read": [ "config", "index-pattern", "search", "visualization" ] }, "ui": [ "show" ] } } } ``` -------------------------------- ### Provision and Test Package Installation Source: https://www.elastic.co/guide/en/kibana/8.19/development-tests.html Installs Kibana and runs OS-level tests on the provisioned virtual machine. This step ensures the machine state and can be repeated when adding new tests. ```bash # Install Kibana and run OS level tests # This step can be repeated when adding new tests, it ensures machine state - installations won't run twice vagrant provision ``` -------------------------------- ### Install kbn-action CLI Tool Source: https://www.elastic.co/guide/en/kibana/8.19/alerting-troubleshooting.html Install the `kbn-action` command-line client globally using npm. This tool can be used to manage alerts and actions via legacy rule APIs, which may need updating for new API versions. ```bash npm install -g pmuellr/kbn-action ``` -------------------------------- ### Install Kibana Plugin from URL Source: https://www.elastic.co/guide/en/kibana/8.19/kibana-plugins.html You can install official Elastic plugins by specifying their name or by providing a URL or file path to a specific plugin. This example shows installation from a remote URL. ```bash $ bin/kibana-plugin install https://artifacts.elastic.co/downloads/packs/x-pack/x-pack-8.19.16.zip ```