You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: splunk/splunk.go
+17-6Lines changed: 17 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,7 @@ import (
5
5
"crypto/tls"
6
6
"encoding/json"
7
7
"errors"
8
+
"fmt"
8
9
"io"
9
10
"io/ioutil"
10
11
"net/http"
@@ -14,14 +15,24 @@ import (
14
15
15
16
// Event represents the log event object that is sent to Splunk when Client.Log is called.
16
17
typeEventstruct {
17
-
Timeint64`json:"time"`// epoch time in seconds
18
+
TimeEventTime`json:"time"`// when the event happened
18
19
Hoststring`json:"host"`// hostname
19
20
Sourcestring`json:"source,omitempty"`// optional description of the source of the event; typically the app's name
20
21
SourceTypestring`json:"sourcetype,omitempty"`// optional name of a Splunk parsing configuration; this is usually inferred by Splunk
21
22
Indexstring`json:"index,omitempty"`// optional name of the Splunk index to store the event in; not required if the token has a default index set in Splunk
22
23
Eventinterface{} `json:"event"`// throw any useful key/val pairs here
23
24
}
24
25
26
+
// EventTime marshals timestamps using the Splunk HTTP Event Collector's default format.
27
+
typeEventTimestruct {
28
+
time.Time
29
+
}
30
+
31
+
func (tEventTime) MarshalJSON() ([]byte, error) {
32
+
// The milliseconds are truncated, not rounded to nearest; eg. 12:00:00.5008274 will be logged as 12:00:00.500.
0 commit comments