Skip to content

Commit

Permalink
Merge pull request #669 from gocardless/lawrence-add-component-label-…
Browse files Browse the repository at this point in the history
…to-cluster-identifier

Label cluster identifier with component
  • Loading branch information
sgotti authored Jun 13, 2019
2 parents dead601 + 87f80d8 commit 2822e82
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
8 changes: 4 additions & 4 deletions cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ var (
clusterIdentifier = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "stolon_cluster_identifier",
Help: "Set to 1, is labelled with the cluster_name",
Help: "Set to 1, is labelled with the cluster_name and component",
},
[]string{"cluster_name"},
[]string{"cluster_name", "component"},
)
)

Expand Down Expand Up @@ -127,8 +127,8 @@ func CheckCommonConfig(cfg *CommonConfig) error {
// SetMetrics should be called by any stolon component that outputs application metrics.
// It sets the clusterIdentifier metric, which is key to joining across all the other
// metric series.
func SetMetrics(cfg *CommonConfig) {
clusterIdentifier.WithLabelValues(cfg.ClusterName).Set(1)
func SetMetrics(cfg *CommonConfig, component string) {
clusterIdentifier.WithLabelValues(cfg.ClusterName, component).Set(1)
}

func IsColorLoggerEnable(cmd *cobra.Command, cfg *CommonConfig) bool {
Expand Down
2 changes: 1 addition & 1 deletion cmd/keeper/cmd/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -1873,7 +1873,7 @@ func keeper(c *cobra.Command, args []string) {
log.Fatalf(err.Error())
}

cmd.SetMetrics(&cfg.CommonConfig)
cmd.SetMetrics(&cfg.CommonConfig, "keeper")

if err = os.MkdirAll(cfg.dataDir, 0700); err != nil {
log.Fatalf("cannot create data dir: %v", err)
Expand Down
2 changes: 2 additions & 0 deletions cmd/proxy/cmd/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,8 @@ func proxy(c *cobra.Command, args []string) {
log.Fatalf(err.Error())
}

cmd.SetMetrics(&cfg.CommonConfig, "proxy")

if cfg.keepAliveIdle < 0 {
log.Fatalf("tcp keepalive idle value must be greater or equal to 0")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/sentinel/cmd/sentinel.go
Original file line number Diff line number Diff line change
Expand Up @@ -1961,7 +1961,7 @@ func sentinel(c *cobra.Command, args []string) {
log.Fatalf(err.Error())
}

cmd.SetMetrics(&cfg.CommonConfig)
cmd.SetMetrics(&cfg.CommonConfig, "sentinel")

uid := common.UID()
log.Infow("sentinel uid", "uid", uid)
Expand Down

0 comments on commit 2822e82

Please sign in to comment.