发布时间:2020-08-05 09:19:47编辑:admin阅读(3366)
Minio支持集成prometheus,用以监控CPU、硬盘、网络等数据。
官方的给docker-compose.yaml,默认是不能访问metric数据的。
这里配置用是"public"类型,无身份认证。
需要在docker-compose.yaml中,增加一个环境变量即可。
MINIO_PROMETHEUS_AUTH_TYPE: public
在上篇文章,链接如下:
https://www.cnblogs.com/xiao987334176/p/13256553.html
还没有配置主机目录映射,因此,这里就一并修改了,完整内容如下:
version: '3.7' # starts 4 docker containers running minio server instances. Each # minio server's web interface will be accessible on the host at port # 9001 through 9004. services: minio1: image: minio/minio:RELEASE.2020-07-02T00-15-09Z volumes: - /data/minio-cluster/minio1/data1:/data1 - /data/minio-cluster/minio1/data2:/data2 ports: - "9001:9000" environment: MINIO_ACCESS_KEY: minio MINIO_SECRET_KEY: minio123 MINIO_PROMETHEUS_AUTH_TYPE: public command: server http://minio{1...4}/data{1...2} healthcheck: test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"] interval: 30s timeout: 20s retries: 3 minio2: image: minio/minio:RELEASE.2020-07-02T00-15-09Z volumes: - /data/minio-cluster/minio2/data1:/data1 - /data/minio-cluster/minio2/data2:/data2 ports: - "9002:9000" environment: MINIO_ACCESS_KEY: minio MINIO_SECRET_KEY: minio123 MINIO_PROMETHEUS_AUTH_TYPE: public command: server http://minio{1...4}/data{1...2} healthcheck: test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"] interval: 30s timeout: 20s retries: 3 minio3: image: minio/minio:RELEASE.2020-07-02T00-15-09Z volumes: - /data/minio-cluster/minio3/data1:/data1 - /data/minio-cluster/minio3/data2:/data2 ports: - "9003:9000" environment: MINIO_ACCESS_KEY: minio MINIO_SECRET_KEY: minio123 MINIO_PROMETHEUS_AUTH_TYPE: public command: server http://minio{1...4}/data{1...2} healthcheck: test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"] interval: 30s timeout: 20s retries: 3 minio4: image: minio/minio:RELEASE.2020-07-02T00-15-09Z volumes: - /data/minio-cluster/minio4/data1:/data1 - /data/minio-cluster/minio4/data2:/data2 ports: - "9004:9000" environment: MINIO_ACCESS_KEY: minio MINIO_SECRET_KEY: minio123 MINIO_PROMETHEUS_AUTH_TYPE: public command: server http://minio{1...4}/data{1...2} healthcheck: test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"] interval: 30s timeout: 20s retries: 3
创建主机目录
mkdir -p /data/minio-cluster/minio{1,2,3,4}/data{1,2}
启动docker-compose
docker-compose up -d
http://192.168.31.34:9001/minio/prometheus/metrics
效果如下:
将端口改为9002~9004,也是同样的结果。
修改prometheus.yml,增加job_name
- job_name: minio metrics_path: /minio/prometheus/metrics scrape_interval: 10s scheme: http static_configs: - targets: ['192.168.31.34:9001','192.168.31.34:9002','192.168.31.34:9003','192.168.31.34:9004']
修改完成后,重启prometheus
访问targets,确保都是UP状态
推荐使用模板:https://grafana.com/grafana/dashboards/12063
这个模板执行选择Minio节点,而且还是中文显示的。
注意:其他的Minio模板,虽然星级很高,下载次数也比较多。但是发现都不合适!
导入模板后,效果如下:
但是发现关于s3相关图表,数据是空的。
需要修改图表中的metrics计算公式才行。
先来看S3接口总请求,对应的metrics计算公式为:
sum(s3_requests_total{instance="172.16.62.150:9000",job="minio-metrics"}) by (api)
它需要key为s3_requests_total的值。
我们再去这几个metrics中去查找
http://192.168.31.34:9001/minio/prometheus/metrics http://192.168.31.34:9002/minio/prometheus/metrics http://192.168.31.34:9003/minio/prometheus/metrics http://192.168.31.34:9004/minio/prometheus/metrics
发现只有第一个才有s3_requests_total的值。
因此metrics的计算公式为:
sum(s3_requests_total{api="listobjectsv1"}) by (api)
修改完成之后,图表数据就有了。
附上其他图表的正确计算公式:
S3接口当前总请求数 sum(s3_requests_current{api="listobjectsv1"}) by (api) S3接口总错误请求数 sum(s3_errors_total{api="listobjectsv1",job="$job"}) by (api) sum(s3_requests_current{api="listobjectsv1",job="$job"}) by (api) S3接口延迟统计 s3_ttfb_seconds_sum{api="listobjectsv1"}
对于S3接口总错误请求数,需要修改一下Legend,做一下标识区分。
最终总体效果如下:
本文参考链接:
https://www.cnblogs.com/rongfengliang/p/12017914.html
https://blog.csdn.net/kuang1144/article/details/105302960
47303
45507
36587
34101
28810
25424
24274
19469
18914
17483
5304°
5904°
5403°
5488°
6375°
5220°
5219°
5731°
5687°
6996°