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
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
edb04ffb2bf27a80996718dcf7543d8e93f6fbe490ee00feb02e13fd8407d756
|
|
| MD5 |
a3dfe5c42ef90778a10117322e57c9c5
|
|
| BLAKE2b-256 |
15c641829e5e0db0ba527d6f8ebabf5533b507447b7e95f84dab9a579306840f
|
Provenance
The following attestation bundles were made for hass_splunk-0.1.4.tar.gz:
Publisher:
publish.yml on Bre77/hass_splunk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hass_splunk-0.1.4.tar.gz -
Subject digest:
edb04ffb2bf27a80996718dcf7543d8e93f6fbe490ee00feb02e13fd8407d756 - Sigstore transparency entry: 946330230
- Sigstore integration time:
-
Permalink:
Bre77/hass_splunk@8939233a22d05e676ea4c0a9c9d8f013f11dbe14 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/Bre77
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8939233a22d05e676ea4c0a9c9d8f013f11dbe14 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7caf5785d7a3788dc5b307c922df09e00c0f2daf72c420c50ac1e7030064916c
|
|
| MD5 |
6666cfcd6faebfa248be7f0078d47c2a
|
|
| BLAKE2b-256 |
e17d0169a82f09df0406f907ed5d784d4f3f1a3581a93b07f75cd85cd4cd313f
|
Provenance
The following attestation bundles were made for hass_splunk-0.1.4-py3-none-any.whl:
Publisher:
publish.yml on Bre77/hass_splunk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hass_splunk-0.1.4-py3-none-any.whl -
Subject digest:
7caf5785d7a3788dc5b307c922df09e00c0f2daf72c420c50ac1e7030064916c - Sigstore transparency entry: 946330272
- Sigstore integration time:
-
Permalink:
Bre77/hass_splunk@8939233a22d05e676ea4c0a9c9d8f013f11dbe14 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/Bre77
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8939233a22d05e676ea4c0a9c9d8f013f11dbe14 -
Trigger Event:
release
-
Statement type: