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

Add barebones Grafana Dashboard setup #15

Merged
merged 2 commits into from
Jun 18, 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.mypy_cache
docker-stack.yml
.env
postgres/dumps
15 changes: 14 additions & 1 deletion docker-compose.override.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: "3.3"
services:

proxy:
Expand Down Expand Up @@ -36,6 +35,11 @@ services:
ports:
- "5050:5050"

db:
volumes:
- ./postgres/dumps/:/docker-entrypoint-initdb.d/


backend:
ports:
- "8888:8888"
Expand All @@ -58,6 +62,15 @@ services:
- traefik.http.routers.${STACK_NAME?Variable not set}-backend-http.rule=PathPrefix(`/api`) || PathPrefix(`/docs`) || PathPrefix(`/redoc`)
- traefik.http.services.${STACK_NAME?Variable not set}-backend.loadbalancer.server.port=80

grafana:
ports:
- "3000:3000"
labels:
- traefik.enable=true
- traefik.constraint-label-stack=${TRAEFIK_TAG?Variable not set}
- traefik.http.routers.${STACK_NAME?Variable not set}-grafana-http.rule=Host(`${DOMAIN?Variable not set}`)
- traefik.http.services.${STACK_NAME?Variable not set}-grafana.loadbalancer.server.port=3000

networks:
traefik-public:
# For local dev, don't expect an external Traefik network
Expand Down
30 changes: 29 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: "3.8"
services:

proxy:
Expand Down Expand Up @@ -131,6 +130,35 @@ services:
- traefik.http.routers.${STACK_NAME?Variable not set}-backend-http.rule=PathPrefix(`/api`) || PathPrefix(`/docs`) || PathPrefix(`/redoc`)
- traefik.http.services.${STACK_NAME?Variable not set}-backend.loadbalancer.server.port=80

grafana:
image: grafana/grafana-oss:latest
networks:
- ${TRAEFIK_PUBLIC_NETWORK?Variable not set}
- default
env_file:
- .env
environment:
- GF_SECURITY_ADMIN_USER=${GF_ADMIN_USER?Variable not set}
- GF_SECURITY_ADMIN_PASSWORD=${GF_ADMIN_PASSWORD?Variable not set}
# add privisioning path
- GF_PATHS_PROVISIONING=/etc/grafana/provisioning
volumes:
- ./grafana/provisioning:/etc/grafana/provisioning
- ./grafana/dashboards:/var/lib/grafana/dashboards
deploy:
labels:
- traefik.enable=true
- traefik.docker.network=${TRAEFIK_PUBLIC_NETWORK?Variable not set}
- traefik.constraint-label=${TRAEFIK_PUBLIC_TAG?Variable not set}
- traefik.http.routers.${STACK_NAME?Variable not set}-grafana-http.rule=Host(`grafana.${DOMAIN?Variable not set}`)
- traefik.http.routers.${STACK_NAME?Variable not set}-grafana-http.entrypoints=http
- traefik.http.routers.${STACK_NAME?Variable not set}-grafana-http.middlewares=${STACK_NAME?Variable not set}-https-redirect
- traefik.http.routers.${STACK_NAME?Variable not set}-grafana-https.rule=Host(`grafana.${DOMAIN?Variable not set}`)
- traefik.http.routers.${STACK_NAME?Variable not set}-grafana-https.entrypoints=https
- traefik.http.routers.${STACK_NAME?Variable not set}-grafana-https.tls=true
- traefik.http.routers.${STACK_NAME?Variable not set}-grafana-https.tls.certresolver=le
- traefik.http.services.${STACK_NAME?Variable not set}-grafana.loadbalancer.server.port=3000

volumes:
app-db-data:

Expand Down
287 changes: 287 additions & 0 deletions grafana/dashboards/generator_dashboard.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,287 @@
{
"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": {
"type": "grafana-postgresql-datasource",
"uid": "P44368ADAD746BC27"
},
"fieldConfig": {
"defaults": {
"color": {
"fixedColor": "blue",
"mode": "fixed"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "bars",
"fillOpacity": 90,
"gradientMode": "scheme",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 1,
"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": 9,
"w": 24,
"x": 0,
"y": 0
},
"id": 1,
"options": {
"legend": {
"calcs": [],
"displayMode": "hidden",
"placement": "right",
"showLegend": false
},
"tooltip": {
"maxHeight": 600,
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "11.0.0",
"targets": [
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "P44368ADAD746BC27"
},
"editorMode": "code",
"format": "table",
"rawQuery": true,
"rawSql": "SELECT $__timeGroupAlias(\"timestamp\",'1w'),\n COUNT(DISTINCT name) as \"Number of Licenses\"\nFROM license\nWHERE name NOT LIKE '%test%'\nGROUP BY time",
"refId": "Count Number of Licenses over Time",
"sql": {
"columns": [
{
"parameters": [
{
"name": "\"timestamp\"",
"type": "functionParameter"
}
],
"type": "function"
},
{
"parameters": [
{
"name": "name",
"type": "functionParameter"
}
],
"type": "function"
}
],
"groupBy": [
{
"property": {
"name": "\"timestamp\"",
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
},
"table": "license"
}
],
"title": "Number of Licenses Created ",
"type": "timeseries"
},
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "P44368ADAD746BC27"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"fillOpacity": 80,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineWidth": 1,
"stacking": {
"group": "A",
"mode": "none"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 9
},
"id": 2,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
}
},
"targets": [
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "P44368ADAD746BC27"
},
"editorMode": "code",
"format": "table",
"rawQuery": true,
"rawSql": "SELECT COUNT(name)\nFROM license\nGROUP BY name",
"refId": "A",
"sql": {
"columns": [
{
"parameters": [],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
}
}
],
"title": "Number of Edits of a License",
"type": "histogram"
}
],
"refresh": "",
"schemaVersion": 39,
"tags": [
"kubernetes"
],
"templating": {
"list": []
},
"time": {
"from": "2024-02-29T23:00:00.000Z",
"to": "now"
},
"timeRangeUpdatedDuringEditOrView": false,
"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": "Cluster",
"uid": "fdp5e17m7wkqoc",
"version": 4,
"weekStart": ""
}
12 changes: 12 additions & 0 deletions grafana/provisioning/dashboards/default.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: 1

providers:
- name: "Dashboard provider"
orgId: 1
type: file
disableDeletion: false
updateIntervalSeconds: 10
allowUiUpdates: true
options:
path: /var/lib/grafana/dashboards
foldersFromFilesStructure: true
Loading
Loading