A simple and complete package to abstract main operations with Splunk API (send data / run search / get result)
Project description
easy_slpunk>
A simple and complete package to abstract main operations with Splunk API (send data / run searches).
Install
pip install easy_splunk
Upgrade
pip install easy_splunk -U
Usage
from easy_splunk import Splunk
host = "EVENT_HOST"
source = "EVENT_SOURCE"
try:
spk_hec = Splunk(protocol="https", url="10.0.0.2", port="8088", timeout=60,
hec_key="e51e9c62-5f25-46cf-9a4e-218638cdab77")
spk_syslog = Splunk(protocol="syslog", url="10.0.0.2", port="5514")
except:
raise
#Send a dict data as JSON to Splunk API
data_hec = {}
data_hec["Key_1"] = "Valor_1"
data_hec["Key_2"] = "Valor_2"
data_hec["Key_3"] = "Valor_3"
spk_hec.send_data(event_host=host, event_source=source, event_data=data_hec)
spk_hec.send_data(event_source=source, event_data=data_hec)
#Send a basic syslog message to Splunk
data_syslog = "Syslog message sent by easy_splunk"
spk_syslog.send_data(event_data=data_syslog)
#Run a specific search and get the result as a list of JSONs
search = 'index=raw_syslog | head 1'
search_output = spk_hec.run_search(username='admin', password='admin', search=search)
print(search_output)
OUTPUTS SEND_DATA()
OUTPUT RUN_SEARCH()
[
{
'preview': False,
'offset': 0,
'result':
{
'_bkt': 'raw_syslog~0~1C4DDDBB-BFC8-49A2-A2FC-6418F3E80CAD',
'_cd': '0:56',
'_indextime': '1561619057',
'_raw': 'Syslog message sent by easy_splunk',
'_serial': '0',
'_si': ['localhost', 'raw_syslog'],
'_sourcetype': 'syslog',
'_time': '2019-06-27 15:04:17.000 CST',
'host': '10.0.0.2',
'index': 'raw_syslog',
'linecount': '1',
'source': 'udp:5514',
'sourcetype': 'syslog',
'splunk_server': 'localhost'
}
}
]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
easy_splunk-0.2.0.tar.gz
(4.0 kB
view details)
Built Distribution
File details
Details for the file easy_splunk-0.2.0.tar.gz
.
File metadata
- Download URL: easy_splunk-0.2.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b263c03cefb78d12d2fdec11d24248fe490dc42c787a695363c1806844bac365 |
|
MD5 | 5a047c99c2ebf18c6ed00353070e7aff |
|
BLAKE2b-256 | 18bb24d0143c4d0a0709bf0845fd719f0e2840c7fd3fe31ddbd45b7a04ed7d00 |
File details
Details for the file easy_splunk-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: easy_splunk-0.2.0-py3-none-any.whl
- Upload date:
- Size: 16.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ee1025c6d6989605f9dec6638b1bae62deebe32619f0b49db64e441410b91eb |
|
MD5 | ea3eab6e5701fcc8e1e369876d22cd8c |
|
BLAKE2b-256 | b76e2663c487fe4eaa3725177204863ebb77b4588932f80fc0ea2b4551beb72a |