Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var GenDocs = &cobra.Command{ Use: "docs", Short: "Automatically generate documentation for the CLI.", Run: func(cmd *cobra.Command, args []string) { err := doc.GenMarkdownTree(rootCmd, "./docs") if err != nil { log.Fatal(err) } header := &doc.GenManHeader{ Title: "Splunk GO", Section: "1", } err = doc.GenManTree(rootCmd, header, "./docs/manual") if err != nil { log.Fatal(err) } }, }
GenDocs is used to generate documentation for the CLI
View Source
var LoginCmd = &cobra.Command{ Use: "login", Short: "Authenticate to Splunk and return a session token.", Run: func(cmd *cobra.Command, args []string) { conn := splunk.Connection{ Username: viper.GetString("SPLUNK_USERNAME"), Password: viper.GetString("SPLUNK_PASSWORD"), BaseURL: viper.GetString("SPLUNK_URL"), } key, err := conn.Login() if err != nil { log.Fatal(au.Red("Couldn't login to Splunk. Ensure your configuration is correct.")) } fmt.Println("Logged in Successfully. \nSession key:", au.BrightBlue(key.Value)) }, }
LoginCmd is used to authenticate to Splunk
View Source
var SearchCmd = &cobra.Command{ Use: "search [string or filepath]", Short: "Search Splunk for events.", Long: `The search command is used to perform search queries via the Splunk REST API. Searching splunk using the CLI requires one argument of a SPL file containing your search. e.g. splunk-go search ~/.splunk-go/searches/my-search.spl `, Run: func(cmd *cobra.Command, args []string) { conn := splunk.Connection{ Username: viper.GetString("SPLUNK_USERNAME"), Password: viper.GetString("SPLUNK_PASSWORD"), BaseURL: viper.GetString("SPLUNK_URL"), } if interactive == true { file := splunk.SearchInteractive() content, err := ioutil.ReadFile(file) if err != nil { log.Fatal(err) } result := searchString(string(content), mode, conn) fmt.Println(result) } else { internal.Help(cmd, args) content, err := ioutil.ReadFile(args[0]) if err != nil { log.Fatal(err) } result := searchString(string(content), mode, conn) fmt.Println(result) } }, }
SearchCmd is used to search splunk events
View Source
var SystemCmd = &cobra.Command{ Use: "system", Short: "Perform operations on the Splunk server.", Run: func(cmd *cobra.Command, args []string) { internal.Help(cmd, args) }, }
SystemCmd represents the system command
Functions ¶
Types ¶
This section is empty.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.