{"id":21595010,"url":"https://github.com/thomas-touhey/lscl","last_synced_at":"2025-03-18T10:43:51.271Z","repository":{"id":245347657,"uuid":"816023096","full_name":"thomas-touhey/lscl","owner":"thomas-touhey","description":"Logstash configuration language handling. (Gitlab.com mirror)","archived":false,"fork":false,"pushed_at":"2025-02-04T10:56:21.000Z","size":207,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-02-04T11:32:05.153Z","etag":null,"topics":["logstash","parser","python"],"latest_commit_sha":null,"homepage":"https://lscl.touhey.pro/","language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thomas-touhey.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.txt","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-16T21:05:02.000Z","updated_at":"2025-02-04T10:56:24.000Z","dependencies_parsed_at":"2024-06-21T16:26:15.431Z","dependency_job_id":"f6b0314d-db41-4771-984d-0081c4bead7a","html_url":"https://github.com/thomas-touhey/lscl","commit_stats":null,"previous_names":["thomas-touhey/lscl"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomas-touhey%2Flscl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomas-touhey%2Flscl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomas-touhey%2Flscl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomas-touhey%2Flscl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thomas-touhey","download_url":"https://codeload.github.com/thomas-touhey/lscl/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244207477,"owners_count":20416097,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["logstash","parser","python"],"created_at":"2024-11-24T17:24:34.425Z","updated_at":"2025-03-18T10:43:51.264Z","avatar_url":"https://github.com/thomas-touhey.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"lscl -- Logstash configuration language handling\n================================================\n\nlscl is a Python module for parsing and rendering Logstash_ configurations\nin its own language, named LSCL for \"LogStash Configuration Language\".\n\nThe project is present at the following locations:\n\n* `Official website and documentation at\n  lscl.touhey.pro \u003clscl website_\u003e`_;\n* `lscl repository on Gitlab \u003clscl on Gitlab_\u003e`_;\n* `lscl project on PyPI \u003clscl on PyPI_\u003e`_.\n\nAs described in `Reading Logstash configurations`_ and `Rendering\nLogstash configurations`_, you can use this module to create, parse, update\nand render Logstash pipelines. Here is an example where lscl is used to add\nan ``add_field`` operation on an existing pipeline:\n\n.. code-block:: python\n\n    from lscl.lang import LsclAttribute, LsclBlock\n    from lscl.parser import parse_lscl\n    from lscl.renderer import render_as_lscl\n\n\n    SOURCE = \"\"\"\n    input {\n        stdin { }\n    }\n    filter {\n        dissect {\n            mapping =\u003e {\n                \"message\" =\u003e \"[%{ts}] %{message}\"\n            }\n        }\n    }\n    output {\n        elasticsearch { codec =\u003e rubydebug }\n    }\n    \"\"\"\n\n    content = parse_lscl(SOURCE)\n\n    # Find the 'filter' block at top level.\n    # If the block is not found, create it.\n    for el in content:\n        if isinstance(el, LsclBlock) and el.name == \"filter\":\n            break\n    else:\n        el = LsclBlock(name=\"filter\")\n        content.append(el)\n\n    # Add the add_field filter.\n    el.content.append(\n        LsclBlock(\n            name=\"mutate\",\n            content=[\n                LsclAttribute(name=\"add_field\", content={\"mytag\": \"myvalue\"}),\n            ],\n        )\n    )\n\n    print(render_as_lscl(content), end=\"\")\n\nThe script will output the following:\n\n.. code-block:: text\n\n    input {\n      stdin {}\n    }\n    filter {\n      dissect {\n        mapping =\u003e {\n          message =\u003e \"[%{ts}] %{message}\"\n        }\n      }\n      mutate {\n        add_field =\u003e {\n          mytag =\u003e myvalue\n        }\n      }\n    }\n    output {\n      elasticsearch {\n        codec =\u003e rubydebug\n      }\n    }\n\n.. _Logstash: https://www.elastic.co/fr/logstash\n.. _lscl website: https://lscl.touhey.pro/\n.. _lscl on Gitlab: https://gitlab.com/kaquel/lscl\n.. _lscl on PyPI: https://pypi.org/project/lscl\n.. _Reading Logstash configurations:\n    https://lscl.touhey.pro/developer-guides/read.html\n.. _Rendering Logstash configurations:\n    https://lscl.touhey.pro/developer-guides/render.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomas-touhey%2Flscl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthomas-touhey%2Flscl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomas-touhey%2Flscl/lists"}