This commit is contained in:
孙小云 2025-09-10 16:27:31 +08:00
parent 1197b1d73f
commit 8e67c01540
3 changed files with 65 additions and 0 deletions

View File

@ -0,0 +1,52 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: grafana-dash-provisioning
namespace: default
data:
dashboards.yml: |
apiVersion: 1
providers:
- name: 'Default'
orgId: 1
type: file
disableDeletion: false
editable: true
options:
path: /var/lib/grafana/dashboards
---
apiVersion: v1
kind: ConfigMap
metadata:
name: grafana-dashboard-aserver
namespace: default
data:
aserver-dashboard.json: |
{
"id": null,
"uid": "aserver-qps",
"title": "AServer Requests",
"timezone": "browser",
"schemaVersion": 38,
"version": 1,
"editable": true,
"style": "dark",
"time": { "from": "now-15m", "to": "now" },
"panels": [
{
"type": "timeseries",
"title": "Requests per second by endpoint",
"gridPos": { "x": 0, "y": 0, "w": 24, "h": 8 },
"targets": [
{
"expr": "sum by (endpoint) (rate(aserver_http_requests_total[1m]))",
"legendFormat": "{{endpoint}}",
"refId": "A",
"datasource": { "type": "prometheus", "uid": "Prometheus" }
}
]
}
]
}

View File

@ -38,6 +38,12 @@ spec:
- name: grafana-provisioning
mountPath: /etc/grafana/provisioning/datasources
readOnly: true
- name: grafana-dash-provisioning
mountPath: /etc/grafana/provisioning/dashboards
readOnly: true
- name: grafana-dashboards
mountPath: /var/lib/grafana/dashboards
readOnly: true
volumes:
- name: grafana-storage
hostPath:
@ -46,6 +52,12 @@ spec:
- name: grafana-provisioning
configMap:
name: grafana-datasource
- name: grafana-dash-provisioning
configMap:
name: grafana-dash-provisioning
- name: grafana-dashboards
configMap:
name: grafana-dashboard-aserver
---
apiVersion: v1
kind: Service

View File

@ -4,6 +4,7 @@ set -euo pipefail
echo "开始安装 Grafana..."
sudo chown -R 65534:65534 /opt/prometheus/data
kubectl apply -f grafana-datasource.yaml
kubectl apply -f grafana-dash-provisioning.yaml
kubectl apply -f grafana-deployment.yaml
kubectl apply -f grafana-service.yaml
kubectl apply -f grafana-ingress.yaml