Skip to content

Low level lib to create an http Request object for connecting to Splunk.

Notifications You must be signed in to change notification settings

scottso/splunking

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Splunk Request

Build Status GoDoc

Low level lib to create an http Request object for connecting to Splunk.

Usage

import (
    "fmt"

    "github.com/jmervine/splunking"
)

func main() {
    // Load configs from environment
    //  SPLUNK_USERNAME=username
    //  SPLUNK_PASSWORD=password
    //  SPLUNK_HOST=splunk.example.com
    //  SPLUNK_PORT=8089        // default
    //  SPLUNK_PROTO=https      // default
    //  SPLUNK_OUTPUT_TYPE=json // default
    client, err := splunking.Init()
    if err != nil {
        panic(err)
    }

    // Or load from URL - same defaults as above apply
    client, err = splunking.InitURL("https://username:password@splunk.example.com:8089?output_type=json")
    if err != nil {
        panic(err)
    }

    // Basic request
    resp, err := client.Get("/api/path", nil)
    if err != nil {
        panic(err)
    }

    fmt.Printf("%+v\n", resp)

    // Advanced request handling
    req, err := client.Request("GET", "/api/path", nil)
    if err != nil {
        panic(err)
    }

    // ... do stuff with request

    resp, err = client.Submit(req)
    if err != nil {
        panic(err)
    }

    fmt.Printf("%+v\n", resp)
}

About

Low level lib to create an http Request object for connecting to Splunk.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 98.0%
  • Makefile 2.0%