FleetClient¶
Client for the Kibana Fleet core API.
Fleet provides centralized management of Elastic Agents and their policies. This client covers the Fleet internals: initializing Fleet, reading and updating the global and per-space Fleet settings, checking Fleet Server health, and checking the current user’s Fleet permissions.
All Fleet APIs are space-aware: every method accepts an optional
space_id to target a specific Kibana space.
- class kibana._sync.client.fleet.FleetClient(client, default_space_id=None, validate_spaces=True)[source]¶
Bases:
NamespaceClientClient for the Kibana Fleet core API (setup, settings, health).
Fleet provides a web-based UI and APIs in Kibana for centrally managing Elastic Agents and their policies. This client covers the Fleet internals: initializing Fleet (
setup), reading and updating the global Fleet settings, reading and updating the per-space Fleet settings, checking Fleet Server health, and checking the current user’s Fleet permissions.All Fleet APIs are space-aware: every method accepts an optional
space_idto target a specific Kibana space (Nonetargets the default space or the space the client is scoped to).Example
>>> from kibana import Kibana >>> client = Kibana("http://localhost:5601", api_key="...") >>> >>> # Initialize Fleet (idempotent) >>> result = client.fleet.setup() >>> print(result.body["isInitialized"]) True >>> >>> # Read the global Fleet settings >>> settings = client.fleet.get_settings() >>> print(settings.body["item"]["id"]) fleet-default-settings
Initializing Fleet
Fleet setup creates the Elasticsearch resources Fleet needs to operate. It is idempotent and safe to call multiple times:
from kibana import Kibana client = Kibana("http://localhost:5601", api_key="your_api_key") result = client.fleet.setup() print(result.body["isInitialized"]) # True print(result.body["nonFatalErrors"]) # []
Checking Permissions and Fleet Server Health
# Check whether the current user can use Fleet perms = client.fleet.check_permissions() if not perms.body["success"]: print(perms.body["error"]) # e.g. "MISSING_PRIVILEGES" # Also verify Fleet Server setup privileges perms = client.fleet.check_permissions(fleet_server_setup=True) # Check the health of a configured Fleet Server host by its ID health = client.fleet.health_check(id="fleet-server-host-id-1") print(health.body["status"]) # "ONLINE" or "OFFLINE"
Global Fleet Settings
# Read the global Fleet settings settings = client.fleet.get_settings() item = settings.body["item"] print(item["prerelease_integrations_enabled"]) # Update a setting (only the provided fields are changed) client.fleet.update_settings(prerelease_integrations_enabled=True) # Configure automatic deletion of unenrolled agents client.fleet.update_settings( delete_unenrolled_agents={ "enabled": True, "is_preconfigured": False, } )
Per-Space Fleet Settings
Space settings restrict which data stream namespace prefixes may be used in a Kibana space. Note that Kibana 9.4.3 rejects prefixes containing a
-character:# Read the space settings for the default space space_settings = client.fleet.get_space_settings() print(space_settings.body["item"]["allowed_namespace_prefixes"]) # Restrict namespaces in a specific space client.fleet.update_space_settings( allowed_namespace_prefixes=["teama", "teamb"], space_id="marketing", ) # Remove all restrictions again client.fleet.update_space_settings( allowed_namespace_prefixes=[], space_id="marketing", )
- __init__(client, default_space_id=None, validate_spaces=True)[source]¶
Initialize the FleetClient.
- Parameters:
Example
>>> fleet_client = FleetClient(kibana_client)
- setup(*, space_id=None, validate_spaces=None)[source]¶
Initiate Fleet setup.
Initialize Fleet and create the necessary Elasticsearch resources for Fleet to operate. Safe to call multiple times (idempotent). Returns the initialization status and any non-fatal errors encountered during setup.
- Parameters:
- Returns:
isInitialized: True if Fleet is ready to accept agent enrollment
nonFatalErrors: List of
{"name", "message"}objects describing non-blocking issues encountered during setup
- Return type:
ObjectApiResponse containing the setup result
- Raises:
BadRequestError – If the request is invalid.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
ApiError – If Fleet setup fails with an internal server error.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
Example
>>> result = client.fleet.setup() >>> print(result.body["isInitialized"]) True >>> print(result.body["nonFatalErrors"]) []
- get_settings(*, space_id=None, validate_spaces=None)[source]¶
Get settings.
Get the global Fleet settings.
- Parameters:
- Returns:
ObjectApiResponse containing an
itemobject with the global Fleet settings, includingid,version,prerelease_integrations_enabled,delete_unenrolled_agents,preconfigured_fields,ilm_migration_statusand secret-storage requirement flags.- Raises:
NotFoundError – If Fleet settings have not been initialized.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges (requires
fleet-settings-read).SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> settings = client.fleet.get_settings() >>> print(settings.body["item"]["prerelease_integrations_enabled"]) False
- update_settings(*, additional_yaml_config=None, delete_unenrolled_agents=None, has_seen_add_data_notice=None, integration_knowledge_enabled=None, kibana_ca_sha256=None, kibana_urls=None, prerelease_integrations_enabled=None, space_id=None, validate_spaces=None)[source]¶
Update settings.
Update the global Fleet settings. Only the provided fields are changed; omitted fields keep their current values.
- Parameters:
additional_yaml_config (str | None) – Deprecated. Additional Fleet Server YAML configuration.
delete_unenrolled_agents (dict[str, Any] | None) – Automatic deletion policy for unenrolled agents, an object with the required keys
enabled(bool) andis_preconfigured(bool).has_seen_add_data_notice (bool | None) – Deprecated. Whether the “add data” notice has been dismissed.
integration_knowledge_enabled (bool | None) – Whether integration knowledge content is enabled.
kibana_ca_sha256 (str | None) – Deprecated. SHA-256 of the Kibana CA certificate.
kibana_urls (list[str] | None) – Deprecated. Kibana URLs used by agents (maximum 10 URI strings).
prerelease_integrations_enabled (bool | None) – Whether pre-release integrations may be installed from the package registry.
space_id (str | None) – Optional space ID to update the settings in.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse containing an
itemobject with the updated global Fleet settings.- Raises:
BadRequestError – If the request body is invalid.
NotFoundError – If Fleet settings have not been initialized.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges (requires
fleet-settings-all).SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> updated = client.fleet.update_settings( ... prerelease_integrations_enabled=True, ... ) >>> print(updated.body["item"]["prerelease_integrations_enabled"]) True
- get_space_settings(*, space_id=None, validate_spaces=None)[source]¶
Get space settings.
Get the Fleet settings for the current Kibana space. Added in Kibana 9.1.0.
- Parameters:
- Returns:
allowed_namespace_prefixes: List of namespace prefixes allowed in this space
managed_by: Optional identifier of the manager of these settings
- Return type:
ObjectApiResponse containing an
itemobject with- Raises:
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
Example
>>> settings = client.fleet.get_space_settings() >>> print(settings.body["item"]["allowed_namespace_prefixes"]) []
- update_space_settings(*, allowed_namespace_prefixes=None, space_id=None, validate_spaces=None)[source]¶
Create or update space settings.
Create or update the Fleet settings for the current Kibana space. Added in Kibana 9.1.0.
Note: as of Kibana 9.4.3 the live server rejects prefixes that contain a
-character (Must not contain -), even though the published OpenAPI schema allows arbitrary strings.- Parameters:
allowed_namespace_prefixes (list[str] | None) – List of namespace prefixes (maximum 10) that data streams in this space are allowed to use. Pass an empty list to remove all restrictions.
space_id (str | None) – Optional space ID to update the space settings in.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse containing an
itemobject with the updatedallowed_namespace_prefixes(and optionallymanaged_by).- Raises:
BadRequestError – If the request body is invalid (for example, a prefix containing
-).AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges (requires
fleet-settings-all).SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> updated = client.fleet.update_space_settings( ... allowed_namespace_prefixes=["teama", "teamb"], ... ) >>> print(updated.body["item"]["allowed_namespace_prefixes"]) ['teama', 'teamb']
- health_check(*, id, space_id=None, validate_spaces=None)[source]¶
Check Fleet Server health.
Check the health status of a Fleet Server instance by its host ID. Returns the server status and name if available.
- Parameters:
- Returns:
status: Fleet Server status (e.g.
"ONLINE"or"OFFLINE")name: The Fleet Server name, if available
host_id: The checked host ID, if the host is unreachable
- Return type:
ObjectApiResponse containing the health check result
- Raises:
BadRequestError – If the host ID exists but has no associated host URLs configured.
NotFoundError – If no Fleet Server host exists with the given ID.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges (requires
fleet-settings-all).SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
Example
>>> health = client.fleet.health_check(id="fleet-server-host-id-1") >>> print(health.body["status"]) ONLINE
- check_permissions(*, fleet_server_setup=None, space_id=None, validate_spaces=None)[source]¶
Check permissions.
Check whether the current user has the required permissions to use Fleet. Optionally verifies Fleet Server setup privileges.
- Parameters:
- Returns:
success: True if the user has all required permissions
error: Present when success is False; one of
"MISSING_SECURITY","MISSING_PRIVILEGES"or"MISSING_FLEET_SERVER_SETUP_PRIVILEGES"
- Return type:
ObjectApiResponse containing the permission check result
- Raises:
BadRequestError – If the request is invalid.
AuthenticationException – If authentication fails.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
Example
>>> perms = client.fleet.check_permissions() >>> print(perms.body["success"]) True
AsyncFleetClient¶
Asynchronous version of the FleetClient for use with async/await syntax.
- class kibana._async.client.fleet.AsyncFleetClient(client, default_space_id=None, validate_spaces=True)[source]¶
Bases:
AsyncNamespaceClientAsync client for the Kibana Fleet core API (setup, settings, health).
Fleet provides a web-based UI and APIs in Kibana for centrally managing Elastic Agents and their policies. This client covers the Fleet internals: initializing Fleet (
setup), reading and updating the global Fleet settings, reading and updating the per-space Fleet settings, checking Fleet Server health, and checking the current user’s Fleet permissions.All Fleet APIs are space-aware: every method accepts an optional
space_idto target a specific Kibana space (Nonetargets the default space or the space the client is scoped to).Example
>>> from kibana import AsyncKibana >>> client = AsyncKibana("http://localhost:5601", api_key="...") >>> >>> # Initialize Fleet (idempotent) >>> result = await client.fleet.setup() >>> print(result.body["isInitialized"]) True >>> >>> # Read the global Fleet settings >>> settings = await client.fleet.get_settings() >>> print(settings.body["item"]["id"]) fleet-default-settings
Usage
The AsyncFleetClient provides the same methods as FleetClient but all methods are async and must be awaited:
from kibana import AsyncKibana import asyncio async def main(): async with AsyncKibana("http://localhost:5601") as client: # Initialize Fleet (async) result = await client.fleet.setup() print(result.body["isInitialized"]) # Read and update the global settings (async) settings = await client.fleet.get_settings() await client.fleet.update_settings( prerelease_integrations_enabled=True ) # Check permissions (async) perms = await client.fleet.check_permissions() print(perms.body["success"]) asyncio.run(main())
- __init__(client, default_space_id=None, validate_spaces=True)[source]¶
Initialize the AsyncFleetClient.
- Parameters:
client (AsyncKibana) – The parent AsyncKibana client instance to delegate requests to.
default_space_id (str | None) – Optional default space ID for all operations.
validate_spaces (bool) – Whether to validate space existence before space-scoped operations (default: True).
Example
>>> fleet_client = AsyncFleetClient(kibana_client)
- async setup(*, space_id=None, validate_spaces=None)[source]¶
Initiate Fleet setup.
Initialize Fleet and create the necessary Elasticsearch resources for Fleet to operate. Safe to call multiple times (idempotent). Returns the initialization status and any non-fatal errors encountered during setup.
- Parameters:
- Returns:
isInitialized: True if Fleet is ready to accept agent enrollment
nonFatalErrors: List of
{"name", "message"}objects describing non-blocking issues encountered during setup
- Return type:
ObjectApiResponse containing the setup result
- Raises:
BadRequestError – If the request is invalid.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
ApiError – If Fleet setup fails with an internal server error.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
Example
>>> result = await client.fleet.setup() >>> print(result.body["isInitialized"]) True >>> print(result.body["nonFatalErrors"]) []
- async get_settings(*, space_id=None, validate_spaces=None)[source]¶
Get settings.
Get the global Fleet settings.
- Parameters:
- Returns:
ObjectApiResponse containing an
itemobject with the global Fleet settings, includingid,version,prerelease_integrations_enabled,delete_unenrolled_agents,preconfigured_fields,ilm_migration_statusand secret-storage requirement flags.- Raises:
NotFoundError – If Fleet settings have not been initialized.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges (requires
fleet-settings-read).SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> settings = await client.fleet.get_settings() >>> print(settings.body["item"]["prerelease_integrations_enabled"]) False
- async update_settings(*, additional_yaml_config=None, delete_unenrolled_agents=None, has_seen_add_data_notice=None, integration_knowledge_enabled=None, kibana_ca_sha256=None, kibana_urls=None, prerelease_integrations_enabled=None, space_id=None, validate_spaces=None)[source]¶
Update settings.
Update the global Fleet settings. Only the provided fields are changed; omitted fields keep their current values.
- Parameters:
additional_yaml_config (str | None) – Deprecated. Additional Fleet Server YAML configuration.
delete_unenrolled_agents (dict[str, Any] | None) – Automatic deletion policy for unenrolled agents, an object with the required keys
enabled(bool) andis_preconfigured(bool).has_seen_add_data_notice (bool | None) – Deprecated. Whether the “add data” notice has been dismissed.
integration_knowledge_enabled (bool | None) – Whether integration knowledge content is enabled.
kibana_ca_sha256 (str | None) – Deprecated. SHA-256 of the Kibana CA certificate.
kibana_urls (list[str] | None) – Deprecated. Kibana URLs used by agents (maximum 10 URI strings).
prerelease_integrations_enabled (bool | None) – Whether pre-release integrations may be installed from the package registry.
space_id (str | None) – Optional space ID to update the settings in.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse containing an
itemobject with the updated global Fleet settings.- Raises:
BadRequestError – If the request body is invalid.
NotFoundError – If Fleet settings have not been initialized.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges (requires
fleet-settings-all).SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> updated = await client.fleet.update_settings( ... prerelease_integrations_enabled=True, ... ) >>> print(updated.body["item"]["prerelease_integrations_enabled"]) True
- async get_space_settings(*, space_id=None, validate_spaces=None)[source]¶
Get space settings.
Get the Fleet settings for the current Kibana space. Added in Kibana 9.1.0.
- Parameters:
- Returns:
allowed_namespace_prefixes: List of namespace prefixes allowed in this space
managed_by: Optional identifier of the manager of these settings
- Return type:
ObjectApiResponse containing an
itemobject with- Raises:
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
Example
>>> settings = await client.fleet.get_space_settings() >>> print(settings.body["item"]["allowed_namespace_prefixes"]) []
- async update_space_settings(*, allowed_namespace_prefixes=None, space_id=None, validate_spaces=None)[source]¶
Create or update space settings.
Create or update the Fleet settings for the current Kibana space. Added in Kibana 9.1.0.
Note: as of Kibana 9.4.3 the live server rejects prefixes that contain a
-character (Must not contain -), even though the published OpenAPI schema allows arbitrary strings.- Parameters:
allowed_namespace_prefixes (list[str] | None) – List of namespace prefixes (maximum 10) that data streams in this space are allowed to use. Pass an empty list to remove all restrictions.
space_id (str | None) – Optional space ID to update the space settings in.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse containing an
itemobject with the updatedallowed_namespace_prefixes(and optionallymanaged_by).- Raises:
BadRequestError – If the request body is invalid (for example, a prefix containing
-).AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges (requires
fleet-settings-all).SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> updated = await client.fleet.update_space_settings( ... allowed_namespace_prefixes=["teama", "teamb"], ... ) >>> print(updated.body["item"]["allowed_namespace_prefixes"]) ['teama', 'teamb']
- async health_check(*, id, space_id=None, validate_spaces=None)[source]¶
Check Fleet Server health.
Check the health status of a Fleet Server instance by its host ID. Returns the server status and name if available.
- Parameters:
- Returns:
status: Fleet Server status (e.g.
"ONLINE"or"OFFLINE")name: The Fleet Server name, if available
host_id: The checked host ID, if the host is unreachable
- Return type:
ObjectApiResponse containing the health check result
- Raises:
BadRequestError – If the host ID exists but has no associated host URLs configured.
NotFoundError – If no Fleet Server host exists with the given ID.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges (requires
fleet-settings-all).SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
Example
>>> health = await client.fleet.health_check( ... id="fleet-server-host-id-1" ... ) >>> print(health.body["status"]) ONLINE
- async check_permissions(*, fleet_server_setup=None, space_id=None, validate_spaces=None)[source]¶
Check permissions.
Check whether the current user has the required permissions to use Fleet. Optionally verifies Fleet Server setup privileges.
- Parameters:
- Returns:
success: True if the user has all required permissions
error: Present when success is False; one of
"MISSING_SECURITY","MISSING_PRIVILEGES"or"MISSING_FLEET_SERVER_SETUP_PRIVILEGES"
- Return type:
ObjectApiResponse containing the permission check result
- Raises:
BadRequestError – If the request is invalid.
AuthenticationException – If authentication fails.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
Example
>>> perms = await client.fleet.check_permissions() >>> print(perms.body["success"]) True