Logstash configuration language handling
Project description
lscl is a Python module for parsing and rendering Logstash configurations in its own language, named LSCL for “LogStash Configuration Language”.
The project is present at the following locations:
As described in Reading Logstash configurations and Rendering Logstash configurations, you can use this module to create, parse, update and render Logstash pipelines. Here is an example where lscl is used to add an add_field operation on an existing pipeline:
from lscl.lang import LsclAttribute, LsclBlock
from lscl.parser import parse_lscl
from lscl.renderer import render_as_lscl
SOURCE = """
input {
stdin { }
}
filter {
dissect {
mapping => {
"message" => "[%{ts}] %{message}"
}
}
}
output {
elasticsearch { codec => rubydebug }
}
"""
content = parse_lscl(SOURCE)
# Find the 'filter' block at top level.
# If the block is not found, create it.
for el in content:
if isinstance(el, LsclBlock) and el.name == "filter":
break
else:
el = LsclBlock(name="filter")
content.append(el)
# Add the add_field filter.
el.content.append(
LsclBlock(
name="mutate",
content=[
LsclAttribute(name="add_field", content={"mytag": "myvalue"}),
],
)
)
print(render_as_lscl(content), end="")
The script will output the following:
input {
stdin {}
}
filter {
dissect {
mapping => {
message => "[%{ts}] %{message}"
}
}
mutate {
add_field => {
mytag => myvalue
}
}
}
output {
elasticsearch {
codec => rubydebug
}
}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lscl-0.5.tar.gz.
File metadata
- Download URL: lscl-0.5.tar.gz
- Upload date:
- Size: 24.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a85c2ad19dcdc694458783091f7da76ef37d0d11d5862d4af9bed907c75cf276
|
|
| MD5 |
8fdd0672354383fccd64f407595676e9
|
|
| BLAKE2b-256 |
7459c0ce5d4d21afea3cdbdb7a1f6ac0ee9d47d06630be7f84233cd2fd638aef
|
File details
Details for the file lscl-0.5-py3-none-any.whl.
File metadata
- Download URL: lscl-0.5-py3-none-any.whl
- Upload date:
- Size: 28.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f711d052f98dcdb0c6fcd776761191e19c91a25cdbc7de5893f8e45311a3f5b8
|
|
| MD5 |
fac8ff601894f75689f28269bd5b22b0
|
|
| BLAKE2b-256 |
a0414e0324103945a8ef033f7adb12077df22539d5b2e5358b33cd12d0533d93
|