File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -85,13 +85,16 @@ func (s *splunkClient) send(postBody *[]byte) error {
85
85
req .Header .Set ("Content-Type" , "application/json" )
86
86
req .Header .Set ("Connection" , "keep-alive" )
87
87
req .Header .Set ("Authorization" , fmt .Sprintf ("Splunk %s" , s .config .Token ))
88
+ //Add app headers for HEC telemetry
89
+ //Todo: update static values with appName and appVersion variables
90
+ req .Header .Set ("__splunk_app_name" , "Splunk Firehose Nozzle" )
91
+ req .Header .Set ("__splunk_app_version" , "2.0.0" )
88
92
89
93
resp , err := s .httpClient .Do (req )
90
94
if err != nil {
91
95
return err
92
96
}
93
97
defer resp .Body .Close ()
94
-
95
98
if resp .StatusCode > 299 {
96
99
responseBody , _ := ioutil .ReadAll (resp .Body )
97
100
return errors .New (fmt .Sprintf ("Non-ok response code [%d] from splunk: %s" , resp .StatusCode , responseBody ))
Original file line number Diff line number Diff line change @@ -88,6 +88,36 @@ var _ = Describe("Splunk", func() {
88
88
Expect (contentType ).To (Equal ("application/json" ))
89
89
})
90
90
91
+ It ("sets app name to appName" , func () {
92
+ appName := "Splunk Firehose Nozzle"
93
+
94
+ client := NewSplunk (config )
95
+ events := []map [string ]interface {}{}
96
+ err , _ := client .Write (events )
97
+
98
+ Expect (err ).To (BeNil ())
99
+ Expect (capturedRequest ).NotTo (BeNil ())
100
+
101
+ applicationName := capturedRequest .Header .Get ("__splunk_app_name" )
102
+ Expect (applicationName ).To (Equal (appName ))
103
+
104
+ })
105
+
106
+ It ("sets app appVersion" , func () {
107
+ appVersion := "2.0.0"
108
+
109
+ client := NewSplunk (config )
110
+ events := []map [string ]interface {}{}
111
+ err , _ := client .Write (events )
112
+
113
+ Expect (err ).To (BeNil ())
114
+ Expect (capturedRequest ).NotTo (BeNil ())
115
+
116
+ applicationVersion := capturedRequest .Header .Get ("__splunk_app_version" )
117
+ Expect (applicationVersion ).To (Equal (appVersion ))
118
+
119
+ })
120
+
91
121
It ("Writes batch event json" , func () {
92
122
client := NewSplunk (config )
93
123
event1 := map [string ]interface {}{"event" : map [string ]interface {}{
You can’t perform that action at this time.
0 commit comments