LogstashClient¶
Client for the Kibana Logstash Configuration Management API.
Manage centrally-managed Logstash pipelines that are stored in Elasticsearch
and distributed to Logstash instances configured with xpack.management
(centralized pipeline management). A running Logstash instance is not
required to create, read, update, or delete pipeline definitions.
Note
All endpoints in this namespace are in technical preview in Kibana 9.4 and are not space-scoped.
Required privileges: the logstash_admin built-in role (or a customized
Logstash writer role) for write operations, and the logstash_admin
built-in role (or a customized Logstash reader role) for read operations.
- class kibana._sync.client.logstash.LogstashClient(client, default_space_id=None, validate_spaces=True)[source]¶
Bases:
NamespaceClientClient for the Kibana Logstash Configuration Management API.
Manage centrally-managed Logstash pipelines that are stored in Elasticsearch and distributed to Logstash instances configured with
xpack.management(centralized pipeline management). A running Logstash instance is not required to create, read, update, or delete pipeline definitions.All endpoints in this namespace are in Technical Preview in Kibana 9.4 and are not space-scoped.
Required privileges: the
logstash_adminbuilt-in role (or a customized Logstash writer role) for write operations, and thelogstash_adminbuilt-in role (or a customized Logstash reader role) for read operations.Example
>>> from kibana import Kibana >>> client = Kibana("http://localhost:5601", api_key="...") >>> >>> # Create a pipeline >>> client.logstash.create_or_update( ... id="hello-world", ... pipeline="input { stdin {} } output { stdout {} }", ... description="Just a simple pipeline", ... ) >>> >>> # List all pipelines >>> for p in client.logstash.get_all().body["pipelines"]: ... print(p["id"]) hello-world
Managing Pipelines
from kibana import Kibana client = Kibana("http://localhost:5601", api_key="your_api_key") # Create (or replace) a pipeline client.logstash.create_or_update( id="hello-world", pipeline="input { stdin {} } output { stdout {} }", description="Just a simple pipeline", ) # List all pipelines for p in client.logstash.get_all().body["pipelines"]: print(p["id"]) # Get a single pipeline (includes the pipeline definition) pipeline = client.logstash.get(id="hello-world") print(pipeline.body["pipeline"]) # Delete the pipeline client.logstash.delete(id="hello-world")
Pipeline Settings
Pipelines accept optional Logstash settings (worker counts, batch sizes, queue configuration):
client.logstash.create_or_update( id="tuned-pipeline", pipeline="input { stdin {} } output { stdout {} }", settings={ "pipeline.workers": 2, "pipeline.batch.size": 250, "queue.type": "persisted", }, )
- get_all()[source]¶
Get all Logstash pipelines.
Get a list of all centrally-managed Logstash pipelines. Limit the number of pipelines to 10,000 or fewer; as the number of pipelines nears and surpasses 10,000, you may see performance issues on Kibana. The
usernameproperty appears in the response when security is enabled and depends on when the pipeline was created or last updated.Technical preview in 9.4.
- Returns:
ObjectApiResponse with a
pipelineslist; each entry containsid,description,last_modifiedand, when security is enabled,username.- Raises:
AuthenticationException – If authentication fails.
AuthorizationException – If the user lacks the
logstash_adminrole or a customized Logstash reader role.
- Return type:
Example
>>> response = client.logstash.get_all() >>> for pipeline in response.body["pipelines"]: ... print(pipeline["id"], pipeline.get("description", "")) hello-world Just a simple pipeline
- get(*, id)[source]¶
Get a Logstash pipeline.
Get information for a centrally-managed Logstash pipeline.
Technical preview in 9.4.
- Parameters:
id (str) – An identifier for the pipeline.
- Returns:
id,description,pipeline(the pipeline definition),settingsand, when security is enabled,username.- Return type:
ObjectApiResponse with the pipeline document
- Raises:
AuthenticationException – If authentication fails.
AuthorizationException – If the user lacks the
logstash_adminrole or a customized Logstash reader role.NotFoundError – If no pipeline exists with the given
id.
Example
>>> response = client.logstash.get(id="hello-world") >>> print(response.body["pipeline"]) input { stdin {} } output { stdout {} }
- create_or_update(*, id, pipeline, description=None, settings=None)[source]¶
Create or update a Logstash pipeline.
Create a centrally-managed Logstash pipeline or update an existing pipeline (the operation is an upsert on
id).Technical preview in 9.4.
- Parameters:
id (str) – An identifier for the pipeline. It must begin with a letter or underscore and can contain only letters, underscores, dashes, hyphens, and numbers.
pipeline (str) – A definition for the pipeline, as a Logstash pipeline configuration string.
description (str | None) – A description of the pipeline.
settings (dict[str, Any] | None) – Supported settings, represented as object keys, include
pipeline.workers,pipeline.batch.size,pipeline.batch.delay,pipeline.ecs_compatibility,pipeline.ordered,queue.type,queue.max_bytesandqueue.checkpoint.writes.
- Returns:
ObjectApiResponse with an empty body (the server replies
204 No Contenton success).- Raises:
AuthenticationException – If authentication fails.
AuthorizationException – If the user lacks the
logstash_adminrole or a customized Logstash writer role.BadRequestError – If the pipeline identifier or body is invalid.
- Return type:
Example
>>> client.logstash.create_or_update( ... id="hello-world", ... pipeline="input { stdin {} } output { stdout {} }", ... description="Just a simple pipeline", ... settings={"queue.type": "persisted"}, ... )
- delete(*, id)[source]¶
Delete a Logstash pipeline.
Delete a centrally-managed Logstash pipeline.
Technical preview in 9.4.
- Parameters:
id (str) – An identifier for the pipeline.
- Returns:
ObjectApiResponse with an empty body (the server replies
204 No Contenton success).- Raises:
AuthenticationException – If authentication fails.
AuthorizationException – If the user lacks the
logstash_adminrole or a customized Logstash writer role.NotFoundError – If no pipeline exists with the given
id.
- Return type:
Example
>>> client.logstash.delete(id="hello-world")
- __init__(client, default_space_id=None, validate_spaces=True)¶
Initialize NamespaceClient with optional space support.
AsyncLogstashClient¶
Asynchronous version of the LogstashClient for use with async/await syntax.
- class kibana._async.client.logstash.AsyncLogstashClient(client, default_space_id=None, validate_spaces=True)[source]¶
Bases:
AsyncNamespaceClientAsync client for the Kibana Logstash Configuration Management API.
Manage centrally-managed Logstash pipelines that are stored in Elasticsearch and distributed to Logstash instances configured with
xpack.management(centralized pipeline management). A running Logstash instance is not required to create, read, update, or delete pipeline definitions.All endpoints in this namespace are in Technical Preview in Kibana 9.4 and are not space-scoped.
Required privileges: the
logstash_adminbuilt-in role (or a customized Logstash writer role) for write operations, and thelogstash_adminbuilt-in role (or a customized Logstash reader role) for read operations.Example
>>> from kibana import AsyncKibana >>> client = AsyncKibana("http://localhost:5601", api_key="...") >>> >>> # Create a pipeline >>> await client.logstash.create_or_update( ... id="hello-world", ... pipeline="input { stdin {} } output { stdout {} }", ... description="Just a simple pipeline", ... ) >>> >>> # List all pipelines >>> for p in (await client.logstash.get_all()).body["pipelines"]: ... print(p["id"]) hello-world
Usage
The AsyncLogstashClient provides the same methods as LogstashClient 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: # Create a pipeline (async) await client.logstash.create_or_update( id="async-pipeline", pipeline="input { stdin {} } output { stdout {} }", ) # List pipelines (async) pipelines = await client.logstash.get_all() # Delete (async) await client.logstash.delete(id="async-pipeline") asyncio.run(main())
- async get_all()[source]¶
Get all Logstash pipelines.
Get a list of all centrally-managed Logstash pipelines. Limit the number of pipelines to 10,000 or fewer; as the number of pipelines nears and surpasses 10,000, you may see performance issues on Kibana. The
usernameproperty appears in the response when security is enabled and depends on when the pipeline was created or last updated.Technical preview in 9.4.
- Returns:
ObjectApiResponse with a
pipelineslist; each entry containsid,description,last_modifiedand, when security is enabled,username.- Raises:
AuthenticationException – If authentication fails.
AuthorizationException – If the user lacks the
logstash_adminrole or a customized Logstash reader role.
- Return type:
Example
>>> response = await client.logstash.get_all() >>> for pipeline in response.body["pipelines"]: ... print(pipeline["id"], pipeline.get("description", "")) hello-world Just a simple pipeline
- async get(*, id)[source]¶
Get a Logstash pipeline.
Get information for a centrally-managed Logstash pipeline.
Technical preview in 9.4.
- Parameters:
id (str) – An identifier for the pipeline.
- Returns:
id,description,pipeline(the pipeline definition),settingsand, when security is enabled,username.- Return type:
ObjectApiResponse with the pipeline document
- Raises:
AuthenticationException – If authentication fails.
AuthorizationException – If the user lacks the
logstash_adminrole or a customized Logstash reader role.NotFoundError – If no pipeline exists with the given
id.
Example
>>> response = await client.logstash.get(id="hello-world") >>> print(response.body["pipeline"]) input { stdin {} } output { stdout {} }
- async create_or_update(*, id, pipeline, description=None, settings=None)[source]¶
Create or update a Logstash pipeline.
Create a centrally-managed Logstash pipeline or update an existing pipeline (the operation is an upsert on
id).Technical preview in 9.4.
- Parameters:
id (str) – An identifier for the pipeline. It must begin with a letter or underscore and can contain only letters, underscores, dashes, hyphens, and numbers.
pipeline (str) – A definition for the pipeline, as a Logstash pipeline configuration string.
description (str | None) – A description of the pipeline.
settings (dict[str, Any] | None) – Supported settings, represented as object keys, include
pipeline.workers,pipeline.batch.size,pipeline.batch.delay,pipeline.ecs_compatibility,pipeline.ordered,queue.type,queue.max_bytesandqueue.checkpoint.writes.
- Returns:
ObjectApiResponse with an empty body (the server replies
204 No Contenton success).- Raises:
AuthenticationException – If authentication fails.
AuthorizationException – If the user lacks the
logstash_adminrole or a customized Logstash writer role.BadRequestError – If the pipeline identifier or body is invalid.
- Return type:
Example
>>> await client.logstash.create_or_update( ... id="hello-world", ... pipeline="input { stdin {} } output { stdout {} }", ... description="Just a simple pipeline", ... settings={"queue.type": "persisted"}, ... )
- async delete(*, id)[source]¶
Delete a Logstash pipeline.
Delete a centrally-managed Logstash pipeline.
Technical preview in 9.4.
- Parameters:
id (str) – An identifier for the pipeline.
- Returns:
ObjectApiResponse with an empty body (the server replies
204 No Contenton success).- Raises:
AuthenticationException – If authentication fails.
AuthorizationException – If the user lacks the
logstash_adminrole or a customized Logstash writer role.NotFoundError – If no pipeline exists with the given
id.
- Return type:
Example
>>> await client.logstash.delete(id="hello-world")
- __init__(client, default_space_id=None, validate_spaces=True)¶
Initialize AsyncNamespaceClient with optional space support.