Skip to content

Commit 1562fdb

Browse files
committed
Merged in feature/SCFF-44 (pull request #24)
Feature/SCFF-44
2 parents 0c24070 + 46bba9f commit 1562fdb

5 files changed

Lines changed: 364 additions & 86 deletions

File tree

README.md

Lines changed: 117 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,126 @@
1-
# README #
1+
# cloudfoundry-sumologic-nozzle
22

3-
This README would normally document whatever steps are necessary to get your application up and running.
3+
This Nozzle aggregates all the events from the _Firehose_ feature in Cloud Foundry towards Sumo Logic
44

5-
### What is this repository for? ###
5+
### Options of use
66

7-
* Quick summary
8-
* Version
9-
* [Learn Markdown](https://bitbucket.org/tutorials/markdowndemo)
7+
```
8+
usage: main [<flags>]
109
11-
### How do I get set up? ###
10+
Flags:
11+
--help Show context-sensitive help (also try --help-long and --help-man).
12+
--api-endpoint=API-ENDPOINT CF API Endpoint
13+
--sumo-endpoint=SUMO-ENDPOINT Sumo Logic Endpoint
14+
--subscription-id="firehose" Cloud Foundry ID for the subscription.
15+
--cloudfoundry-user=CLOUDFOUNDRY-USER
16+
Cloud Foundry User
17+
--cloudfoundry-password=CLOUDFOUNDRY-PASSWORD
18+
Cloud Foundry Password
19+
--events="LogMessage" Comma separated list of events you would like. Valid options are ContainerMetric,
20+
CounterEvent, Error, HttpStart, HttpStartStop, HttpStop, LogMessage, ValueMetric
21+
--nozzle-polling-period=15s Nozzle Polling Period
22+
--log-events-batch-size=200 Log Events Batch Size to send to Sumo
23+
--sumo-post-minimum-delay=200ms
24+
Sumo Logic HTTP Post Minimum Delay
25+
--sumo-category="" Sumo Logic Category
26+
--sumo-name="" Sumo Logic Name
27+
--sumo-host="" Sumo Logic Host
28+
--verbose-log-messages Allow Verbose Log Messages
29+
--custom-metadata="" Use this flag for addingCustom Metadata (key1:value1,key2:value2, etc...)
30+
--include-only-matching-filter=""
31+
Adds an 'Include only' filter to Events content (key1:value1,key2:value2, etc...)
32+
--exclude-always-matching-filter=""
33+
Adds an 'Exclude always' filter to Events content (key1:value1,key2:value2,
34+
etc...)
35+
--version Show application version.
36+
```
1237

13-
* Summary of set up
14-
* Configuration
15-
* Dependencies
16-
* Database configuration
17-
* How to run tests
18-
* Deployment instructions
1938

20-
### Contribution guidelines ###
39+
There are two ways to run this Nozzle:
2140

22-
* Writing tests
23-
* Code review
24-
* Other guidelines
41+
1. Run as standalone app
42+
2. Run as a tile in Pivotal Cloud Foundry
2543

26-
### Who do I talk to? ###
44+
### Run as standalone app
2745

28-
* Repo owner or admin
29-
* Other community or team contact
46+
```
47+
godep go run main.go --sumo-endpoint=https://sumo-endpoint --api-endpoint=https://api.endpoint --cloudfoundry-user=some_user --cloudfoundry-password=some_password --sumo-post-minimum-delay=200ms --custom-metadata=Key1:Value1,Key2:Value2,Key3:Value3 --log-events-batch-size=200 --events=LogMessage, ValueMetric --verbose-log-messages
48+
```
49+
50+
If everything goes right, you should see in your terminal the _Nozzle's Logs_ and, in the __Sumo Logic endpoint__ (defined in the _--sumo-endpoint_ flag) you should see the logs according the events you choose (_'LogMessage'_ and _'ValueMetric'_ with _verbose_ in this case).
51+
52+
53+
### Filtering Option
54+
55+
asked. It works this way:
56+
* case 1:
57+
Include-Only filter="" (Empty)
58+
Exclude-Always filter="" (Empty)
59+
in this case, all the events will be sent to Sumo Logic
60+
61+
* case 2:
62+
Include-Only filter="" (Empty)
63+
Exclude-Always filter= "source_type:other,origin:rep",
64+
in this case, all the events that contains a source-type:other field OR an origin:rep field will be not sent to Sumo Logic
65+
66+
* case 3:
67+
Include-Only filter="job:diego_cell,source_type:other"
68+
Exclude-Always filter="" (Empty)
69+
in this case, Only the events that contains a job:diego-cell field OR a source-type:other field will be sent to Sumo Logic
70+
71+
* case 4:
72+
Include-Only filter="job:diego_cell,source_type:other"
73+
Exclude-Always filter="source_type:other,origin:rep"
74+
75+
in this case, all the events that contains a job:diego-cell field OR a source-type:other field will be sent to Sumo Logic
76+
AND also
77+
all the events that contains a source-type:other field OR an origin:rep field will be not sent to Sumo Logic
78+
if an event share both filters (contains a Include-Only filter field and a Exclude-Always filter field), Only the *Include-Only filter will be considered*
79+
80+
The correct way of using those flags will be something like this:
81+
82+
```
83+
godep go run main.go --sumo-endpoint=https://sumo-endpoint --api-endpoint=https://api.endpoint --cloudfoundry-user=some_user --cloudfoundry-password=some_password --sumo-post-minimum-delay=200ms --log-events-batch-size=200 --events=LogMessage, ValueMetric --include-only-matching-filter=job:diego_cell,source_type:app --exclude-always-matching-filter=source_type:other,unit:count
84+
```
85+
86+
87+
### Run as a tile in Pivotal Cloud Foundry
88+
89+
**Pivotal Cloud Foundry** (PCF) has a Tile Generator tool which will help you to deploy this Nozzle in PCF allowing an easy configuration of it.
90+
91+
The tile configuration is handled in the 'tile.yml' file. (If you want to modify this file, is worth to mention that it is directly related to the Nozzle flags mentioned before).
92+
93+
#### Steps to run as this Nozzle as a tile in PCF:
94+
95+
##### Step 1 - Install the tile-generator python package
96+
97+
* Follow the Official Pivotal Instructions: http://docs.pivotal.io/tiledev/tile-generator.html#how-to
98+
(only until half of the _step 3_, DON'T DO 'tile init', only cd into the 'cloudfoundry-sumologic-nozzle' folder)
99+
100+
##### Step 2 - Check the tile file
101+
* If you want to add more settings to the tile or remove some. Check the Official Pivotal Documentation for more options http://docs.pivotal.io/tiledev/tile-generator.html#define
102+
103+
##### Step 3 - Prepare your code:
104+
* Zip your entire code and place the zip file into the root directory of the project for which you wish to create a tile. For this tile use this command: (you should do this in a new terminal window)
105+
106+
```
107+
zip -r sumo-logic-nozzle.zip bitbucket-pipelines.yml caching/ ci/ eventQueue/ eventRouting/ events/ firehoseclient/ glide.yaml glide.lock Godeps/ LICENSE logging/ main.go manifest.yml event.db Procfile sumoCFFirehose/ utils/ vendor/
108+
```
109+
##### Step 4 - Build tile file
110+
* go to the 'tile-generator' terminal window and run
111+
112+
```
113+
$ tile build
114+
```
115+
##### Step 4 - Install the tile in Pivotal Cloud Foundry
116+
* Login with proper credentials into the OPS Manager and import the .pivotal file created above and wait.
117+
* Then add it to the Installation Dashboard to configure it. You should able to configure the settings created in the tile file.
118+
* Update the changes and you should start to see some logs in the Sumo Logic Endpoint defined.
119+
120+
## Authors
121+
122+
mcplusa.com
123+
124+
## Related Sources
125+
126+
* Firehose-to-syslog Nozzle

main.go

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,22 @@ var (
2121
apiEndpoint = kingpin.Flag("api-endpoint", "CF API Endpoint").OverrideDefaultFromEnvar("API_ENDPOINT").String()
2222
sumoEndpoint = kingpin.Flag("sumo-endpoint", "Sumo Logic Endpoint").OverrideDefaultFromEnvar("SUMO_ENDPOINT").String()
2323
//dopplerEndpoint = kingpin.Flag("doppler-endpoint", "Overwrite default doppler endpoint return by /v2/info").OverrideDefaultFromEnvar("DOPPLER_ENDPOINT").String()
24-
subscriptionId = kingpin.Flag("subscription-id", "Cloud Foundry ID for the subscription.").Default("firehose").OverrideDefaultFromEnvar("FIREHOSE_SUBSCRIPTION_ID").String()
25-
user = kingpin.Flag("cloudfoundry-user", "Cloud Foundry User").OverrideDefaultFromEnvar("CLOUDFOUNDRY_USER").String() //user created in CF, authorized to connect the firehose
26-
password = kingpin.Flag("cloudfoundry-password", "Cloud Foundry Password").OverrideDefaultFromEnvar("CLOUDFOUNDRY_PASSWORD").String() // password created along with the firehose_user //kingpin.Flag("skip-ssl-validation", "Please don't").Default("false").OverrideDefaultFromEnvar("SKIP_SSL_VALIDATION").Bool()
27-
keepAlive, errK = time.ParseDuration("25s") //default Error, ContainerMetric, HttpStart, HttpStop, HttpStartStop, LogMessage, ValueMetric, CounterEvent
28-
wantedEvents = kingpin.Flag("events", fmt.Sprintf("Comma separated list of events you would like. Valid options are %s", eventRouting.GetListAuthorizedEventEvents())).Default("Error, ContainerMetric, HttpStart, HttpStop, HttpStartStop, LogMessage, ValueMetric, CounterEvent").OverrideDefaultFromEnvar("EVENTS").String()
29-
boltDatabasePath = "event.db"
30-
tickerTime = kingpin.Flag("nozzle-polling-period", "Nozzle Polling Period").Default("15s").OverrideDefaultFromEnvar("NOZZLE_POLLING_PERIOD").Duration()
31-
eventsBatchSize = kingpin.Flag("log-events-batch-size", "Log Events Batch Size").OverrideDefaultFromEnvar("LOG_EVENTS_BATCH_SIZE").Int()
32-
sumoPostMinimumDelay = kingpin.Flag("sumo-post-minimum-delay", "Sumo Logic HTTP Post Minimum Delay").OverrideDefaultFromEnvar("SUMO_POST_MINIMUM_DELAY").Duration()
33-
sumoCategory = kingpin.Flag("sumo-category", "Sumo Logic Category").Default("").OverrideDefaultFromEnvar("SUMO_CATEGORY").String()
34-
sumoName = kingpin.Flag("sumo-name", "Sumo Logic Name").Default("").OverrideDefaultFromEnvar("SUMO_NAME").String()
35-
sumoHost = kingpin.Flag("sumo-host", "Sumo Logic Host").Default("").OverrideDefaultFromEnvar("SUMO_HOST").String()
36-
verboseLogMessages = kingpin.Flag("verbose-log-messages", "Verbose Log Messages").Default("true").OverrideDefaultFromEnvar("VERBOSE_LOG_MESSAGES").Bool()
37-
customMetadata = kingpin.Flag("custom-metadata", "Custom Metadata").Default("").OverrideDefaultFromEnvar("CUSTOM_METADATA").String()
24+
subscriptionId = kingpin.Flag("subscription-id", "Cloud Foundry ID for the subscription.").Default("firehose").OverrideDefaultFromEnvar("FIREHOSE_SUBSCRIPTION_ID").String()
25+
user = kingpin.Flag("cloudfoundry-user", "Cloud Foundry User").OverrideDefaultFromEnvar("CLOUDFOUNDRY_USER").String() //user created in CF, authorized to connect the firehose
26+
password = kingpin.Flag("cloudfoundry-password", "Cloud Foundry Password").OverrideDefaultFromEnvar("CLOUDFOUNDRY_PASSWORD").String() // password created along with the firehose_user //kingpin.Flag("skip-ssl-validation", "Please don't").Default("false").OverrideDefaultFromEnvar("SKIP_SSL_VALIDATION").Bool()
27+
keepAlive, errK = time.ParseDuration("25s") //default Error, ContainerMetric, HttpStart, HttpStop, HttpStartStop, LogMessage, ValueMetric, CounterEvent
28+
wantedEvents = kingpin.Flag("events", fmt.Sprintf("Comma separated list of events you would like. Valid options are %s", eventRouting.GetListAuthorizedEventEvents())).Default("LogMessage").OverrideDefaultFromEnvar("EVENTS").String()
29+
boltDatabasePath = "event.db"
30+
tickerTime = kingpin.Flag("nozzle-polling-period", "Nozzle Polling Period").Default("15s").OverrideDefaultFromEnvar("NOZZLE_POLLING_PERIOD").Duration()
31+
eventsBatchSize = kingpin.Flag("log-events-batch-size", "Log Events Batch Size to send to Sumo").Default("200").OverrideDefaultFromEnvar("LOG_EVENTS_BATCH_SIZE").Int()
32+
sumoPostMinimumDelay = kingpin.Flag("sumo-post-minimum-delay", "Sumo Logic HTTP Post Minimum Delay").Default("200ms").OverrideDefaultFromEnvar("SUMO_POST_MINIMUM_DELAY").Duration()
33+
sumoCategory = kingpin.Flag("sumo-category", "Sumo Logic Category").Default("").OverrideDefaultFromEnvar("SUMO_CATEGORY").String()
34+
sumoName = kingpin.Flag("sumo-name", "Sumo Logic Name").Default("").OverrideDefaultFromEnvar("SUMO_NAME").String()
35+
sumoHost = kingpin.Flag("sumo-host", "Sumo Logic Host").Default("").OverrideDefaultFromEnvar("SUMO_HOST").String()
36+
verboseLogMessages = kingpin.Flag("verbose-log-messages", "Allow Verbose Log Messages").Default("false").OverrideDefaultFromEnvar("VERBOSE_LOG_MESSAGES").Bool()
37+
customMetadata = kingpin.Flag("custom-metadata", "Use this flag for addingCustom Metadata (key1:value1,key2:value2, etc...)").Default("").OverrideDefaultFromEnvar("CUSTOM_METADATA").String()
38+
includeOnlyMatchingFilter = kingpin.Flag("include-only-matching-filter", "Adds an 'Include only' filter to Events content (key1:value1,key2:value2, etc...)").Default("").OverrideDefaultFromEnvar("INCLUDE_ONLY_MATCHING_FILTER").String()
39+
excludeAlwaysMatchingFilter = kingpin.Flag("exclude-always-matching-filter", "Adds an 'Exclude always' filter to Events content (key1:value1,key2:value2, etc...)").Default("").OverrideDefaultFromEnvar("EXCLUDE_ALWAYS_MATCHING_FILTER").String()
3840
)
3941

4042
var (
@@ -88,7 +90,7 @@ func main() {
8890

8991
logging.Info.Println("Creating queue")
9092
queue := eventQueue.NewQueue(make([]*events.Event, 100))
91-
loggingClientSumo := sumoCFFirehose.NewSumoLogicAppender(*sumoEndpoint, 5000, &queue, *eventsBatchSize, *sumoPostMinimumDelay, *sumoCategory, *sumoName, *sumoHost, *verboseLogMessages, *customMetadata)
93+
loggingClientSumo := sumoCFFirehose.NewSumoLogicAppender(*sumoEndpoint, 5000, &queue, *eventsBatchSize, *sumoPostMinimumDelay, *sumoCategory, *sumoName, *sumoHost, *verboseLogMessages, *customMetadata, *includeOnlyMatchingFilter, *excludeAlwaysMatchingFilter)
9294
go loggingClientSumo.Start() //multi
9395

9496
logging.Info.Println("Creating Events")

0 commit comments

Comments
 (0)