Skip to content
This repository has been archived by the owner on Jun 25, 2020. It is now read-only.

Commit

Permalink
Merge pull request #101 from cloudfoundry-community/pr-metrics-to-log…
Browse files Browse the repository at this point in the history
…ging

Allow the user to send any event to Stackdriver Logging
  • Loading branch information
johnsonj authored Aug 19, 2017
2 parents 7797bf8 + a3e7aab commit 3e78329
Show file tree
Hide file tree
Showing 16 changed files with 330 additions and 317 deletions.
7 changes: 5 additions & 2 deletions jobs/stackdriver-nozzle/spec
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ properties:
firehose.skip_ssl:
description: Skip SSL validation (for self signed certs, useful in dev environments)
default: false
firehose.events:
description: Whitelisted event types to send to Stackdriver (comma separated). Valid values include LogMessage,Error,HttpStartStop,CounterEvent,ValueMetric,ContainerMetric
firehose.events_to_stackdriver_logging:
description: Whitelisted event types to send to Stackdriver Logging (comma separated). Valid values include LogMessage,Error,HttpStartStop,CounterEvent,ValueMetric,ContainerMetric
default: LogMessage,Error
firehose.events_to_stackdriver_monitoring:
description: Whitelisted event types to send to Stackdriver Monitoring (comma separated). Valid values include CounterEvent,ValueMetric,ContainerMetric
default: CounterEvent,ValueMetric,ContainerMetric
firehose.subscription_id:
description: Subscription ID for the firehose nozzle
default: stackdriver-nozzle
Expand Down
3 changes: 2 additions & 1 deletion jobs/stackdriver-nozzle/templates/stackdriver-nozzle-ctl.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ case $1 in
export FIREHOSE_ENDPOINT=<%= p('firehose.endpoint') %>
export FIREHOSE_USERNAME=<%= p('firehose.username') %>
export FIREHOSE_PASSWORD=<%= p('firehose.password') %>
export FIREHOSE_EVENTS=<%= p('firehose.events', 'LogMessage,Error') %>
export FIREHOSE_EVENTS_TO_STACKDRIVER_LOGGING=<%= p('firehose.events_to_stackdriver_logging', 'LogMessage,Error') %>
export FIREHOSE_EVENTS_TO_STACKDRIVER_MONITORING=<%= p('firehose.events_to_stackdriver_monitoring', 'CounterEvent,ValueMetric,ContainerMetric') %>
export FIREHOSE_SKIP_SSL=<%= p('firehose.skip_ssl', false) %>
export FIREHOSE_SUBSCRIPTION_ID=<%= p('firehose.subscription_id', 'stackdriver-nozzle') %>
export FIREHOSE_NEWLINE_TOKEN=<%= p('firehose.newline_token', '') %>
Expand Down
3 changes: 2 additions & 1 deletion src/stackdriver-nozzle/.envrc.template
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# http://direnv.net

export FIREHOSE_ENDPOINT=https://api.bosh-lite.com
export FIREHOSE_EVENTS=HttpStart,HttpStop,HttpStartStop,LogMessage,ValueMetric,CounterEvent,Error,ContainerMetric
export FIREHOSE_EVENTS_TO_STACKDRIVER_LOGGING=HttpStart,HttpStop,HttpStartStop,LogMessage,ValueMetric,CounterEvent,Error,ContainerMetric
export FIREHOSE_EVENTS_TO_STACKDRIVER_MONITORING=ValueMetric,CounterEvent,ContainerMetric
export FIREHOSE_USERNAME=admin
export FIREHOSE_PASSWORD=admin
export FIREHOSE_SKIP_SSL=true
Expand Down
46 changes: 24 additions & 22 deletions src/stackdriver-nozzle/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@ func NewConfig() (*Config, error) {

type Config struct {
// Firehose config
APIEndpoint string `envconfig:"firehose_endpoint" required:"true"`
Events string `envconfig:"firehose_events" required:"true"`
Username string `envconfig:"firehose_username" default:"admin"`
Password string `envconfig:"firehose_password" default:"admin"`
SkipSSL bool `envconfig:"firehose_skip_ssl" default:"false"`
SubscriptionID string `envconfig:"firehose_subscription_id" required:"true"`
NewlineToken string `envconfig:"firehose_newline_token"`
APIEndpoint string `envconfig:"firehose_endpoint" required:"true"`
LoggingEvents string `envconfig:"firehose_events_to_stackdriver_logging" required:"true"`
MonitoringEvents string `envconfig:"firehose_events_to_stackdriver_monitoring" required:"false"`
Username string `envconfig:"firehose_username" default:"admin"`
Password string `envconfig:"firehose_password" default:"admin"`
SkipSSL bool `envconfig:"firehose_skip_ssl" default:"false"`
SubscriptionID string `envconfig:"firehose_subscription_id" required:"true"`
NewlineToken string `envconfig:"firehose_newline_token"`

// Stackdriver config
ProjectID string `envconfig:"gcp_project_id"`
Expand All @@ -80,8 +81,8 @@ func (c *Config) validate() error {
return errors.New("FIREHOSE_ENDPOINT is empty")
}

if c.Events == "" {
return errors.New("FIREHOSE_EVENTS is empty")
if c.LoggingEvents == "" && c.MonitoringEvents == "" {
return errors.New("FIREHOSE_EVENTS_TO_STACKDRIVER_LOGGING and FIREHOSE_EVENTS_TO_STACKDRIVER_MONITORING are empty")
}

return nil
Expand Down Expand Up @@ -119,18 +120,19 @@ func (c *Config) setNozzleHostInfo() {

func (c *Config) ToData() lager.Data {
return lager.Data{
"APIEndpoint": c.APIEndpoint,
"Username": c.Username,
"Password": "<redacted>",
"Events": c.Events,
"SkipSSL": c.SkipSSL,
"ProjectID": c.ProjectID,
"BatchCount": c.BatchCount,
"BatchDuration": c.BatchDuration,
"HeartbeatRate": c.HeartbeatRate,
"ResolveAppMetadata": c.ResolveAppMetadata,
"SubscriptionID": c.SubscriptionID,
"DebugNozzle": c.DebugNozzle,
"NewlineToken": c.NewlineToken,
"APIEndpoint": c.APIEndpoint,
"Username": c.Username,
"Password": "<redacted>",
"EventsToStackdriverMonitoring": c.MonitoringEvents,
"EventsToStackdriverLogging": c.LoggingEvents,
"SkipSSL": c.SkipSSL,
"ProjectID": c.ProjectID,
"BatchCount": c.BatchCount,
"BatchDuration": c.BatchDuration,
"HeartbeatRate": c.HeartbeatRate,
"ResolveAppMetadata": c.ResolveAppMetadata,
"SubscriptionID": c.SubscriptionID,
"DebugNozzle": c.DebugNozzle,
"NewlineToken": c.NewlineToken,
}
}
5 changes: 3 additions & 2 deletions src/stackdriver-nozzle/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ var _ = Describe("Config", func() {

BeforeEach(func() {
os.Setenv("FIREHOSE_ENDPOINT", "https://api.example.com")
os.Setenv("FIREHOSE_EVENTS", "LogMessage")
os.Setenv("FIREHOSE_EVENTS_TO_STACKDRIVER_LOGGING", "LogMessage")
os.Setenv("FIREHOSE_EVENTS_TO_STACKDRIVER_MONITORING", "")
os.Setenv("FIREHOSE_USERNAME", "admin")
os.Setenv("FIREHOSE_PASSWORD", "monkey123")
os.Setenv("FIREHOSE_SKIP_SSL", "true")
Expand Down Expand Up @@ -76,7 +77,7 @@ var _ = Describe("Config", func() {
Expect(err.Error()).To(ContainSubstring(envName))
},
Entry("FIREHOSE_ENDPOINT", "FIREHOSE_ENDPOINT"),
Entry("FIREHOSE_EVENTS", "FIREHOSE_EVENTS"),
Entry("FIREHOSE_EVENTS_TO_STACKDRIVER_LOGGING", "FIREHOSE_EVENTS_TO_STACKDRIVER_LOGGING"),
Entry("FIREHOSE_SUBSCRIPTION_ID", "FIREHOSE_SUBSCRIPTION_ID"),
)
})
85 changes: 0 additions & 85 deletions src/stackdriver-nozzle/filter/filter.go

This file was deleted.

29 changes: 0 additions & 29 deletions src/stackdriver-nozzle/filter/filter_suite_test.go

This file was deleted.

149 changes: 0 additions & 149 deletions src/stackdriver-nozzle/filter/filter_test.go

This file was deleted.

Loading

0 comments on commit 3e78329

Please sign in to comment.