diff --git a/Gopkg.lock b/Gopkg.lock index c53628d..a4d13cd 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -33,6 +33,21 @@ pruneopts = "UT" revision = "3a771d992973f24aa725d07868b467d1ddfceafb" +[[projects]] + branch = "master" + digest = "1:d76f06183572b1eabc33c586fae00b16430091ca48300ec9fdc8450f88df4c35" + name = "github.com/bloomberg/goldpinger" + packages = [ + "pkg/client", + "pkg/client/operations", + "pkg/goldpinger", + "pkg/models", + "pkg/restapi", + "pkg/restapi/operations", + ] + pruneopts = "UT" + revision = "0ebc4eecfa001237308b3c148619ec0f22f21ea1" + [[projects]] digest = "1:6f82cacd0af5921e99bf3f46748705239b36489464f4529a1589bc895764fb18" name = "github.com/docker/go-units" @@ -612,6 +627,12 @@ analyzer-name = "dep" analyzer-version = 1 input-imports = [ + "github.com/bloomberg/goldpinger/pkg/client", + "github.com/bloomberg/goldpinger/pkg/client/operations", + "github.com/bloomberg/goldpinger/pkg/goldpinger", + "github.com/bloomberg/goldpinger/pkg/models", + "github.com/bloomberg/goldpinger/pkg/restapi", + "github.com/bloomberg/goldpinger/pkg/restapi/operations", "github.com/go-openapi/errors", "github.com/go-openapi/loads", "github.com/go-openapi/runtime", @@ -630,6 +651,7 @@ "golang.org/x/net/netutil", "k8s.io/apimachinery/pkg/apis/meta/v1", "k8s.io/client-go/kubernetes", + "k8s.io/client-go/rest", "k8s.io/client-go/tools/clientcmd", ] solver-name = "gps-cdcl" diff --git a/README.md b/README.md index a8589a8..266f2eb 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -# Goldpinger +# Goldpinger [![Build Status](https://travis-ci.com/bloomberg/goldpinger.svg?branch=master)](https://travis-ci.com/bloomberg/goldpinger) __Goldpinger__ makes calls between its instances for visibility and alerting. -It runs as a `DaemonSet` on `Kubernetes` and produces `Prometheus` metrics that can be scaped, visualised and alerted on. +It runs as a `DaemonSet` on `Kubernetes` and produces `Prometheus` metrics that can be scraped, visualised and alerted on. Oh, and it gives you the graph below for your cluster. @@ -27,7 +27,7 @@ Oh, and it gives you the graph below for your cluster. ## Rationale -We built __Goldpinger__ to troubleshoot, visualise and alert on our networking layer, while adopting `Kubernetes` at Bloomberg. It has since become the goto tool to see connectivity and slowness issues. +We built __Goldpinger__ to troubleshoot, visualise and alert on our networking layer while adopting `Kubernetes` at Bloomberg. It has since become the go-to tool to see connectivity and slowness issues. It's small, simple and you'll wonder why you hadn't had it before. @@ -71,7 +71,7 @@ namespace="docker.io/myhandle/" make push ## Installation -`Goldpinger` works by asking `Kubernetes` for pods with particular labels (`app=goldpinger`). While you can deploy `Golpinger` in a variety of ways, it works very nicely as a `DaemonSet` out of the box. +`Goldpinger` works by asking `Kubernetes` for pods with particular labels (`app=goldpinger`). While you can deploy `Goldpinger` in a variety of ways, it works very nicely as a `DaemonSet` out of the box. ### Authentication with Kubernetes API diff --git a/build/build.sh b/build/build.sh index 5f8a1f3..9ded6c2 100755 --- a/build/build.sh +++ b/build/build.sh @@ -37,5 +37,6 @@ export CGO_ENABLED=0 export GOARCH="${ARCH}" go build \ - -o ./bin/${BIN} \ - ./cmd/${BIN} + -ldflags "-X 'main.Version=${VERSION}' -X 'main.Build=`date`'" \ + -o ./bin/${BIN} \ + ./cmd/${BIN} diff --git a/cmd/goldpinger/main.go b/cmd/goldpinger/main.go index 0deffa1..fc12f05 100644 --- a/cmd/goldpinger/main.go +++ b/cmd/goldpinger/main.go @@ -29,7 +29,15 @@ import ( flags "github.com/jessevdk/go-flags" ) +// these will be injected during build in build.sh script to allow printing +var ( + Version, Build string +) + func main() { + + log.Println("Goldpinger version:", Version, "build:", Build) + // load embedded swagger file swaggerSpec, err := loads.Analyzed(restapi.SwaggerJSON, "") if err != nil { diff --git a/pkg/goldpinger/stats.go b/pkg/goldpinger/stats.go index 3dfcbef..a54b4ca 100644 --- a/pkg/goldpinger/stats.go +++ b/pkg/goldpinger/stats.go @@ -83,19 +83,6 @@ var ( }, ) - groups = map[string]map[string]int64{ - "received": map[string]int64{ - "ping": 0, - "check": 0, - "check_all": 0, - }, - "made": map[string]int64{ - "ping": 0, - "check": 0, - "check_all": 0, - }, - } - bootTime = time.Now() ) @@ -109,21 +96,14 @@ func init() { } func GetStats() *models.PingResults { - var result models.PingResults - var calls models.CallStats - - calls.Check = groups["received"]["check"] - calls.CheckAll = groups["received"]["check_all"] - calls.Ping = groups["received"]["ping"] - result.BootTime = strfmt.DateTime(bootTime) - result.Received = &calls - return &result + // GetStats no longer populates the received and made calls - use metrics for that instead + return &models.PingResults{ + BootTime: strfmt.DateTime(bootTime), + } } // counts various calls received and made func CountCall(group string, call string) { - groups[group][call]++ - goldpingerStatsCounter.WithLabelValues( GoldpingerConfig.Hostname, group,