Skip to main content

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

lscl-0.5.tar.gz (24.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lscl-0.5-py3-none-any.whl (28.9 kB view details)

Uploaded Python 3

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

Hashes for lscl-0.5.tar.gz
Algorithm Hash digest
SHA256 a85c2ad19dcdc694458783091f7da76ef37d0d11d5862d4af9bed907c75cf276
MD5 8fdd0672354383fccd64f407595676e9
BLAKE2b-256 7459c0ce5d4d21afea3cdbdb7a1f6ac0ee9d47d06630be7f84233cd2fd638aef

See more details on using hashes here.

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

Hashes for lscl-0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 f711d052f98dcdb0c6fcd776761191e19c91a25cdbc7de5893f8e45311a3f5b8
MD5 fac8ff601894f75689f28269bd5b22b0
BLAKE2b-256 a0414e0324103945a8ef033f7adb12077df22539d5b2e5358b33cd12d0533d93

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page