/splunkhecwriter

Python library for sending events to Splunk HEC (Http Event Collector)

Primary LanguagePythonApache License 2.0Apache-2.0

PyPI - Python Version PyPI GitHub GitHub issues GitHub last commit PyPI - Downloads

splunkhecwriter

Library for sending log events to Splunk

Example Code block 1

  from splunkhecwriter import SplunkHECWriter
  hec_token = '<HEC-TOKEN-HERE>'
  splunk_server = '127.0.0.1'

  hec_writer = SplunkHECWriter(splunk_host=splunk_server, splunk_hec_token=hec_token)

  msg =  { 'foo': 'bar' }
  hec_writer.send_msg(msg=msg)

Example Code block 2

  from splunkhecwriter import SplunkHECWriter
  hec_token = '<HEC-TOKEN-HERE>'
  splunk_server = '127.0.0.1'

  hec_writer = SplunkHECWriter(splunk_host=splunk_server, splunk_hec_token=hec_token)

  msgs = []
  msgs.append({ 'foo': 'bar' })
  msgs.append({ 'bar': 'foo'})
  hec_writer.send_msgs(msgs=msgs)

Example Code block 3

  from splunkhecwriter import SplunkHECWriter
  hec_token = '<HEC-TOKEN-HERE>'
  splunk_server = '127.0.0.1'
  sourcetype= 'foobar:json'
  source = 'hec'
  host = 'foobar'

  hec_writer = SplunkHECWriter(
    splunk_host=splunk_server,
    splunk_hec_token=hec_token,
    sourcetype=sourcetype,
    source=source,
    host=host)

  msg =  { 'foo': 'bar' }
  hec_writer.send_msg(msg=msg)

License

This project is licensed under the Apache License - see the LICENSE.md file for details

Disclaimer

This custom component is neither affiliated with nor endorsed by Splunk.