Skip to content

Commit ecf9398

Browse files
luckyj5heidmotron
andauthored
Merge v1.2.2 to master (#277)
* Convert NaN or Infinity value metrics to string (#271) * enable ignore app config (#274) * Update hec telemetry (#275) Co-authored-by: Matthew Heidemann <[email protected]>
1 parent 30027c9 commit ecf9398

File tree

9 files changed

+89
-16
lines changed

9 files changed

+89
-16
lines changed

.circleci/config.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ jobs:
99
- run:
1010
name: Install Dependencies
1111
command: |
12-
curl https://glide.sh/get | sh
13-
go get -t ./...
12+
go get -u -v -t github.com/Masterminds/glide
13+
glide install --strip-vendor
1414
- run:
1515
name: Builder
1616
command: make build
@@ -20,7 +20,7 @@ jobs:
2020
make testall
2121
cp splunk-firehose-nozzle /tmp
2222
- persist_to_workspace:
23-
root: /tmp
23+
root: /tmp
2424
paths:
2525
- splunk-firehose-nozzle
2626

@@ -35,8 +35,8 @@ jobs:
3535
- run:
3636
name: Install dependencies
3737
command: |
38-
curl https://glide.sh/get | sh
39-
go get -t ./...
38+
go get -u -v -t github.com/Masterminds/glide
39+
glide install --strip-vendor
4040
cp -R /tmp/splunk-firehose-nozzle .
4141
- run:
4242
name: Deploy nozzle
@@ -75,8 +75,8 @@ jobs:
7575
- run:
7676
name: Install dependencies
7777
command: |
78-
curl https://glide.sh/get | sh
79-
go get -t ./...
78+
go get -u -v -t github.com/Masterminds/glide
79+
glide install --strip-vendor
8080
cp -R /tmp/splunk-firehose-nozzle .
8181
- run:
8282
name: Deploy data-gen
@@ -127,5 +127,6 @@ workflows:
127127
filters:
128128
branches:
129129
only:
130+
- develop
130131
- master
131-
- release/v1.2.0
132+
- release/v1.2.2

.circleci/pre-req.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ make
66
wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add -
77
echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list
88
#Add support for https apt sources
9-
sudo apt-get install apt-transport-https ca-certificates
109
sudo apt-get update
10+
sudo apt-get install apt-transport-https ca-certificates
1111
sudo apt-get install cf-cli
1212
#CF Login
1313
cf login --skip-ssl-validation -a $API_ENDPOINT -u $API_USER -p $API_PASSWORD -o system -s system

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ In addition, logs from the nozzle itself are of sourcetype `cf:splunknozzle`.
1919

2020
### Setup
2121

22-
The Nozzle requires a client with the authorities `doppler.firehose` and `cloud_controller.admin_read_only` (the latter is only required if `ADD_APP_INFO` is true) and grant-types `client_credentials` and `refresh_token`. If `cloud_controller.admin_read_only` is not
22+
The Nozzle requires a client with the authorities `doppler.firehose` and `cloud_controller.admin_read_only` (the latter is only required if `ADD_APP_INFO` is enabled) and grant-types `client_credentials` and `refresh_token`. If `cloud_controller.admin_read_only` is not
2323
available in the system, switch to use `cloud_controller.admin`.
2424

2525
You can either
@@ -153,6 +153,10 @@ $ ./dump_app_info --skip-ssl-validation --api-endpoint=https://<your api endpoin
153153
After populating the application info cache file, user can copy to different Splunk nozzle deployments and start Splunk nozzle to pick up this cache file by
154154
specifying correct "--boltdb-path" flag or "BOLTDB_PATH" environment variable.
155155

156+
### Disable logging for noisy applications
157+
Set F2S_DISABLE_LOGGING = true as a environment variable in applications's manifest to disable logging.
158+
159+
156160
### Index routing
157161
Index routing is a feature that can be used to send different Cloud Foundry logs to different indexes for better ACL and data retention control in Splunk.
158162

@@ -333,7 +337,7 @@ A correct setup logs a start message with configuration parameters of the Nozzle
333337
skip-ssl: true
334338
splunk-host: http://localhost:8088
335339
splunk-index: atomic
336-
splunk-version: 6.6
340+
splunk-version: 8.1
337341
subscription-id: splunk-firehose
338342
trace-logging: true
339343
status-monitor-interval: 0s
@@ -417,7 +421,7 @@ $ chmod +x tools/nozzle.sh
417421
Build project:
418422
419423
```
420-
$ make VERSION=1.2.0
424+
$ make VERSION=1.2.2
421425
```
422426
423427
Run tests with [Ginkgo](http://onsi.github.io/ginkgo/)

eventrouter/eventrouter_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,15 @@ var _ = Describe("eventrouter", func() {
138138
Expect(len(memSink.Messages)).To(Equal(0))
139139
})
140140

141+
It("Route ignore app", func() {
142+
noCache.SetIgnoreApp(true)
143+
eventType = events.Envelope_LogMessage
144+
err := r.Route(msg)
145+
Ω(err).ShouldNot(HaveOccurred())
146+
Expect(len(memSink.Events)).To(Equal(0))
147+
Expect(len(memSink.Messages)).To(Equal(0))
148+
})
149+
141150
It("Route sink error", func() {
142151
memSink.ReturnErr = true
143152
eventType = events.Envelope_LogMessage

events/events.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package events
33
import (
44
"encoding/json"
55
"fmt"
6+
"math"
67
"sort"
78
"strings"
89

@@ -121,11 +122,21 @@ func LogMessage(msg *events.Envelope) *Event {
121122

122123
func ValueMetric(msg *events.Envelope) *Event {
123124
valMetric := msg.GetValueMetric()
125+
value := valMetric.GetValue()
124126

125127
fields := logrus.Fields{
126128
"name": valMetric.GetName(),
127129
"unit": valMetric.GetUnit(),
128-
"value": valMetric.GetValue(),
130+
"value": value,
131+
}
132+
133+
// Convert special values
134+
if math.IsNaN(value) {
135+
fields["value"] = "NaN"
136+
} else if math.IsInf(value, 1) {
137+
fields["value"] = "Infinity"
138+
} else if math.IsInf(value, -1) {
139+
fields["value"] = "-Infinity"
129140
}
130141

131142
return &Event{
@@ -199,6 +210,7 @@ func (e *Event) AnnotateWithAppData(appCache cache.Cache, config *Config) {
199210
cf_space_name := appInfo.SpaceName
200211
cf_org_id := appInfo.OrgGuid
201212
cf_org_name := appInfo.OrgName
213+
cf_ignored_app := appInfo.IgnoredApp
202214
app_env := appInfo.CfAppEnv
203215

204216
if cf_app_name != "" && config.AddAppName {
@@ -224,6 +236,11 @@ func (e *Event) AnnotateWithAppData(appCache cache.Cache, config *Config) {
224236
if app_env["SPLUNK_INDEX"] != nil {
225237
e.Fields["info_splunk_index"] = app_env["SPLUNK_INDEX"]
226238
}
239+
240+
if cf_ignored_app != false {
241+
e.Fields["cf_ignored_app"] = cf_ignored_app
242+
}
243+
227244
}
228245
}
229246

events/events_test.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package events_test
22

33
import (
4+
"math"
5+
46
fevents "github.com/cloudfoundry-community/splunk-firehose-nozzle/events"
57
"github.com/cloudfoundry-community/splunk-firehose-nozzle/testing"
68
. "github.com/cloudfoundry/sonde-go/events"
@@ -88,6 +90,45 @@ var _ = Describe("Events", func() {
8890
Expect(evt.Fields["unit"]).To(Equal(unit))
8991
})
9092

93+
It("ValueMetric NaN", func() {
94+
msg = NewValueMetric()
95+
nan := math.NaN()
96+
msg.ValueMetric.Value = &nan
97+
evt := fevents.ValueMetric(msg)
98+
Expect(evt).ToNot(BeNil())
99+
Expect(evt.Fields).ToNot(BeNil())
100+
Expect(evt.Msg).To(Equal(""))
101+
Expect(evt.Fields["name"]).To(Equal(name))
102+
Expect(evt.Fields["value"]).To(Equal("NaN"))
103+
Expect(evt.Fields["unit"]).To(Equal(unit))
104+
})
105+
106+
It("ValueMetric +Infinity", func() {
107+
msg = NewValueMetric()
108+
inf := math.Inf(1)
109+
msg.ValueMetric.Value = &inf
110+
evt := fevents.ValueMetric(msg)
111+
Expect(evt).ToNot(BeNil())
112+
Expect(evt.Fields).ToNot(BeNil())
113+
Expect(evt.Msg).To(Equal(""))
114+
Expect(evt.Fields["name"]).To(Equal(name))
115+
Expect(evt.Fields["value"]).To(Equal("Infinity"))
116+
Expect(evt.Fields["unit"]).To(Equal(unit))
117+
})
118+
119+
It("ValueMetric -Infinity", func() {
120+
msg = NewValueMetric()
121+
inf := math.Inf(-1)
122+
msg.ValueMetric.Value = &inf
123+
evt := fevents.ValueMetric(msg)
124+
Expect(evt).ToNot(BeNil())
125+
Expect(evt.Fields).ToNot(BeNil())
126+
Expect(evt.Msg).To(Equal(""))
127+
Expect(evt.Fields["name"]).To(Equal(name))
128+
Expect(evt.Fields["value"]).To(Equal("-Infinity"))
129+
Expect(evt.Fields["unit"]).To(Equal(unit))
130+
})
131+
91132
It("CounterEvent", func() {
92133
msg = NewCounterEvent()
93134
evt := fevents.CounterEvent(msg)

eventwriter/splunk.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func (s *splunkClient) send(postBody *[]byte) error {
8787
//Add app headers for HEC telemetry
8888
//Todo: update static values with appName and appVersion variables
8989
req.Header.Set("__splunk_app_name", "Splunk Firehose Nozzle")
90-
req.Header.Set("__splunk_app_version", "1.2.0")
90+
req.Header.Set("__splunk_app_version", "1.2.2")
9191

9292
resp, err := s.httpClient.Do(req)
9393
if err != nil {

eventwriter/splunk_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ var _ = Describe("Splunk", func() {
104104
})
105105

106106
It("sets app appVersion", func() {
107-
appVersion := "1.2.0"
107+
appVersion := "1.2.2"
108108

109109
client := NewSplunk(config)
110110
events := []map[string]interface{}{}

tile/tile-history.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ history:
88
- 1.1.1
99
- 1.1.2
1010
- 1.2.0
11-
version: 1.2.1
11+
- 1.2.1
12+
version: 1.2.2

0 commit comments

Comments
 (0)