Skip to content

Commit 7bf692f

Browse files
author
Donald Tregonning
authored
Merge branch 'develop' into readme-updates
2 parents 8cf6d04 + 7b2421e commit 7bf692f

18 files changed

+467
-27
lines changed

.gitignore

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@
22

33
nozzle.sh
44

5-
scripts/*
6-
!scripts/*.template
7-
!scripts/*.go
5+
tools/*
6+
!tools/*.template
7+
!tools/*.go
88

99
cache.db
1010
*.out
1111

1212
main
1313
splunk-firehose-nozzle
14+
env.sh
15+
data_gen
1416

1517
manifest*.yml
1618
splunk-firehose-nozzle.iml

Makefile

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,17 @@ endif
1212
default: installdeps build
1313

1414
installdeps:
15-
glide --debug install --strip-vendor
15+
glide install --strip-vendor
1616

1717
updatedeps:
18-
glide --debug update
18+
glide update
1919

2020
initdeps:
21-
glide --debug create
21+
glide create
2222

23-
# -gcflags -N -l for debug
23+
# -gcflags '-N -l' for debug
2424
# -ldflags -w for prod
25-
#
26-
#
25+
2726
linux:
2827
GOOS=linux GOARCH=amd64 make
2928

@@ -33,7 +32,7 @@ mac:
3332
build-linux:
3433
GOOS=linux GOARCH=amd64 make build
3534

36-
build: build-nozzle build-app-dump
35+
build: build-nozzle build-app-dump build-data-gen
3736

3837
debug:
3938
DEBUG_FLAGS="-gcflags '-N -l'" make build
@@ -44,11 +43,22 @@ build-nozzle: fmt
4443
go build -o splunk-firehose-nozzle -ldflags ${LDFLAGS} ${DEBUG_FLAGS} ./main.go
4544

4645
build-app-dump:
47-
go build -o scripts/dump_app_info ./scripts/dump_app_info.go
46+
go build -o tools/dump_app_info/dump_app_info ./tools/dump_app_info/dump_app_info.go
47+
48+
build-data-gen:
49+
go build -o ci/data_gen/data_gen tools/data_gen/data_gen.go
50+
51+
PKGS=$(shell go list ./... | grep -v vendor | grep -v tools | grep -v testing | grep -v "splunk-firehose-nozzle$$")
52+
53+
deploy: deploy-nozzle deploy-data-gen
4854

55+
deploy-nozzle:
56+
@cf push -f ci/nozzle_manifest.yml -u process --random-route
4957

50-
PKGS=$(shell go list ./... | grep -v vendor | grep -v scripts | grep -v testing | grep -v "splunk-firehose-nozzle$$")
58+
deploy-data-gen:
59+
@cf push -f ci/data_gen_manifest.yml -u process -p tools/data_gen --random-route
5160

61+
integration-test: deploy-nozzle deploy-data-generation-app test
5262

5363
testall: test vet race cov
5464

README.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ __Cloud Foundry configuration parameters:__
5959

6060
__Splunk configuration parameters:__
6161
* `SPLUNK_TOKEN`: [Splunk HTTP event collector token](http://docs.splunk.com/Documentation/Splunk/latest/Data/UsetheHTTPEventCollector/).
62-
6362
* `SPLUNK_HOST`: Splunk HTTP event collector host. example: https://example.cloud.splunk.com:8088
6463
* `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.
6564

@@ -90,11 +89,11 @@ This is recommended for dev environments only.
9089
* `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.
9190

9291
- - - -
92+
9393
### Push as an App to Cloud Foundry
9494

9595
[splunk-firehose-nozzle-release](https://github.com/cloudfoundry-community/splunk-firehose-nozzle-release)
96-
packages this code into a
97-
[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
9897
Cloud Foundry as an application. See the **Setup** section for details
9998
on making a user and credentials.
10099

@@ -114,14 +113,13 @@ on making a user and credentials.
114113
1. Copy the manifest template and fill in needed values (using the credentials created during setup)
115114

116115
```shell
117-
cp manifest.yml.template manifest.yml
118-
vim manifest.yml
116+
vim ci/nozzle_manifest.yml
119117
```
120118

121119
1. Push the nozzle
122120

123121
```shell
124-
cf push
122+
make deploy-nozzle
125123
```
126124

127125
#### Dump application info to boltdb ####
@@ -135,7 +133,7 @@ Users can run this tool to generate a copy of all application meta data and copy
135133
Example of how to run the dump application info tool:
136134

137135
```
138-
$ cd scripts
136+
$ cd tools/dump_app_info
139137
$ go build dump_app_info.go
140138
$ ./dump_app_info --skip-ssl-validation --api-endpoint=https://<your api endpoint> --user=<api endpoint login username> --password=<api endpoint login password>
141139
```
@@ -232,11 +230,11 @@ $ make installdeps
232230
#### Environment
233231

234232
For development against [bosh-lite](https://github.com/cloudfoundry/bosh-lite),
235-
copy `scripts/nozzle.sh.template` to `scripts/nozzle.sh` and supply missing values:
233+
copy `tools/nozzle.sh.template` to `tools/nozzle.sh` and supply missing values:
236234

237235
```
238-
$ cp script/dev.sh.template scripts/nozzle.sh
239-
$ chmod +x scripts/nozzle.sh
236+
$ cp script/dev.sh.template tools/nozzle.sh
237+
$ chmod +x tools/nozzle.sh
240238
```
241239

242240
Build project:
@@ -269,7 +267,7 @@ Run app
269267

270268
```
271269
# this will run: go run main.go
272-
$ ./scripts/nozzle.sh
270+
$ ./tools/nozzle.sh
273271
```
274272

275273
#### CI

ci/Jenkinsfile

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
@Library('jenkinstools@master') _
2+
3+
import com.splunk.jenkins.DockerRequest;
4+
import com.splunk.tool.plugin.docker.extension.BadDockerExitCode;
5+
6+
def dockerReq = new DockerRequest(steps,
7+
currentBuild,
8+
env,
9+
[imageName: "repo.splunk.com/splunk/products/splact",
10+
userId: "10777",
11+
repoName: "https://github.com/cloudfoundry-community/splunk-firehose-nozzle.git",
12+
runner: "yarn",
13+
remotePath: "/build"])
14+
15+
16+
withSplunkWrapNode("master") {
17+
try {
18+
stage("run orca") {
19+
withCredentials([file(credentialsId: 'srv_releases_orca', variable: 'ORCA_CREDENTIALS')]) {
20+
sh "tar -ovxf $ORCA_CREDENTIALS";
21+
splunkPrepareAndCheckOut request: dockerReq,
22+
files: "${WORKSPACE}/.orca, ${WORKSPACE}/.ssh";
23+
}
24+
splunkRunScript request:dockerReq,
25+
script:
26+
"""
27+
pip install splunk_orca==0.7.5 -i https://repo.splunk.com/artifactory/api/pypi/pypi-virtual/simple
28+
cd ci
29+
30+
# Workaround to use 0.8.0
31+
# sed -i"" "s/^splunk_image_version = 0.7/splunk_image_version = 0.8/g" /build/.orca/orca.conf
32+
#sed -i"" "s/^splunk_ansible_version/#splunk_ansible_version/g" /build/.orca/orca.conf
33+
splunk_orca create --sc nozzle
34+
""";
35+
}
36+
}
37+
catch (BadDockerExitCode e) {
38+
currentBuild.result = "FAILURE";
39+
echo "Exception Caught: ${e.getMessage()}";
40+
echo "Stack Trace: ${e.printStackTrace()}";
41+
}
42+
catch (Exception e) {
43+
currentBuild.result = "FAILURE";
44+
echo "Exception Caught: ${e.getMessage()}";
45+
echo "Stack Trace: ${e.printStackTrace()}";
46+
}
47+
finally {
48+
steps.cleanWs();
49+
}
50+
}

ci/data_gen_manifest.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
applications:
3+
- name: data_gen
4+
memory: 128M
5+
instances: 2
6+
buildpack: go_buildpack
7+
cmd: data_gen
8+
env:
9+
GOPACKAGENAME: main
10+
EPS: 500
11+
TOTAL_EVENTS: 0

ci/nozzle_manifest.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
applications:
3+
- name: splunk-firehose-nozzle
4+
memory: 512M
5+
instances: 2
6+
buildpack: go_buildpack
7+
cmd: splunk-firehose-nozzle
8+
env:
9+
GOPACKAGENAME: main
10+
API_ENDPOINT:
11+
API_USER:
12+
API_PASSWORD:
13+
SPLUNK_HOST:
14+
SPLUNK_TOKEN:
15+
SPLUNK_INDEX:
16+
SKIP_SSL_VALIDATION_CF: true
17+
SKIP_SSL_VALIDATION_SPLUNK: true
18+
JOB_NAME: splunk-nozzle
19+
JOB_INDEX: -1
20+
JOB_HOST: localhost
21+
ADD_APP_INFO: true
22+
IGNORE_MISSING_APP: true
23+
MISSING_APP_CACHE_INVALIDATE_TTL: 3600s
24+
APP_CACHE_INVALIDATE_TTL: 86440s
25+
APP_LIMITS: 1000
26+
BOLTDB_PATH: cache.db
27+
EVENTS: ValueMetric,CounterEvent,Error,LogMessage,HttpStartStop,ContainerMetric
28+
EXTRA_FIELDS: longevity:testing,name:kchen
29+
FIREHOSE_SUBSCRIPTION_ID: splunk-firehose
30+
FLUSH_INTERVAL: 5s
31+
CONSUMER_QUEUE_SIZE: 10000
32+
HEC_BATCH_SIZE: 1000
33+
HEC_RETRIES: 5
34+
HEC_WORKERS: 8
35+
DEBUG: false
36+
ENABLE_EVENT_TRACING: true

ci/orca.conf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[nozzle]
2+
standalone = 1
3+
# search_heads = 1
4+
# indexers = 3
5+
# hec_load_balancers = 1
6+
log_token = 1CB57F19-DC23-419A-8EDA-BA545DD3674D
7+
# perf = true
8+
# memory = 8
9+
# cpu = 8
10+
services = services.yml

ci/perf.py

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
import subprocess
2+
import argparse
3+
import time
4+
5+
6+
nozzle_perf_params = [
7+
{"hec-workers": "1", "hec-batch-size": "100"},
8+
{"hec-workers": "2", "hec-batch-size": "100"},
9+
{"hec-workers": "4", "hec-batch-size": "100"},
10+
{"hec-workers": "8", "hec-batch-size": "100"},
11+
{"hec-workers": "16", "hec-batch-size": "100"},
12+
{"hec-workers": "32", "hec-batch-size": "100"},
13+
{"hec-workers": "1", "hec-batch-size": "1000"},
14+
{"hec-workers": "2", "hec-batch-size": "1000"},
15+
{"hec-workers": "4", "hec-batch-size": "1000"},
16+
{"hec-workers": "8", "hec-batch-size": "1000"},
17+
{"hec-workers": "16", "hec-batch-size": "1000"},
18+
{"hec-workers": "32", "hec-batch-size": "1000"},
19+
]
20+
21+
nozzle_perf_suites = [
22+
{
23+
"message-type": "s256byte",
24+
"extra-fields": "message_type:s256byte",
25+
"cases": nozzle_perf_params,
26+
},
27+
{
28+
"message-type": "s1kbyte",
29+
"extra-fields": "message_type:s1kbyte",
30+
"cases": nozzle_perf_params,
31+
},
32+
{
33+
"message-type": "uns256byte",
34+
"extra-fields": "message_type:uns256byte",
35+
"cases": nozzle_perf_params,
36+
},
37+
{
38+
"message-type": "uns1kbyte",
39+
"extra-fields": "message_type:uns1kbyte",
40+
"cases": nozzle_perf_params,
41+
},
42+
]
43+
44+
45+
def run_nozzle_perf(config):
46+
for suite in nozzle_perf_suites:
47+
for case in suite["cases"]:
48+
kvs = ",".join("{}:{}".format(k, v) for k, v in case.iteritems())
49+
extra_fields = "{},{}".format(suite["extra-fields"], kvs)
50+
cmd = [
51+
"./splunk-firehose-nozzle",
52+
"--api-endpoint", config["api-endpoint"],
53+
"--user", config["user"],
54+
"--password", config["password"],
55+
"--splunk-host", config["splunk-host"],
56+
"--splunk-token", config["splunk-token"],
57+
"--splunk-index", config["splunk-index"],
58+
"--hec-workers", case["hec-workers"],
59+
"--hec-batch-size", case["hec-batch-size"],
60+
"--events", "ContainerMetric,CounterEvent,Error,HttpStart,HttpStartStop,HttpStop,LogMessage,ValueMetric",
61+
"--extra-fields", extra_fields,
62+
"--add-app-info",
63+
"--enable-event-tracing",
64+
"--skip-ssl-validation-cf",
65+
"--skip-ssl-validation-splunk",
66+
]
67+
print " ".join(cmd)
68+
execute(cmd, config["duration"])
69+
70+
71+
def execute(cmd, duration):
72+
has_error = False
73+
while 1:
74+
try:
75+
start = time.time()
76+
print "start {} {}".format(" ".join(cmd), start)
77+
out, err = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
78+
except Exception as e:
79+
has_error = True
80+
print e
81+
else:
82+
has_error = False
83+
print "out:", out
84+
print "err:", err
85+
finally:
86+
end = time.time()
87+
last = end - start
88+
print "end {} {} duration={}".format(" ".join(cmd), end, last)
89+
90+
# If we run too short, rerun it
91+
if last < 0.8 * duration:
92+
print "run too short, retry..."
93+
time.sleep(1)
94+
elif has_error:
95+
pass
96+
else:
97+
break
98+
99+
100+
def run_trafficcontroller(duration):
101+
for suite in nozzle_perf_suites:
102+
for _ in suite["cases"]:
103+
cmd = [
104+
"./trafficcontroller",
105+
"--config", "loggregator_trafficcontroller.json",
106+
"--disableAccessControl",
107+
"--duration", str(duration),
108+
"--message-type", suite["message-type"],
109+
]
110+
111+
execute(cmd, duration)
112+
time.sleep(10)
113+
114+
115+
def main():
116+
parser = argparse.ArgumentParser(description="Nozzle perf test driver")
117+
parser.add_argument("--run", dest="run", required=True, help="nozzle or trafficcontroller")
118+
parser.add_argument("--duration", dest="duration", type=int, required=True, help="how long to run in seconds")
119+
args = parser.parse_args()
120+
121+
if args.run == "nozzle":
122+
config = {
123+
"api-endpoint": "http://ghost:9911",
124+
"user": "admin",
125+
"password": "admin",
126+
"splunk-host": "https://localhost:8088",
127+
"splunk-token": "1CB57F19-DC23-419A-8EDA-BA545DD3674D",
128+
"splunk-index": "main",
129+
"duration": args.duration,
130+
}
131+
run_nozzle_perf(config)
132+
else:
133+
run_trafficcontroller(args.duration)
134+
135+
136+
if __name__ == "__main__":
137+
main()

0 commit comments

Comments
 (0)