Skip to main content

Async single threaded connector to Splunk HEC using an asyncio session

Project description

Splunk HEC for Home Assistant

A Splunk HTTP Event Collector library that follows best practices by opening a single connection to Splunk, and reuses it. When sending large or high volumes of events, or Splunk is slow, the events are batched together. This also allows events to be resent in the case of failures, as they are simply returned to the queue.

Requires you create an aiohttp Client Session, or reuse your applications existing one. From Home Assistant this would be homeassistant.helpers.aiohttp_client.async_get_clientsession

Methods

hass_splunk(session,token,host,port=8088,use_ssl=True,verify_ssl=True,endpoint="collector/event",timeout=5)

Session, token, and host are required, all other parameters are optional, and will be set to defaults shown.

check(connectivity=True, token=True, busy=True)

Returns True if the parameter conditions are okay, False if any fail or any other error is raised. You can selectively ignore certain conditions by setting them to False.

queue(payload, send=True)

The String or Dictionary to be sent to Splunk. By default it will be sent as soon as possible, but you can instead set send=False and it only be queued.

send()

The sends whatever data is in the queue, is what queue() uses internally when send=True.

Example

import asyncio
import aiohttp
import time
from hass_splunk import hass_splunk


async def main():
    async with aiohttp.ClientSession() as session:
        splunk = hass_splunk(
            session=session,
            host="http-inputs-stack.splunkcloud.com",
            use_ssl=True,
            verify_ssl=True,
            token="private",
        )
        print(await splunk.check(connectivity=True, token=True, busy=True))
        await splunk.queue(
            {
                "time": time.time(),
                "host": "name",
                "event": {
                    "meta": "TEST",
                },
            },
            send=False,
        )
        await splunk.send()

asyncio.run(main())

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

hass_splunk-0.1.4.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

hass_splunk-0.1.4-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file hass_splunk-0.1.4.tar.gz.

File metadata

  • Download URL: hass_splunk-0.1.4.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for hass_splunk-0.1.4.tar.gz
Algorithm Hash digest
SHA256 edb04ffb2bf27a80996718dcf7543d8e93f6fbe490ee00feb02e13fd8407d756
MD5 a3dfe5c42ef90778a10117322e57c9c5
BLAKE2b-256 15c641829e5e0db0ba527d6f8ebabf5533b507447b7e95f84dab9a579306840f

See more details on using hashes here.

Provenance

The following attestation bundles were made for hass_splunk-0.1.4.tar.gz:

Publisher: publish.yml on Bre77/hass_splunk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hass_splunk-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: hass_splunk-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for hass_splunk-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 7caf5785d7a3788dc5b307c922df09e00c0f2daf72c420c50ac1e7030064916c
MD5 6666cfcd6faebfa248be7f0078d47c2a
BLAKE2b-256 e17d0169a82f09df0406f907ed5d784d4f3f1a3581a93b07f75cd85cd4cd313f

See more details on using hashes here.

Provenance

The following attestation bundles were made for hass_splunk-0.1.4-py3-none-any.whl:

Publisher: publish.yml on Bre77/hass_splunk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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