Adding scraping relation to Mongodb Exporter
Change-Id: Ia96b29a9c7373254cde77ca708d069d3681b1386
Signed-off-by: sousaedu <eduardo.sousa@canonical.com>
diff --git a/installers/charm/prometheus-mongodb-exporter/.gitignore b/installers/charm/mongodb-exporter/.gitignore
similarity index 95%
rename from installers/charm/prometheus-mongodb-exporter/.gitignore
rename to installers/charm/mongodb-exporter/.gitignore
index 60e34f3..a4d0de2 100644
--- a/installers/charm/prometheus-mongodb-exporter/.gitignore
+++ b/installers/charm/mongodb-exporter/.gitignore
@@ -22,7 +22,7 @@
venv
.vscode
build
-prometheus-mongodb-exporter.charm
+mongodb-exporter.charm
.coverage
.stestr
cover
diff --git a/installers/charm/prometheus-mongodb-exporter/.yamllint.yaml b/installers/charm/mongodb-exporter/.yamllint.yaml
similarity index 100%
rename from installers/charm/prometheus-mongodb-exporter/.yamllint.yaml
rename to installers/charm/mongodb-exporter/.yamllint.yaml
diff --git a/installers/charm/prometheus-mongodb-exporter/README.md b/installers/charm/mongodb-exporter/README.md
similarity index 100%
rename from installers/charm/prometheus-mongodb-exporter/README.md
rename to installers/charm/mongodb-exporter/README.md
diff --git a/installers/charm/prometheus-mongodb-exporter/config.yaml b/installers/charm/mongodb-exporter/config.yaml
similarity index 100%
rename from installers/charm/prometheus-mongodb-exporter/config.yaml
rename to installers/charm/mongodb-exporter/config.yaml
diff --git a/installers/charm/mongodb-exporter/files/mongodb_exporter_dashboard.json b/installers/charm/mongodb-exporter/files/mongodb_exporter_dashboard.json
new file mode 100644
index 0000000..a1b128a
--- /dev/null
+++ b/installers/charm/mongodb-exporter/files/mongodb_exporter_dashboard.json
@@ -0,0 +1,840 @@
+{
+ "annotations": {
+ "list": [
+ {
+ "builtIn": 1,
+ "datasource": "-- Grafana --",
+ "enable": true,
+ "hide": true,
+ "iconColor": "rgba(0, 211, 255, 1)",
+ "name": "Annotations & Alerts",
+ "type": "dashboard"
+ }
+ ]
+ },
+ "description": "MongoDB Prometheus Exporter Dashboard.",
+ "editable": true,
+ "gnetId": 2583,
+ "graphTooltip": 1,
+ "id": 9,
+ "iteration": 1577555358996,
+ "links": [],
+ "panels": [
+ {
+ "collapsed": false,
+ "gridPos": {
+ "h": 1,
+ "w": 24,
+ "x": 0,
+ "y": 0
+ },
+ "id": 22,
+ "panels": [],
+ "repeat": "env",
+ "title": "Health",
+ "type": "row"
+ },
+ {
+ "cacheTimeout": null,
+ "colorBackground": false,
+ "colorValue": true,
+ "colors": [
+ "rgba(245, 54, 54, 0.9)",
+ "rgba(237, 129, 40, 0.89)",
+ "rgba(50, 172, 45, 0.97)"
+ ],
+ "datasource": "prometheus - Juju generated source",
+ "decimals": null,
+ "format": "s",
+ "gauge": {
+ "maxValue": 100,
+ "minValue": 0,
+ "show": false,
+ "thresholdLabels": false,
+ "thresholdMarkers": true
+ },
+ "gridPos": {
+ "h": 4,
+ "w": 12,
+ "x": 0,
+ "y": 1
+ },
+ "id": 10,
+ "interval": null,
+ "links": [],
+ "mappingType": 1,
+ "mappingTypes": [
+ {
+ "name": "value to text",
+ "value": 1
+ },
+ {
+ "name": "range to text",
+ "value": 2
+ }
+ ],
+ "maxDataPoints": 100,
+ "nullPointMode": "connected",
+ "nullText": null,
+ "options": {},
+ "postfix": "",
+ "postfixFontSize": "50%",
+ "prefix": "",
+ "prefixFontSize": "50%",
+ "rangeMaps": [
+ {
+ "from": "null",
+ "text": "N/A",
+ "to": "null"
+ }
+ ],
+ "sparkline": {
+ "fillColor": "rgba(31, 118, 189, 0.18)",
+ "full": false,
+ "lineColor": "rgb(31, 120, 193)",
+ "show": false
+ },
+ "tableColumn": "",
+ "targets": [
+ {
+ "expr": "mongodb_instance_uptime_seconds{instance=~\"$instance\"}",
+ "format": "time_series",
+ "intervalFactor": 2,
+ "legendFormat": "",
+ "refId": "A",
+ "step": 1800
+ }
+ ],
+ "thresholds": "0,360",
+ "title": "Uptime",
+ "type": "singlestat",
+ "valueFontSize": "80%",
+ "valueMaps": [
+ {
+ "op": "=",
+ "text": "N/A",
+ "value": "null"
+ }
+ ],
+ "valueName": "current"
+ },
+ {
+ "cacheTimeout": null,
+ "colorBackground": false,
+ "colorValue": false,
+ "colors": [
+ "rgba(245, 54, 54, 0.9)",
+ "rgba(237, 129, 40, 0.89)",
+ "rgba(50, 172, 45, 0.97)"
+ ],
+ "datasource": "prometheus - Juju generated source",
+ "format": "none",
+ "gauge": {
+ "maxValue": 100,
+ "minValue": 0,
+ "show": false,
+ "thresholdLabels": false,
+ "thresholdMarkers": true
+ },
+ "gridPos": {
+ "h": 4,
+ "w": 12,
+ "x": 12,
+ "y": 1
+ },
+ "id": 1,
+ "interval": null,
+ "links": [],
+ "mappingType": 1,
+ "mappingTypes": [
+ {
+ "name": "value to text",
+ "value": 1
+ },
+ {
+ "name": "range to text",
+ "value": 2
+ }
+ ],
+ "maxDataPoints": 100,
+ "nullPointMode": "connected",
+ "nullText": null,
+ "options": {},
+ "postfix": "",
+ "postfixFontSize": "50%",
+ "prefix": "",
+ "prefixFontSize": "50%",
+ "rangeMaps": [
+ {
+ "from": "null",
+ "text": "N/A",
+ "to": "null"
+ }
+ ],
+ "sparkline": {
+ "fillColor": "rgba(31, 118, 189, 0.18)",
+ "full": true,
+ "lineColor": "rgb(31, 120, 193)",
+ "show": true
+ },
+ "tableColumn": "",
+ "targets": [
+ {
+ "expr": "mongodb_connections{instance=~\"$instance\",state=\"current\"}",
+ "format": "time_series",
+ "intervalFactor": 2,
+ "legendFormat": "",
+ "metric": "mongodb_connections",
+ "refId": "A",
+ "step": 1800
+ }
+ ],
+ "thresholds": "",
+ "title": "Open Connections",
+ "type": "singlestat",
+ "valueFontSize": "80%",
+ "valueMaps": [
+ {
+ "op": "=",
+ "text": "N/A",
+ "value": "null"
+ }
+ ],
+ "valueName": "avg"
+ },
+ {
+ "collapsed": false,
+ "gridPos": {
+ "h": 1,
+ "w": 24,
+ "x": 0,
+ "y": 5
+ },
+ "id": 20,
+ "panels": [],
+ "repeat": "env",
+ "title": "Operations",
+ "type": "row"
+ },
+ {
+ "aliasColors": {},
+ "bars": false,
+ "dashLength": 10,
+ "dashes": false,
+ "datasource": "prometheus - Juju generated source",
+ "fill": 1,
+ "fillGradient": 0,
+ "gridPos": {
+ "h": 6,
+ "w": 10,
+ "x": 0,
+ "y": 6
+ },
+ "id": 7,
+ "legend": {
+ "avg": false,
+ "current": false,
+ "max": false,
+ "min": false,
+ "show": true,
+ "total": false,
+ "values": false
+ },
+ "lines": true,
+ "linewidth": 1,
+ "links": [],
+ "nullPointMode": "null",
+ "options": {
+ "dataLinks": []
+ },
+ "percentage": false,
+ "pointradius": 5,
+ "points": false,
+ "renderer": "flot",
+ "seriesOverrides": [],
+ "spaceLength": 10,
+ "stack": false,
+ "steppedLine": false,
+ "targets": [
+ {
+ "expr": "rate(mongodb_op_counters_total{instance=~\"$instance\"}[$interval])",
+ "format": "time_series",
+ "interval": "",
+ "intervalFactor": 2,
+ "legendFormat": "{{type}}",
+ "refId": "A",
+ "step": 240
+ }
+ ],
+ "thresholds": [],
+ "timeFrom": null,
+ "timeRegions": [],
+ "timeShift": null,
+ "title": "Query Operations",
+ "tooltip": {
+ "shared": true,
+ "sort": 0,
+ "value_type": "individual"
+ },
+ "type": "graph",
+ "xaxis": {
+ "buckets": null,
+ "mode": "time",
+ "name": null,
+ "show": true,
+ "values": []
+ },
+ "yaxes": [
+ {
+ "format": "ops",
+ "label": null,
+ "logBase": 1,
+ "max": null,
+ "min": null,
+ "show": true
+ },
+ {
+ "format": "short",
+ "label": null,
+ "logBase": 1,
+ "max": null,
+ "min": null,
+ "show": true
+ }
+ ],
+ "yaxis": {
+ "align": false,
+ "alignLevel": null
+ }
+ },
+ {
+ "aliasColors": {},
+ "bars": false,
+ "dashLength": 10,
+ "dashes": false,
+ "datasource": "prometheus - Juju generated source",
+ "fill": 1,
+ "fillGradient": 0,
+ "gridPos": {
+ "h": 6,
+ "w": 8,
+ "x": 10,
+ "y": 6
+ },
+ "id": 9,
+ "legend": {
+ "avg": false,
+ "current": false,
+ "max": false,
+ "min": false,
+ "show": true,
+ "total": false,
+ "values": false
+ },
+ "lines": true,
+ "linewidth": 1,
+ "links": [],
+ "nullPointMode": "null",
+ "options": {
+ "dataLinks": []
+ },
+ "percentage": false,
+ "pointradius": 5,
+ "points": false,
+ "renderer": "flot",
+ "seriesOverrides": [
+ {
+ "alias": "returned",
+ "yaxis": 1
+ }
+ ],
+ "spaceLength": 10,
+ "stack": false,
+ "steppedLine": false,
+ "targets": [
+ {
+ "expr": "rate(mongodb_mongod_metrics_document_total{instance=~\"$instance\"}[$interval])",
+ "format": "time_series",
+ "interval": "",
+ "intervalFactor": 2,
+ "legendFormat": "{{state}}",
+ "refId": "A",
+ "step": 240
+ }
+ ],
+ "thresholds": [],
+ "timeFrom": null,
+ "timeRegions": [],
+ "timeShift": null,
+ "title": "Document Operations",
+ "tooltip": {
+ "shared": true,
+ "sort": 0,
+ "value_type": "individual"
+ },
+ "type": "graph",
+ "xaxis": {
+ "buckets": null,
+ "mode": "time",
+ "name": null,
+ "show": true,
+ "values": []
+ },
+ "yaxes": [
+ {
+ "format": "short",
+ "label": null,
+ "logBase": 1,
+ "max": null,
+ "min": null,
+ "show": true
+ },
+ {
+ "format": "short",
+ "label": null,
+ "logBase": 1,
+ "max": null,
+ "min": null,
+ "show": true
+ }
+ ],
+ "yaxis": {
+ "align": false,
+ "alignLevel": null
+ }
+ },
+ {
+ "aliasColors": {},
+ "bars": false,
+ "dashLength": 10,
+ "dashes": false,
+ "datasource": "prometheus - Juju generated source",
+ "fill": 1,
+ "fillGradient": 0,
+ "gridPos": {
+ "h": 6,
+ "w": 6,
+ "x": 18,
+ "y": 6
+ },
+ "id": 8,
+ "legend": {
+ "avg": false,
+ "current": false,
+ "max": false,
+ "min": false,
+ "show": true,
+ "total": false,
+ "values": false
+ },
+ "lines": true,
+ "linewidth": 1,
+ "links": [],
+ "nullPointMode": "null",
+ "options": {
+ "dataLinks": []
+ },
+ "percentage": false,
+ "pointradius": 5,
+ "points": false,
+ "renderer": "flot",
+ "seriesOverrides": [],
+ "spaceLength": 10,
+ "stack": false,
+ "steppedLine": false,
+ "targets": [
+ {
+ "expr": "rate(mongodb_mongod_metrics_query_executor_total{instance=~\"$instance\"}[$interval])",
+ "format": "time_series",
+ "interval": "",
+ "intervalFactor": 2,
+ "legendFormat": "{{state}}",
+ "refId": "A",
+ "step": 600
+ }
+ ],
+ "thresholds": [],
+ "timeFrom": null,
+ "timeRegions": [],
+ "timeShift": null,
+ "title": "Document Query Executor",
+ "tooltip": {
+ "shared": true,
+ "sort": 0,
+ "value_type": "individual"
+ },
+ "type": "graph",
+ "xaxis": {
+ "buckets": null,
+ "mode": "time",
+ "name": null,
+ "show": true,
+ "values": []
+ },
+ "yaxes": [
+ {
+ "format": "short",
+ "label": null,
+ "logBase": 1,
+ "max": null,
+ "min": null,
+ "show": true
+ },
+ {
+ "format": "short",
+ "label": null,
+ "logBase": 1,
+ "max": null,
+ "min": null,
+ "show": true
+ }
+ ],
+ "yaxis": {
+ "align": false,
+ "alignLevel": null
+ }
+ },
+ {
+ "collapsed": false,
+ "gridPos": {
+ "h": 1,
+ "w": 24,
+ "x": 0,
+ "y": 12
+ },
+ "id": 23,
+ "panels": [],
+ "repeat": null,
+ "title": "Resources",
+ "type": "row"
+ },
+ {
+ "aliasColors": {},
+ "bars": false,
+ "dashLength": 10,
+ "dashes": false,
+ "datasource": "prometheus - Juju generated source",
+ "fill": 1,
+ "fillGradient": 0,
+ "gridPos": {
+ "h": 6,
+ "w": 12,
+ "x": 0,
+ "y": 13
+ },
+ "id": 4,
+ "legend": {
+ "alignAsTable": false,
+ "avg": false,
+ "current": true,
+ "hideEmpty": false,
+ "hideZero": false,
+ "max": false,
+ "min": false,
+ "rightSide": false,
+ "show": true,
+ "total": false,
+ "values": true
+ },
+ "lines": true,
+ "linewidth": 1,
+ "links": [],
+ "nullPointMode": "null",
+ "options": {
+ "dataLinks": []
+ },
+ "percentage": false,
+ "pointradius": 5,
+ "points": false,
+ "renderer": "flot",
+ "seriesOverrides": [],
+ "spaceLength": 10,
+ "stack": false,
+ "steppedLine": false,
+ "targets": [
+ {
+ "expr": "mongodb_memory{instance=~\"$instance\",type=~\"resident|virtual\"}",
+ "format": "time_series",
+ "interval": "",
+ "intervalFactor": 2,
+ "legendFormat": "{{type}}",
+ "refId": "A",
+ "step": 240
+ }
+ ],
+ "thresholds": [],
+ "timeFrom": null,
+ "timeRegions": [],
+ "timeShift": null,
+ "title": "Memory",
+ "tooltip": {
+ "shared": false,
+ "sort": 0,
+ "value_type": "individual"
+ },
+ "type": "graph",
+ "xaxis": {
+ "buckets": null,
+ "mode": "time",
+ "name": null,
+ "show": true,
+ "values": [
+ "total"
+ ]
+ },
+ "yaxes": [
+ {
+ "format": "decmbytes",
+ "label": "MB",
+ "logBase": 1,
+ "max": null,
+ "min": null,
+ "show": true
+ },
+ {
+ "format": "short",
+ "label": null,
+ "logBase": 1,
+ "max": null,
+ "min": null,
+ "show": true
+ }
+ ],
+ "yaxis": {
+ "align": false,
+ "alignLevel": null
+ }
+ },
+ {
+ "aliasColors": {},
+ "bars": false,
+ "dashLength": 10,
+ "dashes": false,
+ "datasource": "prometheus - Juju generated source",
+ "fill": 1,
+ "fillGradient": 0,
+ "gridPos": {
+ "h": 6,
+ "w": 12,
+ "x": 12,
+ "y": 13
+ },
+ "id": 5,
+ "legend": {
+ "avg": false,
+ "current": false,
+ "max": false,
+ "min": false,
+ "show": true,
+ "total": false,
+ "values": false
+ },
+ "lines": true,
+ "linewidth": 1,
+ "links": [],
+ "nullPointMode": "null",
+ "options": {
+ "dataLinks": []
+ },
+ "percentage": false,
+ "pointradius": 5,
+ "points": false,
+ "renderer": "flot",
+ "seriesOverrides": [],
+ "spaceLength": 10,
+ "stack": false,
+ "steppedLine": false,
+ "targets": [
+ {
+ "expr": "rate(mongodb_network_bytes_total{instance=~\"$instance\"}[$interval])",
+ "format": "time_series",
+ "interval": "",
+ "intervalFactor": 2,
+ "legendFormat": "{{state}}",
+ "metric": "mongodb_metrics_operation_total",
+ "refId": "A",
+ "step": 240
+ }
+ ],
+ "thresholds": [],
+ "timeFrom": null,
+ "timeRegions": [],
+ "timeShift": null,
+ "title": "Network I/O",
+ "tooltip": {
+ "shared": true,
+ "sort": 0,
+ "value_type": "individual"
+ },
+ "type": "graph",
+ "xaxis": {
+ "buckets": null,
+ "mode": "time",
+ "name": null,
+ "show": true,
+ "values": []
+ },
+ "yaxes": [
+ {
+ "format": "decbytes",
+ "label": null,
+ "logBase": 1,
+ "max": null,
+ "min": null,
+ "show": true
+ },
+ {
+ "format": "short",
+ "label": null,
+ "logBase": 1,
+ "max": null,
+ "min": null,
+ "show": true
+ }
+ ],
+ "yaxis": {
+ "align": false,
+ "alignLevel": null
+ }
+ }
+ ],
+ "refresh": "5s",
+ "schemaVersion": 19,
+ "style": "dark",
+ "tags": [],
+ "templating": {
+ "list": [
+ {
+ "allValue": null,
+ "current": {
+ "text": "All",
+ "value": "$__all"
+ },
+ "datasource": "prometheus - Juju generated source",
+ "definition": "",
+ "hide": 0,
+ "includeAll": true,
+ "label": "instance",
+ "multi": true,
+ "name": "instance",
+ "options": [],
+ "query": "label_values(mongodb_connections, instance)",
+ "refresh": 1,
+ "regex": "",
+ "skipUrlSync": false,
+ "sort": 1,
+ "tagValuesQuery": "/.*-(.*?)-.*/",
+ "tags": [],
+ "tagsQuery": "label_values(mongodb_connections, instance)",
+ "type": "query",
+ "useTags": false
+ },
+ {
+ "auto": true,
+ "auto_count": 30,
+ "auto_min": "10s",
+ "current": {
+ "text": "auto",
+ "value": "$__auto_interval_interval"
+ },
+ "hide": 0,
+ "label": null,
+ "name": "interval",
+ "options": [
+ {
+ "selected": true,
+ "text": "auto",
+ "value": "$__auto_interval_interval"
+ },
+ {
+ "selected": false,
+ "text": "1m",
+ "value": "1m"
+ },
+ {
+ "selected": false,
+ "text": "10m",
+ "value": "10m"
+ },
+ {
+ "selected": false,
+ "text": "30m",
+ "value": "30m"
+ },
+ {
+ "selected": false,
+ "text": "1h",
+ "value": "1h"
+ },
+ {
+ "selected": false,
+ "text": "6h",
+ "value": "6h"
+ },
+ {
+ "selected": false,
+ "text": "12h",
+ "value": "12h"
+ },
+ {
+ "selected": false,
+ "text": "1d",
+ "value": "1d"
+ },
+ {
+ "selected": false,
+ "text": "7d",
+ "value": "7d"
+ },
+ {
+ "selected": false,
+ "text": "14d",
+ "value": "14d"
+ },
+ {
+ "selected": false,
+ "text": "30d",
+ "value": "30d"
+ }
+ ],
+ "query": "1m,10m,30m,1h,6h,12h,1d,7d,14d,30d",
+ "refresh": 2,
+ "skipUrlSync": false,
+ "type": "interval"
+ }
+ ]
+ },
+ "time": {
+ "from": "now/d",
+ "to": "now"
+ },
+ "timepicker": {
+ "refresh_intervals": [
+ "5s",
+ "10s",
+ "30s",
+ "1m",
+ "5m",
+ "15m",
+ "30m",
+ "1h",
+ "2h",
+ "1d"
+ ],
+ "time_options": [
+ "5m",
+ "15m",
+ "1h",
+ "6h",
+ "12h",
+ "24h",
+ "2d",
+ "7d",
+ "30d"
+ ]
+ },
+ "timezone": "browser",
+ "title": "MongoDB",
+ "uid": "HEK4NbtZk",
+ "version": 2
+}
diff --git a/installers/charm/prometheus-mongodb-exporter/metadata.yaml b/installers/charm/mongodb-exporter/metadata.yaml
similarity index 94%
rename from installers/charm/prometheus-mongodb-exporter/metadata.yaml
rename to installers/charm/mongodb-exporter/metadata.yaml
index 78c4a31..26b6dad 100644
--- a/installers/charm/prometheus-mongodb-exporter/metadata.yaml
+++ b/installers/charm/mongodb-exporter/metadata.yaml
@@ -19,7 +19,7 @@
# osm-charmers@lists.launchpad.net
##
-name: prometheus-mongodb-exporter
+name: mongodb-exporter
summary: OSM Prometheus Mongodb Exporter
description: |
A CAAS charm to deploy OSM's Prometheus Mongodb Exporter.
@@ -40,8 +40,8 @@
description: Image of mongodb-exporter
upstream-source: "bitnami/mongodb-exporter:latest"
provides:
- prometheus-target:
- interface: http
+ prometheus-scrape:
+ interface: prometheus
grafana-dashboard:
interface: grafana-dashboard
requires:
diff --git a/installers/charm/prometheus-mongodb-exporter/requirements.txt b/installers/charm/mongodb-exporter/requirements.txt
similarity index 100%
rename from installers/charm/prometheus-mongodb-exporter/requirements.txt
rename to installers/charm/mongodb-exporter/requirements.txt
diff --git a/installers/charm/prometheus-mongodb-exporter/src/charm.py b/installers/charm/mongodb-exporter/src/charm.py
similarity index 88%
rename from installers/charm/prometheus-mongodb-exporter/src/charm.py
rename to installers/charm/mongodb-exporter/src/charm.py
index 12b3c1c..02a600c 100755
--- a/installers/charm/prometheus-mongodb-exporter/src/charm.py
+++ b/installers/charm/mongodb-exporter/src/charm.py
@@ -23,6 +23,7 @@
import logging
from pathlib import Path
from typing import Dict, List, NoReturn
+from urllib.parse import urlparse
from ops.charm import CharmBase
from ops.framework import EventBase, StoredState
@@ -34,7 +35,7 @@
logger = logging.getLogger(__name__)
-PROMETHEUS_MONGODB_EXPORTER_PORT = 9216
+MONGODB_EXPORTER_PORT = 9216
class RelationsMissing(Exception):
@@ -93,19 +94,19 @@
return data
-class PrometheusMongodbExporterCharm(CharmBase):
- """Prometheus Mongodb Exporter Charm."""
+class MongodbExporterCharm(CharmBase):
+ """Mongodb Exporter Charm."""
state = StoredState()
def __init__(self, *args) -> NoReturn:
- """Prometheus Mongodb Exporter Charm constructor."""
+ """Mongodb Exporter Charm constructor."""
super().__init__(*args)
# Internal state initialization
self.state.set_default(pod_spec=None)
- self.port = PROMETHEUS_MONGODB_EXPORTER_PORT
+ self.port = MONGODB_EXPORTER_PORT
self.image = OCIImageResource(self, "image")
# Registering regular events
@@ -120,21 +121,28 @@
# Registering provided relation events
self.framework.observe(
- self.on.prometheus_target_relation_joined, self._publish_target_info
+ self.on.prometheus_scrape_relation_joined, self._publish_scrape_info
)
self.framework.observe(
self.on.grafana_dashboard_relation_joined, self._publish_dashboard_info
)
- def _publish_target_info(self, event: EventBase) -> NoReturn:
- """Publishes target information.
+ def _publish_scrape_info(self, event: EventBase) -> NoReturn:
+ """Publishes scrape information.
Args:
event (EventBase): Exporter relation event.
"""
rel_data = {
- "hostname": self.model.app.name,
- "port": str(PROMETHEUS_MONGODB_EXPORTER_PORT),
+ "hostname": urlparse(self.model.config["site_url"]).hostname
+ if self.model.config["site_url"]
+ else self.model.app.name,
+ "port": "80"
+ if self.model.config["site_url"]
+ else str(MONGODB_EXPORTER_PORT),
+ "metrics_path": "/metrics",
+ "scrape_interval": "30s",
+ "scrape_timeout": "15s",
}
for k, v in rel_data.items():
event.relation.data[self.unit][k] = v
@@ -146,7 +154,8 @@
event (EventBase): Exporter relation event.
"""
rel_data = {
- "dashboard": Path("files/mongodb_exporter_dashboard.yaml").read_text(),
+ "name": "osm-mongodb",
+ "dashboard": Path("files/mongodb_exporter_dashboard.json").read_text(),
}
for k, v in rel_data.items():
event.relation.data[self.unit][k] = v
@@ -213,4 +222,4 @@
if __name__ == "__main__":
- main(PrometheusMongodbExporterCharm)
+ main(MongodbExporterCharm)
diff --git a/installers/charm/prometheus-mongodb-exporter/src/pod_spec.py b/installers/charm/mongodb-exporter/src/pod_spec.py
similarity index 92%
rename from installers/charm/prometheus-mongodb-exporter/src/pod_spec.py
rename to installers/charm/mongodb-exporter/src/pod_spec.py
index 44acb76..781c689 100644
--- a/installers/charm/prometheus-mongodb-exporter/src/pod_spec.py
+++ b/installers/charm/mongodb-exporter/src/pod_spec.py
@@ -103,7 +103,7 @@
"""
return [
{
- "name": "prometheus-mongodb-exporter",
+ "name": "mongo-exporter",
"containerPort": port,
"protocol": "TCP",
}
@@ -122,7 +122,9 @@
Returns:
Dict[str, Any]: pod environment configuration.
"""
- envconfig = {}
+ envconfig = {
+ "MONGODB_URI": relation_state.get("mongodb_connection_string"),
+ }
return envconfig
@@ -238,28 +240,11 @@
}
-def _make_pod_command(relation: Dict[str, Any]) -> List[str]:
- """Generate the startup command.
-
- Args:
- relation (Dict[str, Any]): Relation information.
-
- Returns:
- List[str]: command to startup the process.
- """
- command = [
- "mongodb_exporter_linux_amd64/mongodb_exporter",
- "--mongodbdsn={}".format(relation.get("mongodb_connection_string")),
- ]
-
- return command
-
-
def make_pod_spec(
image_info: Dict[str, str],
config: Dict[str, Any],
relation_state: Dict[str, Any],
- app_name: str = "prometheus-mongodb-exporter",
+ app_name: str = "mongodb-exporter",
port: int = 9216,
) -> Dict[str, Any]:
"""Generate the pod spec information.
@@ -285,7 +270,6 @@
readiness_probe = _make_readiness_probe(port)
liveness_probe = _make_liveness_probe(port)
ingress_resources = _make_pod_ingress_resources(config, app_name, port)
- command = _make_pod_command(relation_state)
return {
"version": 3,
@@ -296,7 +280,6 @@
"imagePullPolicy": "Always",
"ports": ports,
"envConfig": env_config,
- "command": command,
"kubernetes": {
"readinessProbe": readiness_probe,
"livenessProbe": liveness_probe,
diff --git a/installers/charm/prometheus-mongodb-exporter/tests/__init__.py b/installers/charm/mongodb-exporter/tests/__init__.py
similarity index 100%
rename from installers/charm/prometheus-mongodb-exporter/tests/__init__.py
rename to installers/charm/mongodb-exporter/tests/__init__.py
diff --git a/installers/charm/prometheus-mongodb-exporter/tests/test_charm.py b/installers/charm/mongodb-exporter/tests/test_charm.py
similarity index 82%
rename from installers/charm/prometheus-mongodb-exporter/tests/test_charm.py
rename to installers/charm/mongodb-exporter/tests/test_charm.py
index 89d30cd..372886b 100644
--- a/installers/charm/prometheus-mongodb-exporter/tests/test_charm.py
+++ b/installers/charm/mongodb-exporter/tests/test_charm.py
@@ -26,15 +26,15 @@
from ops.model import BlockedStatus
from ops.testing import Harness
-from charm import PrometheusMongodbExporterCharm
+from charm import MongodbExporterCharm
class TestCharm(unittest.TestCase):
- """Prometheus Mongodb Exporter Charm unit tests."""
+ """Mongodb Exporter Charm unit tests."""
def setUp(self) -> NoReturn:
"""Test setup"""
- self.harness = Harness(PrometheusMongodbExporterCharm)
+ self.harness = Harness(MongodbExporterCharm)
self.harness.set_leader(is_leader=True)
self.harness.begin()
@@ -59,21 +59,19 @@
"version": 3,
"containers": [
{
- "name": "prometheus-mongodb-exporter",
+ "name": "mongodb-exporter",
"imageDetails": self.harness.charm.image.fetch(),
"imagePullPolicy": "Always",
"ports": [
{
- "name": "prometheus-mongodb-exporter",
+ "name": "mongo-exporter",
"containerPort": 9216,
"protocol": "TCP",
}
],
- "envConfig": {},
- "command": [
- "mongodb_exporter_linux_amd64/mongodb_exporter",
- "--mongodbdsn=mongodb://mongo",
- ],
+ "envConfig": {
+ "MONGODB_URI": "mongodb://mongo",
+ },
"kubernetes": {
"readinessProbe": {
"httpGet": {
@@ -127,21 +125,19 @@
"version": 3,
"containers": [
{
- "name": "prometheus-mongodb-exporter",
+ "name": "mongodb-exporter",
"imageDetails": self.harness.charm.image.fetch(),
"imagePullPolicy": "Always",
"ports": [
{
- "name": "prometheus-mongodb-exporter",
+ "name": "mongo-exporter",
"containerPort": 9216,
"protocol": "TCP",
}
],
- "envConfig": {},
- "command": [
- "mongodb_exporter_linux_amd64/mongodb_exporter",
- "--mongodbdsn=mongodb://mongo",
- ],
+ "envConfig": {
+ "MONGODB_URI": "mongodb://mongo",
+ },
"kubernetes": {
"readinessProbe": {
"httpGet": {
@@ -169,20 +165,20 @@
"kubernetesResources": {
"ingressResources": [
{
- "name": "prometheus-mongodb-exporter-ingress",
+ "name": "mongodb-exporter-ingress",
"annotations": {
"nginx.ingress.kubernetes.io/ssl-redirect": "false",
},
"spec": {
"rules": [
{
- "host": "prometheus-mongodb-exporter",
+ "host": "mongodb-exporter",
"http": {
"paths": [
{
"path": "/",
"backend": {
- "serviceName": "prometheus-mongodb-exporter",
+ "serviceName": "mongodb-exporter",
"servicePort": 9216,
},
}
@@ -209,7 +205,7 @@
},
)
- self.harness.update_config({"site_url": "http://prometheus-mongodb-exporter"})
+ self.harness.update_config({"site_url": "http://mongodb-exporter"})
pod_spec, _ = self.harness.get_pod_spec()
@@ -221,21 +217,19 @@
"version": 3,
"containers": [
{
- "name": "prometheus-mongodb-exporter",
+ "name": "mongodb-exporter",
"imageDetails": self.harness.charm.image.fetch(),
"imagePullPolicy": "Always",
"ports": [
{
- "name": "prometheus-mongodb-exporter",
+ "name": "mongo-exporter",
"containerPort": 9216,
"protocol": "TCP",
}
],
- "envConfig": {},
- "command": [
- "mongodb_exporter_linux_amd64/mongodb_exporter",
- "--mongodbdsn=mongodb://mongo",
- ],
+ "envConfig": {
+ "MONGODB_URI": "mongodb://mongo",
+ },
"kubernetes": {
"readinessProbe": {
"httpGet": {
@@ -263,18 +257,18 @@
"kubernetesResources": {
"ingressResources": [
{
- "name": "prometheus-mongodb-exporter-ingress",
+ "name": "mongodb-exporter-ingress",
"annotations": {},
"spec": {
"rules": [
{
- "host": "prometheus-mongodb-exporter",
+ "host": "mongodb-exporter",
"http": {
"paths": [
{
"path": "/",
"backend": {
- "serviceName": "prometheus-mongodb-exporter",
+ "serviceName": "mongodb-exporter",
"servicePort": 9216,
},
}
@@ -284,8 +278,8 @@
],
"tls": [
{
- "hosts": ["prometheus-mongodb-exporter"],
- "secretName": "prometheus-mongodb-exporter",
+ "hosts": ["mongodb-exporter"],
+ "secretName": "mongodb-exporter",
}
],
},
@@ -309,8 +303,8 @@
self.harness.update_config(
{
- "site_url": "https://prometheus-mongodb-exporter",
- "tls_secret_name": "prometheus-mongodb-exporter",
+ "site_url": "https://mongodb-exporter",
+ "tls_secret_name": "mongodb-exporter",
}
)
@@ -324,21 +318,19 @@
"version": 3,
"containers": [
{
- "name": "prometheus-mongodb-exporter",
+ "name": "mongodb-exporter",
"imageDetails": self.harness.charm.image.fetch(),
"imagePullPolicy": "Always",
"ports": [
{
- "name": "prometheus-mongodb-exporter",
+ "name": "mongo-exporter",
"containerPort": 9216,
"protocol": "TCP",
}
],
- "envConfig": {},
- "command": [
- "mongodb_exporter_linux_amd64/mongodb_exporter",
- "--mongodbdsn=mongodb://mongo",
- ],
+ "envConfig": {
+ "MONGODB_URI": "mongodb://mongo",
+ },
"kubernetes": {
"readinessProbe": {
"httpGet": {
@@ -366,20 +358,20 @@
"kubernetesResources": {
"ingressResources": [
{
- "name": "prometheus-mongodb-exporter-ingress",
+ "name": "mongodb-exporter-ingress",
"annotations": {
"nginx.ingress.kubernetes.io/whitelist-source-range": "0.0.0.0/0",
},
"spec": {
"rules": [
{
- "host": "prometheus-mongodb-exporter",
+ "host": "mongodb-exporter",
"http": {
"paths": [
{
"path": "/",
"backend": {
- "serviceName": "prometheus-mongodb-exporter",
+ "serviceName": "mongodb-exporter",
"servicePort": 9216,
},
}
@@ -389,8 +381,8 @@
],
"tls": [
{
- "hosts": ["prometheus-mongodb-exporter"],
- "secretName": "prometheus-mongodb-exporter",
+ "hosts": ["mongodb-exporter"],
+ "secretName": "mongodb-exporter",
}
],
},
@@ -414,8 +406,8 @@
self.harness.update_config(
{
- "site_url": "https://prometheus-mongodb-exporter",
- "tls_secret_name": "prometheus-mongodb-exporter",
+ "site_url": "https://mongodb-exporter",
+ "tls_secret_name": "mongodb-exporter",
"ingress_whitelist_source_range": "0.0.0.0/0",
}
)
@@ -442,19 +434,44 @@
# Verifying status
self.assertNotIsInstance(self.harness.charm.unit.status, BlockedStatus)
- def test_publish_target_info(self) -> NoReturn:
- """Test to see if target relation is updated."""
+ def test_publish_scrape_info(self) -> NoReturn:
+ """Test to see if scrape relation is updated."""
expected_result = {
- "hostname": "prometheus-mongodb-exporter",
+ "hostname": "mongodb-exporter",
"port": "9216",
+ "metrics_path": "/metrics",
+ "scrape_interval": "30s",
+ "scrape_timeout": "15s",
}
self.harness.charm.on.start.emit()
- relation_id = self.harness.add_relation("prometheus-target", "prometheus")
+ relation_id = self.harness.add_relation("prometheus-scrape", "prometheus")
self.harness.add_relation_unit(relation_id, "prometheus/0")
relation_data = self.harness.get_relation_data(
- relation_id, "prometheus-mongodb-exporter/0"
+ relation_id, "mongodb-exporter/0"
+ )
+
+ self.assertDictEqual(expected_result, relation_data)
+
+ def test_publish_scrape_info_with_site_url(self) -> NoReturn:
+ """Test to see if target relation is updated."""
+ expected_result = {
+ "hostname": "mongodb-exporter-osm",
+ "port": "80",
+ "metrics_path": "/metrics",
+ "scrape_interval": "30s",
+ "scrape_timeout": "15s",
+ }
+
+ self.harness.charm.on.start.emit()
+
+ self.harness.update_config({"site_url": "http://mongodb-exporter-osm"})
+
+ relation_id = self.harness.add_relation("prometheus-scrape", "prometheus")
+ self.harness.add_relation_unit(relation_id, "prometheus/0")
+ relation_data = self.harness.get_relation_data(
+ relation_id, "mongodb-exporter/0"
)
self.assertDictEqual(expected_result, relation_data)
@@ -466,9 +483,10 @@
relation_id = self.harness.add_relation("grafana-dashboard", "grafana")
self.harness.add_relation_unit(relation_id, "grafana/0")
relation_data = self.harness.get_relation_data(
- relation_id, "prometheus-mongodb-exporter/0"
+ relation_id, "mongodb-exporter/0"
)
+ self.assertEqual("osm-mongodb", relation_data["name"])
self.assertTrue("dashboard" in relation_data)
self.assertTrue(len(relation_data["dashboard"]) > 0)
diff --git a/installers/charm/prometheus-mongodb-exporter/tests/test_pod_spec.py b/installers/charm/mongodb-exporter/tests/test_pod_spec.py
similarity index 88%
rename from installers/charm/prometheus-mongodb-exporter/tests/test_pod_spec.py
rename to installers/charm/mongodb-exporter/tests/test_pod_spec.py
index e907cc0..3e312f4 100644
--- a/installers/charm/prometheus-mongodb-exporter/tests/test_pod_spec.py
+++ b/installers/charm/mongodb-exporter/tests/test_pod_spec.py
@@ -35,7 +35,7 @@
expected_result = [
{
- "name": "prometheus-mongodb-exporter",
+ "name": "mongo-exporter",
"containerPort": port,
"protocol": "TCP",
}
@@ -52,7 +52,7 @@
"mongodb_connection_string": "mongodb://mongo",
}
- expected_result = {}
+ expected_result = {"MONGODB_URI": "mongodb://mongo"}
pod_envconfig = pod_spec._make_pod_envconfig(config, relation_state)
@@ -61,7 +61,7 @@
def test_make_pod_ingress_resources_without_site_url(self) -> NoReturn:
"""Testing make pod ingress resources without site_url."""
config = {"site_url": ""}
- app_name = "prometheus-mongodb-exporter"
+ app_name = "mongodb-exporter"
port = 9216
pod_ingress_resources = pod_spec._make_pod_ingress_resources(
@@ -73,10 +73,10 @@
def test_make_pod_ingress_resources(self) -> NoReturn:
"""Testing make pod ingress resources."""
config = {
- "site_url": "http://prometheus-mongodb-exporter",
+ "site_url": "http://mongodb-exporter",
"ingress_whitelist_source_range": "",
}
- app_name = "prometheus-mongodb-exporter"
+ app_name = "mongodb-exporter"
port = 9216
expected_result = [
@@ -115,10 +115,10 @@
def test_make_pod_ingress_resources_with_whitelist_source_range(self) -> NoReturn:
"""Testing make pod ingress resources with whitelist_source_range."""
config = {
- "site_url": "http://prometheus-mongodb-exporter",
+ "site_url": "http://mongodb-exporter",
"ingress_whitelist_source_range": "0.0.0.0/0",
}
- app_name = "prometheus-mongodb-exporter"
+ app_name = "mongodb-exporter"
port = 9216
expected_result = [
@@ -160,11 +160,11 @@
def test_make_pod_ingress_resources_with_https(self) -> NoReturn:
"""Testing make pod ingress resources with HTTPs."""
config = {
- "site_url": "https://prometheus-mongodb-exporter",
+ "site_url": "https://mongodb-exporter",
"ingress_whitelist_source_range": "",
"tls_secret_name": "",
}
- app_name = "prometheus-mongodb-exporter"
+ app_name = "mongodb-exporter"
port = 9216
expected_result = [
@@ -202,11 +202,11 @@
def test_make_pod_ingress_resources_with_https_tls_secret_name(self) -> NoReturn:
"""Testing make pod ingress resources with HTTPs and TLS secret name."""
config = {
- "site_url": "https://prometheus-mongodb-exporter",
+ "site_url": "https://mongodb-exporter",
"ingress_whitelist_source_range": "",
"tls_secret_name": "secret_name",
}
- app_name = "prometheus-mongodb-exporter"
+ app_name = "mongodb-exporter"
port = 9216
expected_result = [
@@ -281,21 +281,6 @@
self.assertDictEqual(expected_result, liveness_probe)
- def test_make_pod_command(self) -> NoReturn:
- """Testing make pod command."""
- relation = {
- "mongodb_connection_string": "mongodb://mongo",
- }
-
- expected_result = [
- "mongodb_exporter_linux_amd64/mongodb_exporter",
- "--mongodbdsn={}".format(relation.get("mongodb_connection_string")),
- ]
-
- pod_envconfig = pod_spec._make_pod_command(relation)
-
- self.assertListEqual(expected_result, pod_envconfig)
-
def test_make_pod_spec(self) -> NoReturn:
"""Testing make pod spec."""
image_info = {"upstream-source": "bitnami/mongodb-exporter:latest"}
@@ -305,7 +290,7 @@
relation_state = {
"mongodb_connection_string": "mongodb://mongo",
}
- app_name = "prometheus-mongodb-exporter"
+ app_name = "mongodb-exporter"
port = 9216
expected_result = {
@@ -317,16 +302,14 @@
"imagePullPolicy": "Always",
"ports": [
{
- "name": app_name,
+ "name": "mongo-exporter",
"containerPort": port,
"protocol": "TCP",
}
],
- "envConfig": {},
- "command": [
- "mongodb_exporter_linux_amd64/mongodb_exporter",
- "--mongodbdsn=mongodb://mongo",
- ],
+ "envConfig": {
+ "MONGODB_URI": "mongodb://mongo",
+ },
"kubernetes": {
"readinessProbe": {
"httpGet": {
@@ -364,14 +347,14 @@
"""Testing make pod spec."""
image_info = {"upstream-source": "bitnami/mongodb-exporter:latest"}
config = {
- "site_url": "https://prometheus-mongodb-exporter",
- "tls_secret_name": "prometheus-mongodb-exporter",
+ "site_url": "https://mongodb-exporter",
+ "tls_secret_name": "mongodb-exporter",
"ingress_whitelist_source_range": "0.0.0.0/0",
}
relation_state = {
"mongodb_connection_string": "mongodb://mongo",
}
- app_name = "prometheus-mongodb-exporter"
+ app_name = "mongodb-exporter"
port = 9216
expected_result = {
@@ -383,16 +366,14 @@
"imagePullPolicy": "Always",
"ports": [
{
- "name": app_name,
+ "name": "mongo-exporter",
"containerPort": port,
"protocol": "TCP",
}
],
- "envConfig": {},
- "command": [
- "mongodb_exporter_linux_amd64/mongodb_exporter",
- "--mongodbdsn=mongodb://mongo",
- ],
+ "envConfig": {
+ "MONGODB_URI": "mongodb://mongo",
+ },
"kubernetes": {
"readinessProbe": {
"httpGet": {
@@ -470,7 +451,7 @@
relation_state = {
"mongodb_connection_string": "mongodb://mongo",
}
- app_name = "prometheus-mongodb-exporter"
+ app_name = "mongodb-exporter"
port = 9216
spec = pod_spec.make_pod_spec(
@@ -486,7 +467,7 @@
"site_url": "",
}
relation_state = {}
- app_name = "prometheus-mongodb-exporter"
+ app_name = "mongodb-exporter"
port = 9216
with self.assertRaises(ValueError):
diff --git a/installers/charm/prometheus-mongodb-exporter/tox.ini b/installers/charm/mongodb-exporter/tox.ini
similarity index 91%
rename from installers/charm/prometheus-mongodb-exporter/tox.ini
rename to installers/charm/mongodb-exporter/tox.ini
index a20a6f0..6991172 100644
--- a/installers/charm/prometheus-mongodb-exporter/tox.ini
+++ b/installers/charm/mongodb-exporter/tox.ini
@@ -30,7 +30,7 @@
setenv =
PYTHONHASHSEED=0
PYTHONPATH = {toxinidir}/src
- CHARM_NAME = prometheus-mongodb-exporter
+ CHARM_NAME = mongodb-exporter
[testenv:build]
passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY
@@ -39,9 +39,9 @@
rm
unzip
commands =
- rm -rf release prometheus-mongodb-exporter.charm
+ rm -rf release mongodb-exporter.charm
charmcraft build
- unzip prometheus-mongodb-exporter.charm -d release
+ unzip mongodb-exporter.charm -d release
[testenv:unit]
commands =
diff --git a/installers/charm/prometheus-mongodb-exporter/files/mongodb_exporter_dashboard.yaml b/installers/charm/prometheus-mongodb-exporter/files/mongodb_exporter_dashboard.yaml
deleted file mode 100644
index b2489f4..0000000
--- a/installers/charm/prometheus-mongodb-exporter/files/mongodb_exporter_dashboard.yaml
+++ /dev/null
@@ -1,691 +0,0 @@
-# Copyright 2021 Canonical Ltd.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-#
-# For those usages not covered by the Apache License, Version 2.0 please
-# contact: legal@canonical.com
-#
-# To get in touch with the maintainers, please contact:
-# osm-charmers@lists.launchpad.net
-##
-
----
-annotations:
- list:
- - builtIn: 1
- datasource: '-- Grafana --'
- enable: true
- hide: true
- iconColor: 'rgba(0, 211, 255, 1)'
- name: Annotations & Alerts
- type: dashboard
-description: MongoDB Prometheus Exporter Dashboard.
-editable: true
-gnetId: 2583
-graphTooltip: 1
-id: 9
-iteration: 1577555358996
-links: []
-panels:
- - collapsed: false
- gridPos:
- h: 1
- w: 24
- x: 0
- 'y': 0
- id: 22
- panels: []
- repeat: env
- title: Health
- type: row
- - cacheTimeout: null
- colorBackground: false
- colorValue: true
- colors:
- - 'rgba(245, 54, 54, 0.9)'
- - 'rgba(237, 129, 40, 0.89)'
- - 'rgba(50, 172, 45, 0.97)'
- datasource: Prometheus
- decimals: null
- format: s
- gauge:
- maxValue: 100
- minValue: 0
- show: false
- thresholdLabels: false
- thresholdMarkers: true
- gridPos:
- h: 4
- w: 12
- x: 0
- 'y': 1
- id: 10
- interval: null
- links: []
- mappingType: 1
- mappingTypes:
- - name: value to text
- value: 1
- - name: range to text
- value: 2
- maxDataPoints: 100
- nullPointMode: connected
- nullText: null
- options: {}
- postfix: ''
- postfixFontSize: 50%
- prefix: ''
- prefixFontSize: 50%
- rangeMaps:
- - from: 'null'
- text: N/A
- to: 'null'
- sparkline:
- fillColor: 'rgba(31, 118, 189, 0.18)'
- full: false
- lineColor: 'rgb(31, 120, 193)'
- show: false
- tableColumn: ''
- targets:
- - expr: 'mongodb_instance_uptime_seconds{instance=~"$instance"}'
- format: time_series
- intervalFactor: 2
- legendFormat: ''
- refId: A
- step: 1800
- thresholds: '0,360'
- title: Uptime
- type: singlestat
- valueFontSize: 80%
- valueMaps:
- - op: '='
- text: N/A
- value: 'null'
- valueName: current
- - cacheTimeout: null
- colorBackground: false
- colorValue: false
- colors:
- - 'rgba(245, 54, 54, 0.9)'
- - 'rgba(237, 129, 40, 0.89)'
- - 'rgba(50, 172, 45, 0.97)'
- datasource: Prometheus
- format: none
- gauge:
- maxValue: 100
- minValue: 0
- show: false
- thresholdLabels: false
- thresholdMarkers: true
- gridPos:
- h: 4
- w: 12
- x: 12
- 'y': 1
- id: 1
- interval: null
- links: []
- mappingType: 1
- mappingTypes:
- - name: value to text
- value: 1
- - name: range to text
- value: 2
- maxDataPoints: 100
- nullPointMode: connected
- nullText: null
- options: {}
- postfix: ''
- postfixFontSize: 50%
- prefix: ''
- prefixFontSize: 50%
- rangeMaps:
- - from: 'null'
- text: N/A
- to: 'null'
- sparkline:
- fillColor: 'rgba(31, 118, 189, 0.18)'
- full: true
- lineColor: 'rgb(31, 120, 193)'
- show: true
- tableColumn: ''
- targets:
- - expr: 'mongodb_connections{instance=~"$instance",state="current"}'
- format: time_series
- intervalFactor: 2
- legendFormat: ''
- metric: mongodb_connections
- refId: A
- step: 1800
- thresholds: ''
- title: Open Connections
- type: singlestat
- valueFontSize: 80%
- valueMaps:
- - op: '='
- text: N/A
- value: 'null'
- valueName: avg
- - collapsed: false
- gridPos:
- h: 1
- w: 24
- x: 0
- 'y': 5
- id: 20
- panels: []
- repeat: env
- title: Operations
- type: row
- - aliasColors: {}
- bars: false
- dashLength: 10
- dashes: false
- datasource: Prometheus
- fill: 1
- fillGradient: 0
- gridPos:
- h: 6
- w: 10
- x: 0
- 'y': 6
- id: 7
- legend:
- avg: false
- current: false
- max: false
- min: false
- show: true
- total: false
- values: false
- lines: true
- linewidth: 1
- links: []
- nullPointMode: 'null'
- options:
- dataLinks: []
- percentage: false
- pointradius: 5
- points: false
- renderer: flot
- seriesOverrides: []
- spaceLength: 10
- stack: false
- steppedLine: false
- targets:
- - expr: >-
- 'rate(mongodb_op_counters_total{instance=~"$instance"}[$interval])'
- format: time_series
- interval: ''
- intervalFactor: 2
- legendFormat: '{{type}}'
- refId: A
- step: 240
- thresholds: []
- timeFrom: null
- timeRegions: []
- timeShift: null
- title: Query Operations
- tooltip:
- shared: true
- sort: 0
- value_type: individual
- type: graph
- xaxis:
- buckets: null
- mode: time
- name: null
- show: true
- values: []
- yaxes:
- - format: ops
- label: null
- logBase: 1
- max: null
- min: null
- show: true
- - format: short
- label: null
- logBase: 1
- max: null
- min: null
- show: true
- yaxis:
- align: false
- alignLevel: null
- - aliasColors: {}
- bars: false
- dashLength: 10
- dashes: false
- datasource: Prometheus
- fill: 1
- fillGradient: 0
- gridPos:
- h: 6
- w: 8
- x: 10
- 'y': 6
- id: 9
- legend:
- avg: false
- current: false
- max: false
- min: false
- show: true
- total: false
- values: false
- lines: true
- linewidth: 1
- links: []
- nullPointMode: 'null'
- options:
- dataLinks: []
- percentage: false
- pointradius: 5
- points: false
- renderer: flot
- seriesOverrides:
- - alias: returned
- yaxis: 1
- spaceLength: 10
- stack: false
- steppedLine: false
- targets:
- - expr: >-
- rate(mongodb_mongod_metrics_document_total{instance=~"$instance"}[$interval])
- format: time_series
- interval: ''
- intervalFactor: 2
- legendFormat: '{{state}}'
- refId: A
- step: 240
- thresholds: []
- timeFrom: null
- timeRegions: []
- timeShift: null
- title: Document Operations
- tooltip:
- shared: true
- sort: 0
- value_type: individual
- type: graph
- xaxis:
- buckets: null
- mode: time
- name: null
- show: true
- values: []
- yaxes:
- - format: short
- label: null
- logBase: 1
- max: null
- min: null
- show: true
- - format: short
- label: null
- logBase: 1
- max: null
- min: null
- show: true
- yaxis:
- align: false
- alignLevel: null
- - aliasColors: {}
- bars: false
- dashLength: 10
- dashes: false
- datasource: Prometheus
- fill: 1
- fillGradient: 0
- gridPos:
- h: 6
- w: 6
- x: 18
- 'y': 6
- id: 8
- legend:
- avg: false
- current: false
- max: false
- min: false
- show: true
- total: false
- values: false
- lines: true
- linewidth: 1
- links: []
- nullPointMode: 'null'
- options:
- dataLinks: []
- percentage: false
- pointradius: 5
- points: false
- renderer: flot
- seriesOverrides: []
- spaceLength: 10
- stack: false
- steppedLine: false
- targets:
- - expr: >-
- rate(mongodb_mongod_metrics_query_executor_total{instance=~"$instance"}[$interval])
- format: time_series
- interval: ''
- intervalFactor: 2
- legendFormat: '{{state}}'
- refId: A
- step: 600
- thresholds: []
- timeFrom: null
- timeRegions: []
- timeShift: null
- title: Document Query Executor
- tooltip:
- shared: true
- sort: 0
- value_type: individual
- type: graph
- xaxis:
- buckets: null
- mode: time
- name: null
- show: true
- values: []
- yaxes:
- - format: short
- label: null
- logBase: 1
- max: null
- min: null
- show: true
- - format: short
- label: null
- logBase: 1
- max: null
- min: null
- show: true
- yaxis:
- align: false
- alignLevel: null
- - collapsed: false
- gridPos:
- h: 1
- w: 24
- x: 0
- 'y': 12
- id: 23
- panels: []
- repeat: null
- title: Resources
- type: row
- - aliasColors: {}
- bars: false
- dashLength: 10
- dashes: false
- datasource: Prometheus
- fill: 1
- fillGradient: 0
- gridPos:
- h: 6
- w: 12
- x: 0
- 'y': 13
- id: 4
- legend:
- alignAsTable: false
- avg: false
- current: true
- hideEmpty: false
- hideZero: false
- max: false
- min: false
- rightSide: false
- show: true
- total: false
- values: true
- lines: true
- linewidth: 1
- links: []
- nullPointMode: 'null'
- options:
- dataLinks: []
- percentage: false
- pointradius: 5
- points: false
- renderer: flot
- seriesOverrides: []
- spaceLength: 10
- stack: false
- steppedLine: false
- targets:
- - expr: 'mongodb_memory{instance=~"$instance",type=~"resident|virtual"}'
- format: time_series
- interval: ''
- intervalFactor: 2
- legendFormat: '{{type}}'
- refId: A
- step: 240
- thresholds: []
- timeFrom: null
- timeRegions: []
- timeShift: null
- title: Memory
- tooltip:
- shared: false
- sort: 0
- value_type: individual
- type: graph
- xaxis:
- buckets: null
- mode: time
- name: null
- show: true
- values:
- - total
- yaxes:
- - format: decmbytes
- label: MB
- logBase: 1
- max: null
- min: null
- show: true
- - format: short
- label: null
- logBase: 1
- max: null
- min: null
- show: true
- yaxis:
- align: false
- alignLevel: null
- - aliasColors: {}
- bars: false
- dashLength: 10
- dashes: false
- datasource: Prometheus
- fill: 1
- fillGradient: 0
- gridPos:
- h: 6
- w: 12
- x: 12
- 'y': 13
- id: 5
- legend:
- avg: false
- current: false
- max: false
- min: false
- show: true
- total: false
- values: false
- lines: true
- linewidth: 1
- links: []
- nullPointMode: 'null'
- options:
- dataLinks: []
- percentage: false
- pointradius: 5
- points: false
- renderer: flot
- seriesOverrides: []
- spaceLength: 10
- stack: false
- steppedLine: false
- targets:
- - expr: >-
- 'rate(mongodb_network_bytes_total{instance=~"$instance"}[$interval])'
- format: time_series
- interval: ''
- intervalFactor: 2
- legendFormat: '{{state}}'
- metric: mongodb_metrics_operation_total
- refId: A
- step: 240
- thresholds: []
- timeFrom: null
- timeRegions: []
- timeShift: null
- title: Network I/O
- tooltip:
- shared: true
- sort: 0
- value_type: individual
- type: graph
- xaxis:
- buckets: null
- mode: time
- name: null
- show: true
- values: []
- yaxes:
- - format: decbytes
- label: null
- logBase: 1
- max: null
- min: null
- show: true
- - format: short
- label: null
- logBase: 1
- max: null
- min: null
- show: true
- yaxis:
- align: false
- alignLevel: null
-refresh: 5s
-schemaVersion: 19
-style: dark
-tags: []
-templating:
- list:
- - allValue: null
- current:
- text: All
- value: $__all
- datasource: Prometheus
- definition: ''
- hide: 0
- includeAll: true
- label: instance
- multi: true
- name: instance
- options: []
- query: 'label_values(mongodb_connections, instance)'
- refresh: 1
- regex: ''
- skipUrlSync: false
- sort: 1
- tagValuesQuery: /.*-(.*?)-.*/
- tags: []
- tagsQuery: 'label_values(mongodb_connections, instance)'
- type: query
- useTags: false
- - auto: true
- auto_count: 30
- auto_min: 10s
- current:
- text: auto
- value: $__auto_interval_interval
- hide: 0
- label: null
- name: interval
- options:
- - selected: true
- text: auto
- value: $__auto_interval_interval
- - selected: false
- text: 1m
- value: 1m
- - selected: false
- text: 10m
- value: 10m
- - selected: false
- text: 30m
- value: 30m
- - selected: false
- text: 1h
- value: 1h
- - selected: false
- text: 6h
- value: 6h
- - selected: false
- text: 12h
- value: 12h
- - selected: false
- text: 1d
- value: 1d
- - selected: false
- text: 7d
- value: 7d
- - selected: false
- text: 14d
- value: 14d
- - selected: false
- text: 30d
- value: 30d
- query: '1m,10m,30m,1h,6h,12h,1d,7d,14d,30d'
- refresh: 2
- skipUrlSync: false
- type: interval
-time:
- from: now/d
- to: now
-timepicker:
- refresh_intervals:
- - 5s
- - 10s
- - 30s
- - 1m
- - 5m
- - 15m
- - 30m
- - 1h
- - 2h
- - 1d
- time_options:
- - 5m
- - 15m
- - 1h
- - 6h
- - 12h
- - 24h
- - 2d
- - 7d
- - 30d
-timezone: browser
-title: MongoDB
-uid: HEK4NbtZk
-version: 2