Skip to content

Commit

Permalink
Merge pull request #37 from hasanheroglu/35-saving-the-dashboard-conf…
Browse files Browse the repository at this point in the history
…ig-in-git

add provision config for grafana
  • Loading branch information
egekorkan authored Sep 13, 2024
2 parents 072fb5f + 494e53d commit 4bdd87e
Show file tree
Hide file tree
Showing 5 changed files with 178 additions and 3 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,13 @@ A username and password should be generated for running the services. To do so:
For running the things separately, using their `Dockerfile`'s, `docker build -t <image-tag> -f ./Dockerfile ../../` command must be used to give the context to be able to copy `tm.json` into the container.

For Node.js-based devices, we use npm workspaces and running `npm install` at the root directory installs all the packages needed for every device. After packages are installed, running `node main.js` would run the thing. For port configuration, running either `node main.js -p 1000` or `node main.js --port 1000` would start the thing on port 1000.

### Saving Grafana Dashboards

Grafana dashboard json files are stored in [./conf/grafana/dashboards](./conf//grafana//dashboards/).
To save your newly created dashboard locally and push it into the remote repository:
- Export the dashboard as JSON file using Share > Export.
- Save the exported JSON file to [./conf/grafana/dashboards](./conf//grafana//dashboards/).

If your dashboard uses another datasource than our default `prometheus-datasource`, new datasource also must be provisioned in [./conf/grafana/datasources](./conf/grafana/provisioning/datasources/).
For more information check Grafana's provisioning [documentation](https://grafana.com/docs/grafana/latest/administration/provisioning/).
142 changes: 142 additions & 0 deletions conf/grafana/dashboards/dashboard.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"id": 1,
"links": [],
"panels": [
{
"datasource": {
"default": true,
"type": "prometheus",
"uid": "adwznwwq8yupse"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": true,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"barWidthFactor": 0.5,
"drawStyle": "bars",
"fillOpacity": 100,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "smooth",
"lineWidth": 2,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
},
"id": 1,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "right",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "adwznwwq8yupse"
},
"disableTextWrap": false,
"editorMode": "builder",
"expr": "changes(traefik_service_requests_total{protocol=\"http\", service=\"http-express-calculator-simple-test-things@docker\"}[1m])",
"fullMetaSearch": false,
"includeNullMetadata": true,
"instant": false,
"legendFormat": "Status Code:{{code}}",
"range": true,
"refId": "A",
"useBackend": false
}
],
"title": "HTTP Express Calculator GET Requests",
"type": "timeseries"
}
],
"refresh": "",
"schemaVersion": 39,
"tags": [],
"templating": {
"list": []
},
"time": {
"from": "now-1h",
"to": "now"
},
"timepicker": {},
"timezone": "browser",
"title": "HTTP Services",
"uid": "bdwzocnv714hsd",
"version": 1,
"weekStart": ""
}
11 changes: 11 additions & 0 deletions conf/grafana/provisioning/dashboards/dashboard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: 1

providers:
- name: "default"
orgId: 1
folder: ""
type: file
disableDeletion: false
updateIntervalSeconds: 10
options:
path: /var/lib/grafana/dashboards
10 changes: 10 additions & 0 deletions conf/grafana/provisioning/datasources/datasource.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: 1

datasources:
- name: prometheus-datasource
uid: adwznwwq8yupse #THIS IS IMPORTANT ON THE DASHBOARD MUST BE THE SAME
orgId: 1
type: prometheus
access: proxy
url: http://prometheus:${PROMETHEUS_PORT}
isDefault: true
8 changes: 5 additions & 3 deletions docker-compose-infra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ services:
- cadvisor
grafana:
image: grafana/grafana
environment:
- PROMETHEUS_PORT=${PROMETHEUS_PORT}
volumes:
- ./conf/grafana/provisioning:/etc/grafana/provisioning
- ./conf/grafana/dashboards:/var/lib/grafana/dashboards
- grafana_data:/var/lib/grafana
environment:
GF_INSTALL_PLUGINS: grafana-piechart-panel
labels:
- "traefik.http.routers.grafana.rule=Host(`grafana.${HOSTNAME}`)"
- "traefik.http.routers.grafana.service=grafana"
Expand Down Expand Up @@ -124,6 +126,6 @@ services:
cpus: '0.05'
memory: 50M
volumes:
grafana_data:
prometheus_data:
grafana_data:
portainer_data:

0 comments on commit 4bdd87e

Please sign in to comment.