Skip to main content

Library for sending events to Splunk HEC

Project description

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.

Project details


Release history Release notifications | RSS feed

This version

0.4

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

splunkhecwriter-0.4.tar.gz (3.1 kB view hashes)

Uploaded Source

Built Distribution

splunkhecwriter-0.4-py3-none-any.whl (7.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page