mysql
用docker启动exporter
docker run -d \
-p 9104:9104 \
--network my-mysql-network \
-e DATA_SOURCE_NAME="mysqlexporter:mysqlexporter@(192.168.147.46:3306)/" \
prom/mysqld-exporter
给集群中的prometheus添加该exporter的数据
First, you will need to create the additional configuration. Below we are making a simple “prometheus” config. Name this prometheus-additional.yaml or something similar.
- job_name: "prometheus"
static_configs:
- targets: ["localhost:9090"]
Then you will need to make a secret out of this configuration. 其中additional-scrape-configs可以改成自己的名字,比如mysql-exporter-config,到Prometheus编辑的时候,注意要保持一致
kubectl create secret generic additional-scrape-configs --from-file=prometheus-additional.yaml --dry-run=client -oyaml > additional-scrape-configs.yaml
Next, apply the generated kubernetes manifest
kubectl apply -f additional-scrape-configs.yaml -n monitoring
Finally, reference this additional configuration in your prometheus.yaml CRD.
此处要用kubectl -n cattle-prometheus edit prometheus去编辑,
apiVersion: monitoring.coreos.com/v1
kind: Prometheus
metadata:
name: prometheus
labels:
prometheus: prometheus
spec:
replicas: 2
serviceAccountName: prometheus
serviceMonitorSelector:
matchLabels:
team: frontend
additionalScrapeConfigs:
name: additional-scrape-configs
key: prometheus-additional.yaml
additional-scrape-config
mysql-exporter
add the scrape config
granfa添加模板:
登录granfa,账号密码默认为admin/admin
添加完数据源添加dashboard,从下面链接去下载模板json文件,如果是离线环境
MySQL dashboard下载
redis
https://www.cnblogs.com/fsckzy/p/12053604.html