Skip to content

Commit

Permalink
Merge v1.2.2 to master (#277)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
luckyj5 and heidmotron authored May 5, 2021
1 parent 30027c9 commit ecf9398
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 16 deletions.
17 changes: 9 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ jobs:
- run:
name: Install Dependencies
command: |
curl https://glide.sh/get | sh
go get -t ./...
go get -u -v -t github.com/Masterminds/glide
glide install --strip-vendor
- run:
name: Builder
command: make build
Expand All @@ -20,7 +20,7 @@ jobs:
make testall
cp splunk-firehose-nozzle /tmp
- persist_to_workspace:
root: /tmp
root: /tmp
paths:
- splunk-firehose-nozzle

Expand All @@ -35,8 +35,8 @@ jobs:
- run:
name: Install dependencies
command: |
curl https://glide.sh/get | sh
go get -t ./...
go get -u -v -t github.com/Masterminds/glide
glide install --strip-vendor
cp -R /tmp/splunk-firehose-nozzle .
- run:
name: Deploy nozzle
Expand Down Expand Up @@ -75,8 +75,8 @@ jobs:
- run:
name: Install dependencies
command: |
curl https://glide.sh/get | sh
go get -t ./...
go get -u -v -t github.com/Masterminds/glide
glide install --strip-vendor
cp -R /tmp/splunk-firehose-nozzle .
- run:
name: Deploy data-gen
Expand Down Expand Up @@ -127,5 +127,6 @@ workflows:
filters:
branches:
only:
- develop
- master
- release/v1.2.0
- release/v1.2.2
2 changes: 1 addition & 1 deletion .circleci/pre-req.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ make
wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add -
echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list
#Add support for https apt sources
sudo apt-get install apt-transport-https ca-certificates
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates
sudo apt-get install cf-cli
#CF Login
cf login --skip-ssl-validation -a $API_ENDPOINT -u $API_USER -p $API_PASSWORD -o system -s system
Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ In addition, logs from the nozzle itself are of sourcetype `cf:splunknozzle`.

### Setup

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
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
available in the system, switch to use `cloud_controller.admin`.

You can either
Expand Down Expand Up @@ -153,6 +153,10 @@ $ ./dump_app_info --skip-ssl-validation --api-endpoint=https://<your api endpoin
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
specifying correct "--boltdb-path" flag or "BOLTDB_PATH" environment variable.

### Disable logging for noisy applications
Set F2S_DISABLE_LOGGING = true as a environment variable in applications's manifest to disable logging.


### Index routing
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.

Expand Down Expand Up @@ -333,7 +337,7 @@ A correct setup logs a start message with configuration parameters of the Nozzle
skip-ssl: true
splunk-host: http://localhost:8088
splunk-index: atomic
splunk-version: 6.6
splunk-version: 8.1
subscription-id: splunk-firehose
trace-logging: true
status-monitor-interval: 0s
Expand Down Expand Up @@ -417,7 +421,7 @@ $ chmod +x tools/nozzle.sh
Build project:
```
$ make VERSION=1.2.0
$ make VERSION=1.2.2
```
Run tests with [Ginkgo](http://onsi.github.io/ginkgo/)
Expand Down
9 changes: 9 additions & 0 deletions eventrouter/eventrouter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,15 @@ var _ = Describe("eventrouter", func() {
Expect(len(memSink.Messages)).To(Equal(0))
})

It("Route ignore app", func() {
noCache.SetIgnoreApp(true)
eventType = events.Envelope_LogMessage
err := r.Route(msg)
Ω(err).ShouldNot(HaveOccurred())
Expect(len(memSink.Events)).To(Equal(0))
Expect(len(memSink.Messages)).To(Equal(0))
})

It("Route sink error", func() {
memSink.ReturnErr = true
eventType = events.Envelope_LogMessage
Expand Down
19 changes: 18 additions & 1 deletion events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package events
import (
"encoding/json"
"fmt"
"math"
"sort"
"strings"

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

func ValueMetric(msg *events.Envelope) *Event {
valMetric := msg.GetValueMetric()
value := valMetric.GetValue()

fields := logrus.Fields{
"name": valMetric.GetName(),
"unit": valMetric.GetUnit(),
"value": valMetric.GetValue(),
"value": value,
}

// Convert special values
if math.IsNaN(value) {
fields["value"] = "NaN"
} else if math.IsInf(value, 1) {
fields["value"] = "Infinity"
} else if math.IsInf(value, -1) {
fields["value"] = "-Infinity"
}

return &Event{
Expand Down Expand Up @@ -199,6 +210,7 @@ func (e *Event) AnnotateWithAppData(appCache cache.Cache, config *Config) {
cf_space_name := appInfo.SpaceName
cf_org_id := appInfo.OrgGuid
cf_org_name := appInfo.OrgName
cf_ignored_app := appInfo.IgnoredApp
app_env := appInfo.CfAppEnv

if cf_app_name != "" && config.AddAppName {
Expand All @@ -224,6 +236,11 @@ func (e *Event) AnnotateWithAppData(appCache cache.Cache, config *Config) {
if app_env["SPLUNK_INDEX"] != nil {
e.Fields["info_splunk_index"] = app_env["SPLUNK_INDEX"]
}

if cf_ignored_app != false {
e.Fields["cf_ignored_app"] = cf_ignored_app
}

}
}

Expand Down
41 changes: 41 additions & 0 deletions events/events_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package events_test

import (
"math"

fevents "github.com/cloudfoundry-community/splunk-firehose-nozzle/events"
"github.com/cloudfoundry-community/splunk-firehose-nozzle/testing"
. "github.com/cloudfoundry/sonde-go/events"
Expand Down Expand Up @@ -88,6 +90,45 @@ var _ = Describe("Events", func() {
Expect(evt.Fields["unit"]).To(Equal(unit))
})

It("ValueMetric NaN", func() {
msg = NewValueMetric()
nan := math.NaN()
msg.ValueMetric.Value = &nan
evt := fevents.ValueMetric(msg)
Expect(evt).ToNot(BeNil())
Expect(evt.Fields).ToNot(BeNil())
Expect(evt.Msg).To(Equal(""))
Expect(evt.Fields["name"]).To(Equal(name))
Expect(evt.Fields["value"]).To(Equal("NaN"))
Expect(evt.Fields["unit"]).To(Equal(unit))
})

It("ValueMetric +Infinity", func() {
msg = NewValueMetric()
inf := math.Inf(1)
msg.ValueMetric.Value = &inf
evt := fevents.ValueMetric(msg)
Expect(evt).ToNot(BeNil())
Expect(evt.Fields).ToNot(BeNil())
Expect(evt.Msg).To(Equal(""))
Expect(evt.Fields["name"]).To(Equal(name))
Expect(evt.Fields["value"]).To(Equal("Infinity"))
Expect(evt.Fields["unit"]).To(Equal(unit))
})

It("ValueMetric -Infinity", func() {
msg = NewValueMetric()
inf := math.Inf(-1)
msg.ValueMetric.Value = &inf
evt := fevents.ValueMetric(msg)
Expect(evt).ToNot(BeNil())
Expect(evt.Fields).ToNot(BeNil())
Expect(evt.Msg).To(Equal(""))
Expect(evt.Fields["name"]).To(Equal(name))
Expect(evt.Fields["value"]).To(Equal("-Infinity"))
Expect(evt.Fields["unit"]).To(Equal(unit))
})

It("CounterEvent", func() {
msg = NewCounterEvent()
evt := fevents.CounterEvent(msg)
Expand Down
2 changes: 1 addition & 1 deletion eventwriter/splunk.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (s *splunkClient) send(postBody *[]byte) error {
//Add app headers for HEC telemetry
//Todo: update static values with appName and appVersion variables
req.Header.Set("__splunk_app_name", "Splunk Firehose Nozzle")
req.Header.Set("__splunk_app_version", "1.2.0")
req.Header.Set("__splunk_app_version", "1.2.2")

resp, err := s.httpClient.Do(req)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion eventwriter/splunk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ var _ = Describe("Splunk", func() {
})

It("sets app appVersion", func() {
appVersion := "1.2.0"
appVersion := "1.2.2"

client := NewSplunk(config)
events := []map[string]interface{}{}
Expand Down
3 changes: 2 additions & 1 deletion tile/tile-history.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ history:
- 1.1.1
- 1.1.2
- 1.2.0
version: 1.2.1
- 1.2.1
version: 1.2.2

0 comments on commit ecf9398

Please sign in to comment.