Skip to content

Commit 3ef60ef

Browse files
author
Jeff McCormick
committed
add global metrics flag to pgo.yaml
1 parent 9425b54 commit 3ef60ef

File tree

5 files changed

+19
-3
lines changed

5 files changed

+19
-3
lines changed

apiserver/clusterservice/clusterimpl.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,13 @@ func CreateCluster(request *msgs.CreateClusterRequest) msgs.CreateClusterRespons
452452
}
453453
}
454454

455-
//if metrics is chosen, stick it into the user labels
455+
//set the metrics flag with the global setting first
456+
userLabelsMap["crunchy-collect"] = strconv.FormatBool(apiserver.MetricsFlag)
457+
if err != nil {
458+
log.Error(err)
459+
}
460+
461+
//if metrics is chosen on the pgo command, stick it into the user labels
456462
if request.MetricsFlag {
457463
userLabelsMap["crunchy-collect"] = "true"
458464
}

apiserver/root.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ var RESTClient *rest.RESTClient
4141
// Clientset ...
4242
var Clientset *kubernetes.Clientset
4343

44+
// MetricsFlag if set to true will cause crunchy-collect to be added into new clusters
45+
var MetricsFlag bool
46+
4447
// AuditFlag if set to true will cause auditing to occur in the logs
4548
var AuditFlag bool
4649

@@ -64,7 +67,7 @@ var Credentials map[string]string
6467

6568
func init() {
6669
BasicAuth = true
67-
70+
MetricsFlag = false
6871
AuditFlag = false
6972

7073
log.Infoln("apiserver starts")
@@ -136,6 +139,11 @@ func initConfig() {
136139
log.Info("audit flag is set to true")
137140
}
138141

142+
MetricsFlag = viper.GetBool("Pgo.Metrics")
143+
if MetricsFlag {
144+
log.Info("metrics flag is set to true")
145+
}
146+
139147
if DebugFlag || viper.GetBool("Pgo.Debug") {
140148
log.Debug("debug flag is set to true")
141149
log.SetLevel(log.DebugLevel)

conf/apiserver/pgo.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ ReplicaStorage:
2323
StorageType: create
2424
Pgo:
2525
Audit: false
26+
Metrics: false
2627
LSPVCTemplate: /config/pgo.lspvc-template.json
2728
LoadTemplate: /config/pgo.load-template.json
2829
COImagePrefix: crunchydata

conf/postgres-operator/cluster/1/collect.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"value": "http://crunchy-metrics:9091"
1414
}, {
1515
"name": "DATA_SOURCE_NAME",
16-
"value": "postgresql://primaryuser:password@{{.Name}}:5432/postgres?sslmode=disable"
16+
"value": "postgresql://primaryuser:password@127.0.0.1:5432/postgres?sslmode=disable"
1717
}, {
1818
"name": "POSTGRES_EXPORTER_URL",
1919
"value": "http://localhost:9187/metrics"

docs/operator-docs.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,7 @@ Values in the pgo configuration file have the following meaning:
596596
|Pgo.COImagePrefix | image tag prefix to use for the Operator containers
597597
|Pgo.COImageTag | image tag to use for the Operator containers
598598
|Pgo.Audit | boolean, if set to true will cause each apiserver call to be logged with an *audit* marking
599+
|Pgo.Metrics | boolean, if set to true will cause each new cluster to include crunchy-collect as a sidecar container for metrics collection, if set to false (default), users can still add metrics on a cluster-by-cluster basis using the pgo command flag --metrics
599600
|======================
600601

601602
*NOTE*: Regarding the PVC access mode variable; this is automatically set to ReadWriteMany but

0 commit comments

Comments
 (0)