Skip to content

Commit 01bf4f1

Browse files
authored
Merge branch 'develop' into feature/ci-laste-orca
2 parents 642d560 + 49ab21f commit 01bf4f1

File tree

8 files changed

+275
-102
lines changed

8 files changed

+275
-102
lines changed

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
.idea
22

3-
tools/*
4-
!tools/*.template
5-
!tools/*.go
3+
tools/dump_app_info/dump_app_info
4+
tools/data_gen/data_gen
5+
66

77
cache.db
88
*.out

README.md

Lines changed: 43 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -47,108 +47,53 @@ uaac -t member add doppler.firehose splunk-nozzle
4747
`cloud_controller.admin_read_only` will work for cf v241
4848
or later. Earlier versions should use `cloud_controller.admin` instead.
4949

50-
51-
#### Environment Parameters (declare parameters by making a copy of tools/nozzle.sh.template)
52-
53-
DEBUG -
54-
Enable debug mode (forward to standard out instead of Splunk).
55-
56-
Cloud Foundry configuration parameters:
57-
API_ENDPOINT -
58-
Cloud Foundry API endpoint address.
59-
60-
API_USER -
61-
Cloud Foundry user name. (Must have scope described above)
62-
63-
API_PASSWORD -
64-
Cloud Foundry user password.
65-
66-
Splunk configuration parameters:
67-
SPLUNK_TOKEN -
68-
[Splunk HTTP event collector token](http://docs.splunk.com/Documentation/Splunk/latest/Data/UsetheHTTPEventCollector/).
69-
70-
SPLUNK_HOST -
71-
Splunk HTTP event collector host.
72-
example: https://example.cloud.splunk.com:8088
73-
74-
SPLUNK_INDEX -
75-
The Splunk index events will be sent to.
76-
Warning: Setting an invalid index will cause events to be lost.
77-
78-
JOB_NAME -
79-
Tag nozzle log events with job name.
80-
81-
JOB_INDEX -
82-
Tag nozzle log events with job index.
83-
84-
JOB_HOST -
85-
Tag nozzle log events with job host.
86-
87-
SKIP_SSL_VALIDATION_CF -
88-
Skip SSL certificate validation for connection to CF. Secure communications will not check SSL certificates against a trusted CA Authority.
89-
(recommended for dev environments only).
90-
91-
SKIP_SSL_VALIDATION_SPLUNK -
92-
Skip SSL certificate validation for connection to Splunk. Secure communications will not check SSL certificates against a trusted CA Authority.
93-
(recommended for dev environments only).
94-
95-
FIREHOSE_SUBSCRIPTION_ID -
96-
Tag nozzle events with a firehose subscription id. (More information on - https://docs.pivotal.io/pivotalcf/1-11/loggregator/log-ops-guide.html).
97-
98-
FIREHOSE_KEEP_ALIVE -
99-
Keep Alive duration for the firehose consumer.
100-
101-
ADD_APP_INFO -
102-
Enrich raw data with app details.
103-
104-
IGNORE_MISSING_APP -
105-
If application is missing, stop repeatedly querying application info from Cloud Foundry.
106-
107-
MISSING_APP_CACHE_INVALIDATE_TTL -
108-
How frequently the missing app info cache invalidates.
109-
110-
APP_CACHE_INVALIDATE_TTL -
111-
How frequently the app info local cache invalidates.
112-
113-
APP_LIMITS -
114-
Restrict to APP_LIMITS most updated apps per request when populating the app metadata cache.
115-
116-
BOLTDB_PATH -
117-
Bolt Database path.
118-
119-
EVENTS -
120-
Comma separated list of events to include.
121-
possible values: ValueMetric,CounterEvent,Error,LogMessage,HttpStartStop,ContainerMetric
122-
123-
EXTRA_FIELDS -
124-
Extra fields you want to annotate your events with (format is key:value,key:value).
125-
126-
FLUSH_INTERVAL -
127-
Time interval for flushing queue to Splunk regardless of CONSUMER_QUEUE_SIZE. Protects against stale events in low throughput systems.
128-
129-
CONSUMER_QUEUE_SIZE -
130-
Set the internal consumer queue buffer size. Events wil be pushed to Splunk after queue is full.
131-
132-
HEC_BATCH_SIZE -
133-
Set the batch size for the events to push to HEC (Splunk HTTP Event Collector).
134-
135-
HEC_RETRIES -
136-
Retry count for sending events to Splunk. After expiring events will begin dropping causing data loss.
137-
138-
HEC_WORKERS -
139-
Set the amount of Splunk HEC workers to increase concurrency while ingesting in Splunk.
140-
141-
SPLUNK_VERSION - Splunk version will determine how metadata fields are ingested for HEC.(example: 6.6).
142-
143-
ENABLE_EVENT_TRACING -
144-
Enable event trace logging. Splunk events will now contain a UUID, Splunk Nozzle Event Count and Subscription-ID
145-
for Splunk correlation searches.
50+
- - - -
51+
#### Environment Parameters
52+
You can declare parameters by making a copy of the scripts/nozzle.sh.template.
53+
* `DEBUG`: Enable debug mode (forward to standard out instead of Splunk).
54+
55+
__Cloud Foundry configuration parameters:__
56+
* `API_ENDPOINT`: Cloud Foundry API endpoint address.
57+
* `API_USER`: Cloud Foundry user name. (Must have scope described above)
58+
* `API_PASSWORD`: Cloud Foundry user password.
59+
60+
__Splunk configuration parameters:__
61+
* `SPLUNK_TOKEN`: [Splunk HTTP event collector token](http://docs.splunk.com/Documentation/Splunk/latest/Data/UsetheHTTPEventCollector/).
62+
* `SPLUNK_HOST`: Splunk HTTP event collector host. example: https://example.cloud.splunk.com:8088
63+
* `SPLUNK_INDEX`: The Splunk index events will be sent to. Warning: Setting an invalid index will cause events to be lost. This index must match one of the selected indexes for the Splunk HTTP event collector token used for the SPLUNK_TOKEN parameter.
64+
65+
__Advanced Configuration Features:__
66+
* `JOB_NAME`: Tags nozzle log events with job name.
67+
* `JOB_INDEX`: Tags nozzle log events with job index.
68+
* `JOB_HOST`: Tags nozzle log events with job host.
69+
* `SKIP_SSL_VALIDATION_CF`: Skips SSL certificate validation for connection to Cloud Foundry. Secure communications will not check SSL certificates against a trusted certificate authority.
70+
This is recommended for dev environments only.
71+
* `SKIP_SSL_VALIDATION_SPLUNK`: Skips SSL certificate validation for connection to Splunk. Secure communications will not check SSL certificates against a trusted certificate authority.
72+
This is recommended for dev environments only.
73+
* `FIREHOSE_SUBSCRIPTION_ID`: Tags nozzle events with a Firehose subscription id. See https://docs.pivotal.io/pivotalcf/1-11/loggregator/log-ops-guide.html.
74+
* `FIREHOSE_KEEP_ALIVE`: Keep alive duration for the Firehose consumer.
75+
* `ADD_APP_INFO`: Enriches raw data with app details.
76+
* `IGNORE_MISSING_APP`: If the application is missing, then stop repeatedly querying application info from Cloud Foundry.
77+
* `MISSING_APP_CACHE_INVALIDATE_TTL`: How frequently the missing app info cache invalidates.
78+
* `APP_CACHE_INVALIDATE_TTL`: How frequently the app info local cache invalidates.
79+
* `APP_LIMITS`: Restrict to APP_LIMITS the most updated apps per request when populating the app metadata cache.
80+
* `BOLTDB_PATH`: Bolt database path.
81+
* `EVENTS`: A comma separated list of events to include. Possible values: ValueMetric,CounterEvent,Error,LogMessage,HttpStartStop,ContainerMetric
82+
* `EXTRA_FIELDS`: Extra fields to annotate your events with (format is key:value,key:value).
83+
* `FLUSH_INTERVAL`: Time interval for flushing queue to Splunk regardless of CONSUMER_QUEUE_SIZE. Protects against stale events in low throughput systems.
84+
* `CONSUMER_QUEUE_SIZE`: Sets the internal consumer queue buffer size. Events will be pushed to Splunk after queue is full.
85+
* `HEC_BATCH_SIZE`: Set the batch size for the events to push to HEC (Splunk HTTP Event Collector).
86+
* `HEC_RETRIES`: Retry count for sending events to Splunk. After expiring, events will begin dropping causing data loss.
87+
* `HEC_WORKERS`: Set the amount of Splunk HEC workers to increase concurrency while ingesting in Splunk.
88+
* `SPLUNK_VERSION`: The Splunk version that determines how HEC ingests metadata fields. For example: 6.6.
89+
* `ENABLE_EVENT_TRACING`: Enables event trace logging. Splunk events will now contain a UUID, Splunk Nozzle Event Counts, and a Subscription-ID for Splunk correlation searches.
90+
91+
- - - -
14692

14793
### Push as an App to Cloud Foundry
14894

14995
[splunk-firehose-nozzle-release](https://github.com/cloudfoundry-community/splunk-firehose-nozzle-release)
150-
packages this code into a
151-
[BOSH](https://bosh.io) release for deployment. The code could also be run on
96+
packages this code into a [BOSH](https://bosh.io) release for deployment. The code could also be run on
15297
Cloud Foundry as an application. See the **Setup** section for details
15398
on making a user and credentials.
15499

events/events.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package events
22

33
import (
4+
"encoding/json"
45
"fmt"
56
"sort"
67
"strings"
@@ -235,13 +236,19 @@ func AuthorizedEvents() string {
235236
}
236237

237238
func ParseSelectedEvents(wantedEvents string) (map[string]bool, error) {
239+
wantedEvents = strings.TrimSpace(wantedEvents)
238240
selectedEvents := make(map[string]bool)
239241
if wantedEvents == "" {
240242
selectedEvents["LogMessage"] = true
241243
return selectedEvents, nil
242244
}
243245

244-
for _, event := range strings.Split(wantedEvents, ",") {
246+
var events []string
247+
if err := json.Unmarshal([]byte(wantedEvents), &events); err != nil {
248+
events = strings.Split(wantedEvents, ",")
249+
}
250+
251+
for _, event := range events {
245252
event = strings.TrimSpace(event)
246253
if IsAuthorizedEvent(event) {
247254
selectedEvents[event] = true

tile/build.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
if [ "$0" != "./build.sh" ]; then
6+
echo "build.sh should be run from within the tile directory"
7+
exit 1
8+
fi
9+
10+
echo "building go binary"
11+
pushd ..
12+
curdir=`pwd`
13+
go get github.com/cloudfoundry-community/splunk-firehose-nozzle
14+
cd $GOPATH/src/github.com/cloudfoundry-community/splunk-firehose-nozzle && git checkout master && env GOOS=linux GOARCH=amd64 make build VERSION=1.0.0
15+
cp $GOPATH/src/github.com/cloudfoundry-community/splunk-firehose-nozzle/splunk-firehose-nozzle ${curdir}/../splunk-firehose-nozzle/
16+
cd ${curdir}
17+
popd
18+
19+
echo "building tile"
20+
tile build

tile/icon.png

5.38 KB
Loading

tile/tile-history.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
history:
3+
- 0.2.1
4+
version: 1.0.0

tile/tile.yml

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
---
2+
name: splunk-nozzle
3+
label: Splunk Firehose Nozzle for PCF
4+
description: Forward firehose logs & metrics to Splunk
5+
icon_file: icon.png
6+
7+
apply_open_security_group: true # Apply open security group, default: false
8+
allow_paid_service_plans: true # Allow paid service plans, default: false
9+
10+
stemcell_criteria:
11+
os: ubuntu-trusty
12+
requires_cpi: false
13+
version: '3421'
14+
15+
properties:
16+
- name: author
17+
type: string
18+
label: Author
19+
value: Shubham Jain
20+
21+
forms:
22+
- name: splunk-config
23+
label: Splunk Settings
24+
description: Splunk HTTP Event Collector Settings
25+
markdown: |
26+
Configure your Splunk HTTP Event Collector. See http://docs.splunk.com/Documentation/Splunk/latest/Data/UsetheHTTPEventCollector
27+
properties:
28+
- name: splunk_host
29+
type: string
30+
label: HTTP Event Collector Endpoint URL
31+
description: HTTP Event Collector endpoint URL.
32+
- name: splunk_token
33+
type: secret
34+
label: HTTP Event Collector Token
35+
description: Splunk HTTP Event Collector token.
36+
- name: skip_ssl_validation_splunk
37+
type: boolean
38+
label: Skip SSL Validation
39+
default: false
40+
description: Skip SSL certificate validation for connection to Splunk. Secure communications will not check SSL certificates against a trusted Certificate Authority. Skipping SSL validation in production environment is not recommended.
41+
- name: splunk_index
42+
type: string
43+
label: Index
44+
description: The name of the Splunk index that events will be sent to. WARNING:Setting an invalid index will cause events to be lost.
45+
default: main
46+
47+
- name: cf-config
48+
label: Cloud Foundry Settings
49+
description: Cloud Foundry Connection Settings
50+
properties:
51+
- name: api_endpoint
52+
type: string
53+
label: API Endpoint
54+
description: Cloud Foundry API endpoint.
55+
- name: api_user
56+
type: string
57+
label: API User
58+
description: API username
59+
- name: api_password
60+
type: secret
61+
label: API Password
62+
description: Password for API user
63+
- name: skip_ssl_validation_cf
64+
type: boolean
65+
label: Skip SSL Validation
66+
default: false
67+
description: Skip SSL certificate validation for connection to Cloud Foundry. Secure communications will not check SSL certificates against a trusted Certificate Authority. Skipping SSL validation in production environment is not recommended.
68+
- name: events
69+
type: multi_select_options
70+
label: Event Types
71+
default: ['HttpStartStop', 'LogMessage', 'ValueMetric', 'CounterEvent', 'Error', 'ContainerMetric']
72+
options:
73+
- name: HttpStartStop
74+
label: HttpStartStop
75+
- name: LogMessage
76+
label: LogMessage
77+
- name: ValueMetric
78+
label: ValueMetric
79+
- name: CounterEvent
80+
81+
label: CounterEvent
82+
- name: Error
83+
label: Error
84+
- name: ContainerMetric
85+
label: ContainerMetric
86+
description: Event types to forward to Splunk.
87+
88+
- name: advanced
89+
label: Advanced
90+
description: Additional Nozzle Configuration
91+
properties:
92+
- name: scale_out_nozzle
93+
type: integer
94+
label: Scale Out Nozzle
95+
description: Scale out Splunk nozzle. Recommendation:Run 2 or more nozzles for high availability.
96+
default: 2
97+
- name: firehose_subscription_id
98+
type: string
99+
label: Firehose Subscription ID
100+
description: Unique subscription ID to nozzle. Firehose balances across socket connections with the same ID.
101+
optional: true
102+
- name: extra_fields
103+
type: string
104+
label: Additional Fields
105+
description: A set of user defined key:value pairs that are added to all Splunk events that do not occur in the event payload. Expected format - key1:value1, key2:value2, key3:value3
106+
optional: true
107+
- name: add_app_info
108+
type: boolean
109+
default: false
110+
label: Add App Information
111+
description: Enriches raw data with application metadata, such as application name, space name, org name, etc.
112+
- name: enable_event_tracing
113+
type: boolean
114+
label: Enable Event Tracing
115+
default: false
116+
description: Enables data loss tracing.
117+
118+
119+
packages:
120+
- name: splunk-firehose-nozzle
121+
type: app
122+
label: Splunk-Firehose-Nozzle
123+
manifest:
124+
memory: 256M
125+
instances: MY_INSTANCE_COUNT
126+
buildpack: binary_buildpack
127+
health-check-type: process
128+
no-route: true
129+
path: ../splunk-firehose-nozzle
130+
command: ./splunk-firehose-nozzle
131+
env:
132+
GOPACKAGENAME: main
133+
pre_deploy: |
134+
sed -i "s/MY_INSTANCE_COUNT/$SCALE_OUT_NOZZLE/g" $PACKAGE_PATH/splunk_firehose_nozzle/manifest.yml

0 commit comments

Comments
 (0)