Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Cluster and Replica Set labels in Metrics #394

Merged
merged 3 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/grafana_dashboards/MongoDB_ReplSet_Summary.json
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down
Loading