splunk

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

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

Go to latest
Published: May 16, 2025 License: MIT Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Splunk Library

To Do

  • Storage Collection
    • KV Store
    • CSV
  • HEC Event

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidHost   = errors.New("invalid host")
	ErrInvalidAuth   = errors.New("invalid username or password")
	ErrClientNotInit = errors.New("Splunk client not init")
	ErrJobNotDone    = errors.New("Splunk Job not done")
)
View Source
var (
	Search = &search{}
)
View Source
var (
	Searches = &searches{}
)
View Source
var (
	Storage = &storage{
		KV: &kv{owner: "nobody", app: "search"},
	}
)

Functions

func AuthCheck

func AuthCheck() bool

func Event

func Event(req *EventReq) error

func Init

func Init(ctx context.Context, cfg *Config) error

func RawEvent

func RawEvent(req any) error

func RawEvents

func RawEvents(req any) error

func SetContext

func SetContext(ctx context.Context)

func SetDebug

func SetDebug(b bool)

func SetLogger

func SetLogger(l *slog.Logger)

Types

type Config

type Config struct {
	Host     string      `json:"host" yaml:"host" mapstructure:"host"`
	Username string      `json:"username" yaml:"username" mapstructure:"username"`
	Password string      `json:"password" yaml:"password" mapstructure:"password"`
	Event    EventConfig `json:"event" yaml:"event" mapstructure:"event"`
}

type EventClient

type EventClient struct {
	// contains filtered or unexported fields
}

func InitEvent

func InitEvent(cfg *EventConfig) *EventClient

func NewEventClient

func NewEventClient(host, token string) *EventClient

func (*EventClient) Debug

func (ec *EventClient) Debug(v bool) *EventClient

func (*EventClient) Headers

func (ec *EventClient) Headers(v map[string]string) *EventClient

func (*EventClient) Index

func (ec *EventClient) Index(v string) *EventClient

func (*EventClient) Send

func (ec *EventClient) Send(req *EventReq) error

func (*EventClient) Source

func (ec *EventClient) Source(v string) *EventClient

type EventConfig

type EventConfig struct {
	Host   string `json:"host" yaml:"host" mapstructure:"host"`
	Index  string `json:"index" yaml:"index" mapstructure:"index"`
	Source string `json:"source" yaml:"source" mapstructure:"source"`
	Token  string `json:"token" yaml:"token" mapstructure:"token"`
}

type EventReq

type EventReq struct {
	Timestamp_   int64  `json:"timestamp"`
	Name_        string `json:"name,omitempty"`
	Description_ string `json:"description,omitempty"`
	App_         string `json:"app,omitempty"`
	Label_       string `json:"label,omitempty"`
	Events_      []any  `json:"events,omitempty"`
	Event_       any    `json:"event,omitempty"`
}

func NewEventReq

func NewEventReq() *EventReq

func (*EventReq) App

func (e *EventReq) App(v string) *EventReq

func (*EventReq) Description

func (e *EventReq) Description(v string) *EventReq

func (*EventReq) Event

func (e *EventReq) Event(v any) *EventReq

func (*EventReq) Events

func (e *EventReq) Events(v any) *EventReq

func (*EventReq) Label

func (e *EventReq) Label(v string) *EventReq

func (*EventReq) Name

func (e *EventReq) Name(v string) *EventReq

type JobStatus

type JobStatus struct {
	Entry []struct {
		Content JobStatusEntryCount `json:"content"`
	} `json:"entry"`
}

type JobStatusEntryCount

type JobStatusEntryCount struct {
	IsDone      bool  `json:"isDone"`
	DiskUsage   int64 `json:"diskUsage"`
	ResultCount int64 `json:"resultCount"`
}

type OutputMode

type OutputMode string
const (
	OutputModeCSV  OutputMode = "csv"
	OutputModeJSON OutputMode = "json"
)

type QueryResults

type QueryResults []map[string]string

type QueryRsp

type QueryRsp struct {
	Results QueryResults `json:"results"`
}

type QuerySid

type QuerySid struct {
	Sid string `json:"sid"`
}

type SearchRsp

type SearchRsp struct {
	Updated time.Time      `json:"updated"`
	Entry   []SearchesItem `json:"entry"`
	Paging  struct {
		Total int `json:"total"`
	} `json:"paging"`
}

type SearchesItem

type SearchesItem struct {
	Name    string    `json:"name"`
	Updated time.Time `json:"updated"`
	Author  string    `json:"author"`
	Content struct {
		SplunkHecTarget  string `json:"action.forward_alert_to_splunk_hec.param.splunk_hec_target"`
		ActionWebhookURL string `json:"action.webhook.param.url"`
		Actions          string `json:"actions"`
		CronSchedule     string `json:"cron_schedule"`
		Disabled         bool   `json:"disabled"`
		IsScheduled      bool   `json:"is_scheduled"`
		Search           string `json:"search"`
	} `json:"content"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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