diff options
author | Bartek Grzybowski <b.grzybowski@partner.samsung.com> | 2021-06-16 16:02:03 +0200 |
---|---|---|
committer | Bartek Grzybowski <b.grzybowski@partner.samsung.com> | 2021-06-17 08:41:42 +0200 |
commit | 75093a62fdb06bdf672b90e7c1da9a356a6397c7 (patch) | |
tree | da6d6ae81639118adbde20dc10ce96f9fce956fd | |
parent | 86552728e74958d9b0562f747ad83575f614c882 (diff) |
[ANSIBLE] Configure custom Grafana dashboard
A new dashboard provider is set up in Grafana which reads
the dash json definition from the file uploaded to Grafana PV
Change-Id: I2704fe85e838e9aba2a846172334af467b9f2045
Issue-ID: INT-1926
Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
4 files changed, 346 insertions, 1 deletions
diff --git a/ansible/roles/kube-prometheus-stack/defaults/main.yml b/ansible/roles/kube-prometheus-stack/defaults/main.yml index d6b49d47..74d6564a 100644 --- a/ansible/roles/kube-prometheus-stack/defaults/main.yml +++ b/ansible/roles/kube-prometheus-stack/defaults/main.yml @@ -7,6 +7,19 @@ kube_prometheus_stack: helm_values: grafana: adminPassword: admin + dashboardProviders: + dashboardproviders.yaml: + apiVersion: 1 + providers: + - name: 'custom' + orgId: 1 + folder: 'Custom' + type: file + disableDeletion: false + editable: true + updateIntervalSeconds: 60 + options: + path: /var/lib/grafana/dashboards/custom persistence: type: pvc enabled: true @@ -26,4 +39,3 @@ kube_prometheus_stack: resources: requests: storage: 6Gi - selector: {} diff --git a/ansible/roles/kube-prometheus-stack/files/grafana_dashboard.json b/ansible/roles/kube-prometheus-stack/files/grafana_dashboard.json new file mode 100644 index 00000000..1912dd82 --- /dev/null +++ b/ansible/roles/kube-prometheus-stack/files/grafana_dashboard.json @@ -0,0 +1,327 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": 26, + "links": [], + "panels": [ + { + "alert": { + "alertRuleTags": {}, + "conditions": [ + { + "evaluator": { + "params": [ + 24000 + ], + "type": "gt" + }, + "operator": { + "type": "and" + }, + "query": { + "params": [ + "A", + "5m", + "now" + ] + }, + "reducer": { + "params": [], + "type": "last" + }, + "type": "query" + } + ], + "executionErrorState": "alerting", + "for": "5m", + "frequency": "1m", + "handler": 1, + "name": "Open fds high", + "noDataState": "no_data", + "notifications": [] + }, + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fieldConfig": { + "defaults": {}, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 11, + "w": 24, + "x": 0, + "y": 0 + }, + "hiddenSeries": false, + "id": 4, + "legend": { + "alignAsTable": true, + "avg": false, + "current": true, + "max": true, + "min": false, + "rightSide": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.5.5", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "exemplar": true, + "expr": "node_filefd_allocated", + "interval": "", + "legendFormat": "{{instance}}", + "refId": "A" + } + ], + "thresholds": [ + { + "colorMode": "critical", + "fill": true, + "line": true, + "op": "gt", + "value": 24000, + "visible": true + } + ], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Nodes open fds", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:279", + "decimals": null, + "format": "short", + "label": "open fds", + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "$$hashKey": "object:280", + "format": "short", + "label": "", + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "datasource": null, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 40000 + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 24, + "x": 0, + "y": 11 + }, + "id": 2, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "last" + ], + "fields": "", + "values": false + }, + "text": {}, + "textMode": "value_and_name" + }, + "pluginVersion": "7.5.5", + "targets": [ + { + "exemplar": true, + "expr": "node_filefd_allocated", + "hide": false, + "instant": false, + "interval": "", + "legendFormat": "{{instance}}", + "refId": "A" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Node open fds", + "type": "stat" + }, + { + "datasource": null, + "description": "Is node ready", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [ + { + "from": "", + "id": 1, + "text": "NotReady", + "to": "", + "type": 1, + "value": "0" + }, + { + "from": "", + "id": 2, + "text": "ready", + "to": "", + "type": 1, + "value": "1" + } + ], + "max": 1, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "dark-red", + "value": 0 + }, + { + "color": "semi-dark-green", + "value": 1 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 20 + }, + "id": 6, + "options": { + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true, + "text": {} + }, + "pluginVersion": "7.5.5", + "targets": [ + { + "exemplar": true, + "expr": "kube_node_status_condition{condition=\"Ready\",status=\"true\"}", + "interval": "", + "legendFormat": "{{node}}", + "refId": "A" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Node readiness", + "type": "gauge" + } + ], + "schemaVersion": 27, + "style": "dark", + "tags": [], + "templating": { + "list": [] + }, + "time": { + "from": "now-6h", + "to": "now" + }, + "timepicker": {}, + "timezone": "", + "title": "Custom Dashboard", + "uid": "9Q97TIqGz", + "version": 13 +} diff --git a/ansible/roles/kube-prometheus-stack/molecule/default/molecule.yml b/ansible/roles/kube-prometheus-stack/molecule/default/molecule.yml index 17bfcd3a..c1eafa3b 100644 --- a/ansible/roles/kube-prometheus-stack/molecule/default/molecule.yml +++ b/ansible/roles/kube-prometheus-stack/molecule/default/molecule.yml @@ -23,5 +23,6 @@ provisioner: all: app_name: onap app_data_path: "/opt/{{ app_name }}" + nfs_mount_path: "/nfs" verifier: name: testinfra diff --git a/ansible/roles/kube-prometheus-stack/tasks/main.yml b/ansible/roles/kube-prometheus-stack/tasks/main.yml index 596e4b5a..e190b758 100644 --- a/ansible/roles/kube-prometheus-stack/tasks/main.yml +++ b/ansible/roles/kube-prometheus-stack/tasks/main.yml @@ -10,6 +10,11 @@ dest: "{{ kube_prometheus_stack.helm_values_file }}" content: "{{ kube_prometheus_stack.helm_values | combine(kube_prometheus_helm_values | default({}), recursive=True) | to_nice_yaml }}" +- name: Upload custom Grafana dashboard + copy: + src: grafana_dashboard.json + dest: "{{ nfs_mount_path }}/kube-prometheus/kube-prometheus-grafana/dashboards/custom/" + - name: "Install Helm release {{ kube_prometheus_stack.helm_release_name }}" community.kubernetes.helm: release_name: "{{ kube_prometheus_stack.helm_release_name }}" |