Skip to content

Commit a34db27

Browse files
committed
charts: add grafana dashboards and deploy as configmap
1 parent 4eaeacb commit a34db27

File tree

9 files changed

+94
-22
lines changed

9 files changed

+94
-22
lines changed

docs/logging_monitoring.md

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -122,21 +122,7 @@ web-based interface.
122122
123123
#### Dashboards
124124
125-
To view the default metrics in the included default dashboard, upload the dashboard
126-
JSON file to the Grafana server:
127-
128-
```sh
129-
curl localhost:3000/api/dashboards/db \
130-
-H "Content-Type: application/json" \
131-
--data "{\"dashboard\": $(cat resources/configs/grafana/default_dashboard.json)}"
132-
```
133-
134-
Note the URL in the reply from the server (example):
135-
136-
```sh
137-
{"folderUid":"","id":2,"slug":"default-warnet-dashboard","status":"success","uid":"fdu0pda1z6a68b","url":"/d/fdu0pda1z6a68b/default-warnet-dashboard","version":1}(
138-
```
139-
140-
Open the dashboard in your browser (example):
141-
142-
`http://localhost:3000/d/fdu0pda1z6a68b/default-warnet-dashboard`
125+
Grafana dashboards are described in JSON files. A default Warnet dashboard
126+
is included and any other json files in the `/resources/charts/grafana-dashboards/files` directory
127+
will also be deployed to the web server. The Grafana UI itself also has an API
128+
for creating, exporting, and importing other dashboard files.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v2
2+
name: grafana-dashboards
3+
description: A Helm chart for Kubernetes
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 0.1.0
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
# It is recommended to use it with quotes.
24+
appVersion: "1.16.0"

resources/configs/grafana/default_dashboard.json renamed to resources/charts/grafana-dashboards/files/default_dashboard.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
],
2525
"title": "Outbound connections",
2626
"type": "timeseries",
27-
"gridPos": {
27+
"gridPos":
28+
{
2829
"h": 8,
2930
"w": 24,
3031
"x": 0,
@@ -52,7 +53,8 @@
5253
],
5354
"title": "Inbound connections",
5455
"type": "timeseries",
55-
"gridPos": {
56+
"gridPos":
57+
{
5658
"h": 8,
5759
"w": 24,
5860
"x": 0,
@@ -80,7 +82,8 @@
8082
],
8183
"title": "Mempool size",
8284
"type": "timeseries",
83-
"gridPos": {
85+
"gridPos":
86+
{
8487
"h": 8,
8588
"w": 24,
8689
"x": 0,
@@ -108,7 +111,8 @@
108111
],
109112
"title": "Blocks",
110113
"type": "timeseries",
111-
"gridPos": {
114+
"gridPos":
115+
{
112116
"h": 8,
113117
"w": 24,
114118
"x": 0,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Grafana dashboards deployed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: grafana-dashboards-config
5+
data:
6+
{{- $files := .Files.Glob "files/*.json" }}
7+
{{- range $path, $file := $files }}
8+
{{ base $path }}: |-
9+
{{ $file | toString | indent 4 }}
10+
{{- end }}

resources/manifests/grafana_values.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,25 @@ datasources:
1212
- name: Loki
1313
type: loki
1414
url: http://loki-gateway.warnet-logging:80
15+
dashboardProviders:
16+
dashboardproviders.yaml:
17+
apiVersion: 1
18+
providers:
19+
- name: 'default'
20+
orgId: 1
21+
folder: ''
22+
type: file
23+
disableDeletion: false
24+
editable: true
25+
options:
26+
path: /var/lib/grafana/dashboards/default
27+
extraVolumeMounts:
28+
- name: grafana-dashboards-volume
29+
mountPath: /var/lib/grafana/dashboards/default
30+
extraVolumes:
31+
- name: grafana-dashboards-volume
32+
configMap:
33+
name: grafana-dashboards-config
1534
grafana.ini:
1635
auth:
1736
disable_login_form: true

src/warnet/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,5 +95,6 @@
9595
f"helm upgrade --install --namespace warnet-logging --create-namespace --values {MANIFESTS_DIR}/loki_values.yaml loki grafana/loki --version 5.47.2",
9696
"helm upgrade --install --namespace warnet-logging promtail grafana/promtail",
9797
"helm upgrade --install --namespace warnet-logging prometheus prometheus-community/kube-prometheus-stack --namespace warnet-logging --set grafana.enabled=false",
98+
f"helm upgrade --install grafana-dashboards {CHARTS_DIR}/grafana-dashboards --namespace warnet-logging",
9899
f"helm upgrade --install --namespace warnet-logging loki-grafana grafana/grafana --values {MANIFESTS_DIR}/grafana_values.yaml",
99100
]

test/logging_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ def get_five_values_for_metric(metric):
118118
self.wait_for_predicate(lambda: get_five_values_for_metric("blocks"))
119119
self.wait_for_predicate(lambda: get_five_values_for_metric("txrate"))
120120

121+
# Verify default dashboard exists
122+
dbs = requests.get(f"{GRAFANA_URL}api/search").json()
123+
assert dbs[0]["title"] == "Default Warnet Dashboard"
124+
121125

122126
if __name__ == "__main__":
123127
test = LoggingTest()

0 commit comments

Comments
 (0)