splunk

package module
v0.0.0-...-3535631 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2019 License: Apache-2.0 Imports: 10 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: ", 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 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 string
	// contains filtered or unexported fields
}

func CreateConnectionFromEnvironment

func CreateConnectionFromEnvironment() (*SplunkConnection, error)

func (SplunkConnection) GetMessage

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

func (SplunkConnection) InstallApp

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

func (SplunkConnection) Login

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

Login connects to the Splunk server and retrieves a session key

func (SplunkConnection) RestartServer

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

func (SplunkConnection) SearchSync

func (conn SplunkConnection) SearchSync(searchString string) (string, error)

func (SplunkConnection) SendMessage

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

SendMessage sends an informational message to Splunk

Jump to

Keyboard shortcuts

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