Skip to main content

Splunk search client

Project description

Build Status Coverage Status

Search Splunk

Easily create Splunk searches from Python and get the result as a Python object

Requires

Installation instructions

Searchsplunk can be installed from PyPi.

pip install searchsplunk

Usage instructions

from searchsplunk.searchsplunk import SearchSplunk
s = SearchSplunk('https://splunk.acme.com:8089', 'MYUSER', 'MYPASS', ssl_verify=True)
result = s.search('sourcetype=salt:grains openstack_uid=e0303456c-d5a3-789f-ab68-8f27561ffa0f | dedup openstack_uid')

import json
print json.dumps(result, sort_keys=True, indent=2)
{
  "fields": [
    {
      "name": "_bkt"
    },
    {
      "name": "_cd"
    },
    {
      "name": "_indextime"
    },
    {
      "name": "_kv"
    },
    {
      "name": "_raw"
    },
    {
      "name": "_serial"
    },
    {
      "name": "_si"
    },
    {
      "name": "_sourcetype"
    },
    {
      "name": "_subsecond"
    },
    {
      "name": "_time"
    },
    {
      "name": "host"
    },
    {
      "name": "index"
    },
    {
      "name": "linecount"
    },
    {
      "name": "openstack_uid"
    },
    {
      "name": "source"
    },
    {
      "name": "sourcetype"
    },
    {
      "name": "splunk_server"
    }
  ],
  "init_offset": 0,
  "messages": [],
  "preview": false,
  "results": [
    {
      "_bkt": "main~1122~25B521A6-9612-407D-A1BA-F8KJSEBB7628",
      "_cd": "1122:290410720",
      "_indextime": "1435071966",
      "_kv": "1",
      "_raw": "somefile contents",
      "_serial": "0",
      "_si": [
        "splunkserv",
        "main"
      ],
      "_sourcetype": "salt:grains",
      "_time": "2015-06-23T11:06:05.000-04:00",
      "host": "server-7654.acme.com",
      "index": "main",
      "linecount": "17",
      "openstack_uid": "e0303456c-d5a3-789f-ab68-8f27561ffa0f",
      "source": "/etc/salt/grains",
      "sourcetype": "salt:grains",
      "splunk_server": "splunkmaster"
    }
  ]
}

Contributors

Author

Ryan Currah

License

GPL v2

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

searchsplunk-0.3.1.tar.gz (4.1 kB view details)

Uploaded Source

File details

Details for the file searchsplunk-0.3.1.tar.gz.

File metadata

File hashes

Hashes for searchsplunk-0.3.1.tar.gz
Algorithm Hash digest
SHA256 2c36181b48b2211d6d0cd31836ed391d58d3720a7dca780d3f805d3020b3b681
MD5 6389475be873db52b1ee87cf84c3fd85
BLAKE2b-256 8ce509002754c95ddeac72c71bc98441291435479866f2d3c7998a1cfab0458e

See more details on using hashes here.

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