diff --git a/cmd/do-agent/aggregation.go b/cmd/do-agent/aggregation.go index 5f04f439..8488b7c3 100644 --- a/cmd/do-agent/aggregation.go +++ b/cmd/do-agent/aggregation.go @@ -56,3 +56,7 @@ var k8sAggregationSpec = map[string][]string{ "kube_statefulset_replicas": {"statefulset", "namespace"}, "kube_statefulset_status_replicas_ready": {"statefulset", "namespace"}, } + +var mongoAggregationSpec = map[string][]string{ + "mongodb_data_usage_percentage": {"cluster_uuid"}, +} diff --git a/cmd/do-agent/config.go b/cmd/do-agent/config.go index 40c152be..b8fb2bad 100644 --- a/cmd/do-agent/config.go +++ b/cmd/do-agent/config.go @@ -39,6 +39,7 @@ var ( noNode bool kubernetes string dbaas string + mongodb string webListenAddress string webListen bool additionalLabels []string @@ -116,6 +117,9 @@ func init() { kingpin.Flag("dbaas-metrics-path", "enable DO DBAAS metrics collection (this must be a DO DBAAS metrics endpoint)"). StringVar(&config.dbaas) + kingpin.Flag("mongodb-metrics-path", "enable DO DBAAS MongoDB metrics collection (this must be a DO DBAAS metrics endpoint)"). + StringVar(&config.mongodb) + kingpin.Flag("metrics-path", "enable metrics collection from a prometheus endpoint"). StringVar(&config.promAddr) @@ -230,6 +234,13 @@ func initAggregatorSpecs() map[string][]string { } } + if config.mongodb != "" { + for k, v := range mongoAggregationSpec { + aggregateSpecs[k] = append(aggregateSpecs[k], v...) + } + + } + if config.kubernetes != "" { for k, v := range k8sAggregationSpec { aggregateSpecs[k] = append(aggregateSpecs[k], v...) @@ -292,6 +303,15 @@ func initCollectors() []prometheus.Collector { } } + if config.mongodb != "" { + k, err := collector.NewScraper("mongodb", config.mongodb, nil, dbaasWhitelist, collector.WithTimeout(config.scrapeTimeout)) + if err != nil { + log.Error("Failed to initialize DO DBaaS MongoDB metrics collector: %+v", err) + } else { + cols = append(cols, k) + } + } + if config.promAddr != "" { k, err := collector.NewScraper("prometheus", config.promAddr, nil, nil, collector.WithTimeout(config.scrapeTimeout)) if err != nil { diff --git a/cmd/do-agent/whitelist.go b/cmd/do-agent/whitelist.go index 4ecbbd2e..0367db6c 100644 --- a/cmd/do-agent/whitelist.go +++ b/cmd/do-agent/whitelist.go @@ -31,6 +31,8 @@ var dbaasWhitelist = map[string]bool{ "postgresql_pg_stat_database_xact_rollback": true, "postgresql_database_size_database_size": true, + "mongodb_data_usage_percentage": true, + "mysql_threads_created": true, "mysql_threads_connected": true, "mysql_threads_running": true,