diff --git a/src/charm.py b/src/charm.py index 3b58dedce..9bba65f27 100755 --- a/src/charm.py +++ b/src/charm.py @@ -137,15 +137,30 @@ def __init__(self, *args): # relation events for Prometheus metrics are handled in the MetricsEndpointProvider self._grafana_agent = COSAgentProvider( self, - metrics_endpoints=Config.Monitoring.METRICS_ENDPOINTS, metrics_rules_dir=Config.Monitoring.METRICS_RULES_DIR, logs_rules_dir=Config.Monitoring.LOGS_RULES_DIR, log_slots=Config.Monitoring.LOG_SLOTS, + scrape_configs=self._mongo_scrape_config, ) self.secrets = SecretCache(self) # BEGIN: properties + def _mongo_scrape_config(self) -> List[Dict]: + """Generates scrape config for the mongo metrics endpoint.""" + return [ + { + "metrics_path": "/metrics", + "static_configs": [ + { + "targets": [ + f"{self._unit_ip(self.unit)}:{Config.Monitoring.MONGODB_EXPORTER_PORT}" + ], + "labels": {"cluster": self.app.name, "replication_set": self.app.name}, + } + ], + } + ] @property def primary(self) -> str: diff --git a/src/grafana_dashboards/MongoDB_ReplSet_Summary.json b/src/grafana_dashboards/MongoDB_ReplSet_Summary.json index 65977b16a..9a2ddcf02 100644 --- a/src/grafana_dashboards/MongoDB_ReplSet_Summary.json +++ b/src/grafana_dashboards/MongoDB_ReplSet_Summary.json @@ -2810,7 +2810,7 @@ "label": "Replica Set", "multi": false, "multiFormat": "glob", - "name": "replset", + "name": "replication_set", "options": [], "query": { "query": "label_values(mongodb_mongod_replset_my_state{cluster=~\"$cluster\"}, set)",