{"id":4707,"library":"pylogbeat","title":"Pylogbeat","description":"PyLogBeat is a simple, incomplete implementation of the Beats protocol used by Elastic Beats and Logstash. It enables reliable data transfer by having the server acknowledge received data, allowing the client to know whether and what to resend. The library is actively maintained, with a recent major release (2.1.0) in late 2025, and continues to support modern Python environments.","status":"active","version":"2.1.0","language":"en","source_language":"en","source_url":"https://github.com/eht16/pylogbeat/","tags":["logging","logstash","beats","elastic","protocol","observability"],"install":[{"cmd":"pip install pylogbeat","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"symbol":"PyLogBeatClient","correct":"from pylogbeat import PyLogBeatClient"}],"quickstart":{"code":"import os\nfrom datetime import datetime\nfrom pylogbeat import PyLogBeatClient\n\n# Configure connection details (replace with your Logstash/Beats input host and port)\nHOST = os.environ.get('LOGSTASH_HOST', 'localhost')\nPORT = int(os.environ.get('LOGSTASH_PORT', 5959))\n\n# Example message in Logstash format\nmessage = {\n    '@timestamp': datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%S.%fZ'),\n    '@version': '1',\n    'message': 'hello world from pylogbeat',\n    'level': 'INFO',\n    'host': 'my-python-app'\n}\n\ntry:\n    with PyLogBeatClient(HOST, PORT, ssl_enable=False) as client:\n        client.send([message])\n        print(f\"Sent message to {HOST}:{PORT}\")\nexcept Exception as e:\n    print(f\"Failed to send message: {e}\")","lang":"python","description":"This quickstart demonstrates how to send a single log message to a Logstash or Beats input plugin using `PyLogBeatClient`. It utilizes a context manager for automatic connection and disconnection, and shows a basic message structure. Remember to set `LOGSTASH_HOST` and `LOGSTASH_PORT` environment variables or update the default values."},"warnings":[{"fix":"Upgrade Python to 3.11 or newer, or pin `pylogbeat` to a version compatible with your Python environment (e.g., `<2.0.0` for Python 2.x, `<2.1.0` for Python 3.6-3.10).","message":"Version 2.1.0 dropped support for Python versions older than 3.11. If you are on an older Python version, you must upgrade Python or stick to `pylogbeat < 2.1.0`.","severity":"breaking","affected_versions":">=2.1.0"},{"fix":"Ensure your project is running on Python 3 and that any dependencies on `six` are handled elsewhere if necessary. If still on Python 2, use `pylogbeat < 2.0.0`.","message":"The `six` compatibility library dependency was removed in version 2.0.0. This makes `pylogbeat` a Python 3-only library from this version onwards.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Ensure your Logstash instance is version `5.6.12` or higher, or `6.4.0` or higher.","message":"Due to a known bug (logstash-plugins/logstash-input-beats#342), Logstash requires specific versions to correctly receive data from `pylogbeat`.","severity":"gotcha","affected_versions":"*"},{"fix":"Set `use_logging=False` if `pylogbeat` is acting as a transport for a logging handler to prevent infinite logging loops or issues during logging subsystem shutdown.","message":"The `PyLogBeatClient` constructor's `use_logging` argument defaults to `False`. If `pylogbeat` is used as part of your logging system, setting `use_logging=True` might lead to recursive logging issues during shutdown.","severity":"gotcha","affected_versions":"*"},{"fix":"Be aware that not all advanced or edge-case features of the Beats protocol might be fully supported. Test thoroughly if your use case relies on complex Beats protocol behaviors.","message":"The implemented Beats protocol in `pylogbeat` is described as 'incomplete' as the protocol itself is not yet officially specified. While core functionality like sending data and awaiting ACK is present, some details might be missing.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}