Skip to content

Commit

Permalink
v1.1.14 - new origin + logging + ccdb connection handling
Browse files Browse the repository at this point in the history
  • Loading branch information
shahramk committed Dec 15, 2018
1 parent 2184a56 commit 66367c8
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 26 deletions.
1 change: 0 additions & 1 deletion Procfile

This file was deleted.

2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.1.13
v1.1.14
43 changes: 24 additions & 19 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ var insightsClient http.Client
var NREventsMap = make([]NREventType, 0)
var appInfo = map[string]*AppInfoType{} // caching app extended info (app/name/org names, etc.)
var nozzleInstanceId = os.Getenv("CF_INSTANCE_INDEX")
var logger = log.New(os.Stdout, ">>> ", 0)
// var logger = log.New(os.Stdout, ">>> ", 0)
var logger = log.New(os.Stdout, fmt.Sprintf(">>> Nozzle Instance: %3s -- ", nozzleInstanceId), 0)

var nozzleVersion string
var insightsMaxEvents int
Expand Down Expand Up @@ -265,12 +266,12 @@ func main() {
SkipSslValidation: pcfConfig.SkipSSL,
}
client, _ := cfclient.NewClient(c)
getAppList(client) // initial call to get list of current apps and their detail info
// extended org/space/app data
appDetailsInterval, err := strconv.Atoi(pcfExtendedConfig.APP_DETAIL_INTERVAL)
if err!=nil {
panic(err)
}
getAppList(client, appDetailsInterval) // initial call to get list of current apps and their detail info
// extended org/space/app data
getAppInfo(client, appDetailsInterval) // use a go routine to update app info periodically


Expand Down Expand Up @@ -438,15 +439,15 @@ func setFilters(pcfExtendedConfig PcfExtConfig) { //, filters EventFilters) {
}

func getAppInfo(client *cfclient.Client, appDetailsInterval int) {
logger.Printf("getAppInfo");
logger.Printf("Starting Goroutine getAppInfo -- refreshing applications list every %d minute(s)\n", appDetailsInterval);
ticker := time.NewTicker(time.Duration(int64(appDetailsInterval)) * time.Minute)
quit := make(chan struct{})

go func() {
for {
select {
case <-ticker.C:
getAppList(client)
getAppList(client, appDetailsInterval)

case <-quit:
logger.Print("quit \r\n")
Expand All @@ -456,20 +457,24 @@ func getAppInfo(client *cfclient.Client, appDetailsInterval int) {
}()
}

func getAppList(client *cfclient.Client) {

apps, _ := client.ListApps()

eventCount := len(apps)
logger.Println("App Count: ", eventCount)
func getAppList(client *cfclient.Client, appDetailsInterval int) {
logger.Println("Refreshing applications list...")
apps, err := client.ListApps()
if err != nil {
// error in cf-clinet library -- failed to get updated applist - will try next cycle
logger.Printf("Warning: cf-client failed to return applications list - will refresh app list in %d minute(s)...\n", appDetailsInterval)
} else {
eventCount := len(apps)
logger.Printf("App Count: %3d\n", eventCount)

tempAppInfo := map[string]*AppInfoType{}
for _, app := range apps {
addAppDetails(tempAppInfo, app)
// logger.Printf(">>>> index: %3d: name: %-45s\n", idx+1, tempAppInfo[app.Guid].name)
tempAppInfo := map[string]*AppInfoType{}
for _, app := range apps {
addAppDetails(tempAppInfo, app)
// logger.Printf(">>>> index: %3d: name: %-45s\n", idx+1, tempAppInfo[app.Guid].name)
}
appInfo = tempAppInfo
tempAppInfo = nil
}
appInfo = tempAppInfo
tempAppInfo = nil
}

func addAppDetails(appInfo map[string]*AppInfoType, app cfclient.App) {
Expand Down Expand Up @@ -502,8 +507,8 @@ func pushToInsights(nrEvent map[string]interface{}, insightsUrl string, insights
logger.Println("error:", err)
}
// logger.Println("jsonstr:", string(jsonStr)) // TEMP
logger.Printf("Nozzle Instance: %3s -- Value Metrics: %d, Counter Events: %d, Container Events: %d, Http StartStop Events: %d, Log Messages: %d, Errors: %d\n",
nozzleInstanceId, pcfCounters.valueMetricEvents, pcfCounters.counterEvents, pcfCounters.containerEvents,
logger.Printf("Value Metrics: %d, Counter Events: %d, Container Events: %d, Http StartStop Events: %d, Log Messages: %d, Errors: %d\n",
pcfCounters.valueMetricEvents, pcfCounters.counterEvents, pcfCounters.containerEvents,
pcfCounters.httpStartStopEvents, pcfCounters.logMessageEvents, pcfCounters.errors)


Expand Down
7 changes: 4 additions & 3 deletions manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ applications:
instances: 3
health-check-type: none
random-route: true
buildpack: https://github.com/cloudfoundry/go-buildpack.git
# command: go run main.go
buildpacks:
- binary_buildpack
command: ./nr-nozzle
env:
NOZZLE_USERNAME: "Ops Mgr -> Elastic Runtime -> Credentials -> Job -> UAA -> Opentsdb Nozzle Credentials -> Link to Credential -> identity"
NOZZLE_PASSWORD: "Ops Mgr -> Elastic Runtime -> Credentials -> Job -> UAA -> Opentsdb Nozzle Credentials -> Link to Credential -> password"
Expand All @@ -22,7 +23,7 @@ applications:
NEWRELIC_INSIGHTS_BASE_URL: https://insights-collector.newrelic.com/v1
NEWRELIC_INSIGHTS_RPM_ID: New Relic Account ID
NEWRELIC_INSIGHTS_INSERT_KEY: New Relic Insights Insert Key
NEWRELIC_NOZZLE_VERSION: 1.1.13
NEWRELIC_NOZZLE_VERSION: 1.1.14
NEWRELIC_INSIGHTS_MAX_EVENTS: 500

NOZZLE_GLOBAL_DEPLOYMENT_EXCLUSION_FILTERS: ex. 'dep1, dep2'
Expand Down
Binary file modified nr-nozzle
Binary file not shown.
15 changes: 13 additions & 2 deletions tile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,19 @@ packages:
label: New Relic Firehose Nozzle
manifest:
buildpack: binary_buildpack
path: ../newrelic-pcf-nozzle-tile
# path: ../newrelic-pcf-nozzle-tile
path: src
command: ./nr-nozzle
health-check-type: none
instances: (( .properties.nozzle_instances.value ))
# instances: 2
memory: 512M
post_deploy: |
# 12-12-2018
# remove older apps with underscores ("_") in their names
echo "### post-deploy"
echo "package name: ${PKG_NAME} -- old package name: $(echo ${PKG_NAME} | sed 's/-/_/g') -- app name: ${APP_NAME}"
delete_older_versions $(echo ${PKG_NAME} | sed 's/-/_/g') ${APP_NAME}
# Include stemcell criteria if you don't want to accept the default.
# Since this stemcell is only used to run pre and post errands, we
Expand Down Expand Up @@ -81,7 +88,7 @@ forms:
- name: newrelic_nozzle_version
type: string
label: New Relic Nozzle Version
default: v1.1.13
default: v1.1.14
description: New Relic Nozzle Tile Version
configurable: false
- name: newrelic_insights_base_url
Expand Down Expand Up @@ -231,6 +238,8 @@ forms:
label: etcd
- name: file_server
label: file_server
- name: garden-linux
label: garden-linux
- name: garden_linux
label: garden_linux
- name: gorouter
Expand Down Expand Up @@ -556,6 +565,8 @@ forms:
label: etcd
- name: file_server
label: file_server
- name: garden-linux
label: garden-linux
- name: garden_linux
label: garden_linux
- name: gorouter
Expand Down

0 comments on commit 66367c8

Please sign in to comment.