@@ -26,27 +26,61 @@ For example:
2626``` go
2727package main
2828
29- import (
30- " github.com/ZachtimusPrime/Go-Splunk-HTTP/splunk"
31- )
29+ import " github.com/ZachtimusPrime/Go-Splunk-HTTP/splunk"
3230
3331func main () {
3432
35- // Create new Splunk client
36- splunk := splunk.NewClient (
37- nil ,
38- " https://{your-splunk-URL}:8088/services/collector" ,
39- " {your-token}" ,
40- " {your-source}" ,
41- " {your-sourcetype}" ,
42- " {your-index}"
43- )
33+ // Create new Splunk client
34+ splunk := splunk.NewClient (
35+ nil ,
36+ " https://{your-splunk-URL}:8088/services/collector" ,
37+ " {your-token}" ,
38+ " {your-source}" ,
39+ " {your-sourcetype}" ,
40+ " {your-index}"
41+ )
4442
45- // Send a log event with the client
46- err := splunk.Log (interface {" msg" : " send key/val pairs or json objects here" , " msg2" : " anything that is useful to you in the log event" })
47- if err != nil {
48- return err
43+ // Use the client to send a log with time auto-generated by go host [ time.Now().Unix() ]
44+ err := splunk.Log (
45+ interface {" msg" : " send key/val pairs or json objects here" , " msg2" : " anything that is useful to you in the log event" }
46+ )
47+ if err != nil {
48+ return err
4949 }
50+
51+ // Use the client to send a log with time passed by source
52+ err = splunk.LogWithTime (
53+ 1514764800 ,
54+ interface {" msg" : " send key/val pairs or json objects here" , " msg2" : " anything that is useful to you in the log event" }
55+ )
56+ if err != nil {
57+ return err
58+ }
59+
60+ // Use the client to send a batch of log events
61+ var events []splunk.Event
62+ events = append (
63+ events,
64+ splunk.NewEvent (
65+ interface {" msg" : " event1" },
66+ " {desired-source}" ,
67+ " {desired-sourcetype}" ,
68+ " {desired-index}"
69+ )
70+ )
71+ events = append (
72+ events,
73+ splunk.NewEvent (
74+ interface {" msg" : " event2" },
75+ " {desired-source}" ,
76+ " {desired-sourcetype}" ,
77+ " {desired-index}"
78+ )
79+ )
80+ err = splunk.LogEvents (events)
81+ if err != nil {
82+ return err
83+ }
5084}
5185
5286```
0 commit comments