splunk

package
v1.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2024 License: Apache-2.0, Apache-2.0 Imports: 13 Imported by: 0

README

Splunk REST API Client

Example Usage:

package main

import (
    "fmt"
    "github.com/drewrm/splunk"
)

func main() {
    conn := splunk.SplunkConnection {
            Username: "admin",
            Password: "changeme",
            BaseURL: "https://localhost:8089",
    }

    key, err:= conn.Login()

    if err != nil {
            fmt.Println("Couldn't login to splunk: %s", err)
    }

    fmt.Println("Session key: ", key.Value)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message struct {
	Name    string         `json:"name"`
	Content MessageContent `json:"content"`
}

type MessageContent

type MessageContent struct {
	Message  string          `json:"message"`
	Severity MessageSeverity `json:"severity"`
	// contains filtered or unexported fields
}

func (*MessageContent) Content

func (mc *MessageContent) Content() time.Time

type MessageSeverity

type MessageSeverity string
const (
	Info  MessageSeverity = "info"
	Warn  MessageSeverity = "warn"
	Error MessageSeverity = "error"
)

type Messages

type Messages struct {
	Origin   string    `json:"origin"`
	Messages []Message `json:"entry"`
}

type Row

type Row struct {
	Preview bool             `json:"preview"`
	Offset  int              `json:"offset"`
	Result  map[string]Value `json:"result"`
	LastRow bool             `json:"lastrow"`
}

func NewRow

func NewRow() (ret Row)

type Rows

type Rows []Row

type SessionKey

type SessionKey struct {
	Value string `json:"sessionKey"`
}

SessionKey represents the JSON object returned from the Splunk authentication REST call

type SplunkConnection

type SplunkConnection struct {
	Username, Password, BaseURL, SplunkUser, SplunkApp string
	BearerToken                                        string

	HttpClient *http.Client
	// contains filtered or unexported fields
}

func (SplunkConnection) GetMessage

func (conn SplunkConnection) GetMessage(name string) ([]Message, error)

func (SplunkConnection) HasSessionKey

func (conn SplunkConnection) HasSessionKey() bool

func (SplunkConnection) InstallApp

func (conn SplunkConnection) InstallApp(path string, update bool) (string, error)

func (SplunkConnection) Login

func (conn SplunkConnection) Login() (key SessionKey, err error)

Login connects to the Splunk server and retrieves a session key

func (SplunkConnection) RestartServer

func (conn SplunkConnection) RestartServer() (string, error)

func (SplunkConnection) Search

func (conn SplunkConnection) Search(ctx context.Context, boPolicy backoff.Policy, searchString string, params ...map[string]string) (rows []Row, events []string, err error)

func (SplunkConnection) SearchStream

func (conn SplunkConnection) SearchStream(searchString string, params ...map[string]string) (events chan *Row, err error)

func (SplunkConnection) SendMessage

func (conn SplunkConnection) SendMessage(message *Message) (string, error)

SendMessage sends an informational message to Splunk

type Value

type Value interface{}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL