Move grafana storage to persistent database

This commit is contained in:
Finn 2024-08-11 21:54:56 -07:00
parent e2e3299417
commit 4a3123655f
8 changed files with 52 additions and 24542 deletions

View file

@ -1,595 +0,0 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "datasource",
"uid": "grafana"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"target": {
"limit": 100,
"matchAny": false,
"tags": [],
"type": "dashboard"
},
"type": "dashboard"
}
]
},
"description": "Loki and Promtail metrics.",
"editable": true,
"fiscalYearStartMonth": 0,
"gnetId": 10880,
"graphTooltip": 0,
"id": 44,
"links": [],
"liveNow": false,
"panels": [
{
"datasource": {},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"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": 8,
"w": 8,
"x": 0,
"y": 0
},
"id": 10,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {},
"editorMode": "code",
"expr": "sum by (status) (\nlabel_replace(\n label_replace(\n rate(loki_request_duration_seconds_count{route=~\"api_prom_push|loki_api_v1_push\"}[$interval]),\n \"status\", \"${1}xx\", \"status_code\", \"([0-9])..\"),\n\"status\", \"${1}\", \"status_code\", \"([a-z]+)\"))",
"legendFormat": "{{status}}",
"range": true,
"refId": "A"
}
],
"title": "pushes/second",
"type": "timeseries"
},
{
"datasource": {},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 10,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "never",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"links": [],
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "short"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 8,
"x": 8,
"y": 0
},
"id": 2,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "multi",
"sort": "none"
}
},
"pluginVersion": "10.0.3",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "000000001"
},
"editorMode": "code",
"expr": "sum(rate (loki_distributor_ingester_appends_total[$interval]))",
"legendFormat": "{{instance}}",
"range": true,
"refId": "A"
}
],
"title": "Average batch appends sent to ingesters (Loki)",
"type": "timeseries"
},
{
"datasource": {},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 10,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "never",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"links": [],
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "short"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 8,
"x": 16,
"y": 0
},
"id": 8,
"interval": "",
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": false
},
"tooltip": {
"mode": "multi",
"sort": "none"
}
},
"pluginVersion": "10.0.3",
"targets": [
{
"datasource": {},
"editorMode": "code",
"expr": "rate(loki_ingester_chunk_entries_count[$interval])",
"range": true,
"refId": "A"
}
],
"title": "chunks ingested/second",
"type": "timeseries"
},
{
"datasource": {},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 10,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "never",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"links": [],
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "binBps"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 24,
"x": 0,
"y": 8
},
"id": 6,
"options": {
"legend": {
"calcs": [
"mean",
"min",
"sum"
],
"displayMode": "table",
"placement": "right",
"showLegend": true
},
"tooltip": {
"mode": "multi",
"sort": "none"
}
},
"pluginVersion": "10.0.3",
"targets": [
{
"datasource": {},
"editorMode": "code",
"exemplar": true,
"expr": "sum(rate(promtail_sent_bytes_total[$interval])) by (instance)",
"interval": "",
"legendFormat": "__auto",
"range": true,
"refId": "A"
}
],
"title": "sent by total by promtail",
"type": "timeseries"
},
{
"datasource": {},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 10,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "never",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"links": [],
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "binBps"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 24,
"x": 0,
"y": 16
},
"id": 4,
"options": {
"legend": {
"calcs": [],
"displayMode": "table",
"placement": "right",
"showLegend": true
},
"tooltip": {
"mode": "multi",
"sort": "none"
}
},
"pluginVersion": "10.0.3",
"targets": [
{
"datasource": {},
"editorMode": "code",
"expr": "sum(rate(promtail_encoded_bytes_total[$interval])) by (instance)",
"format": "time_series",
"instant": false,
"legendFormat": "{{ pod }}",
"refId": "A"
}
],
"title": "encoded by promtail",
"type": "timeseries"
}
],
"refresh": "30s",
"schemaVersion": 39,
"tags": [],
"templating": {
"list": [
{
"auto": false,
"auto_count": 30,
"auto_min": "10s",
"current": {
"selected": false,
"text": "10m",
"value": "10m"
},
"hide": 0,
"name": "interval",
"options": [
{
"selected": false,
"text": "1m",
"value": "1m"
},
{
"selected": true,
"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",
"queryValue": "",
"refresh": 2,
"skipUrlSync": false,
"type": "interval"
}
]
},
"time": {
"from": "now-24h",
"to": "now"
},
"timepicker": {
"refresh_intervals": [
"5s",
"10s",
"30s",
"1m",
"5m",
"15m",
"30m",
"1h",
"2h",
"1d"
]
},
"timezone": "",
"title": "Loki & Promtail",
"uid": "MQHVDmtWk",
"version": 5,
"weekStart": ""
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,20 @@
apiVersion: "acid.zalan.do/v1"
kind: postgresql
metadata:
name: grafana-database
spec:
teamId: grafana
volume:
size: 1Gi
numberOfInstances: 2
users:
superuser:
- superuser
- createdb
grafana: []
databases:
grafana: grafana
preparedDatabases:
grafana: {}
postgresql:
version: "16"

View file

@ -6,16 +6,11 @@ resources:
- ingresses.yaml
- secrets.yaml
- oauth2-proxy.yaml
- grafana-database.yaml
secretGenerator:
- name: additional-scrape-configs
options:
disableNameSuffixHash: true
files:
- prom-scrape-configs/scrape-configs.yaml
configMapGenerator:
- name: grafana-dashboards-custom
options:
disableNameSuffixHash: true
files:
- grafana-dashboards/loki-and-promtail.json
- grafana-dashboards/node-exporter-full.json

View file

@ -4,16 +4,29 @@
- secretRef:
name: grafana-secrets
- op: add
path: /spec/template/spec/containers/0/volumeMounts/-
path: /spec/template/spec/containers/0/env
value:
mountPath: /grafana-dashboard-definitions/1
name: grafana-dashboards-custom
- op: add
path: /spec/template/spec/volumes/-
value:
name: grafana-dashboards-custom
configMap:
name: grafana-dashboards-custom
- name: DATABASE_USER
valueFrom:
secretKeyRef:
name: grafana.grafana-database.credentials.postgresql.acid.zalan.do
key: username
- name: DATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: grafana.grafana-database.credentials.postgresql.acid.zalan.do
key: password
# - op: add
# path: /spec/template/spec/containers/0/volumeMounts/-
# value:
# mountPath: /grafana-dashboard-definitions/1
# name: grafana-dashboards-custom
# - op: add
# path: /spec/template/spec/volumes/-
# value:
# name: grafana-dashboards-custom
# configMap:
# name: grafana-dashboards-custom
# - op: replace
# path: /spec/template/spec/automountServiceAccountToken
# value: true

View file

@ -1,25 +0,0 @@
{
"apiVersion": 1,
"providers": [
{
"folder": "Default",
"folderUid": "",
"name": "0",
"options": {
"path": "/grafana-dashboard-definitions/0"
},
"orgId": 1,
"type": "file"
},
{
"folder": "Janky Solutions",
"folderUid": "",
"name": "1",
"options": {
"path": "/grafana-dashboard-definitions/1"
},
"orgId": 1,
"type": "file"
}
]
}

View file

@ -45,3 +45,11 @@ region = sea-01
;path =
access_key = BOx3M6NesE3HilaWg9PJ
secret_key = $__env{S3_SECRET_ACCESS_KEY}
[database]
type = postgres
host = grafana-database
name = grafana
user = $__env{DATABASE_USER}
password = $__env{DATABASE_PASSWORD}
ssl_mode = require

View file

@ -46,10 +46,3 @@ secretGenerator:
behavior: replace
files:
- grafana/datasources.yaml
configMapGenerator:
- name: grafana-dashboards
namespace: monitoring
behavior: replace
files:
- grafana/dashboards.yaml