开启HBlock向Prometheus推送监控数据的配置 本节主要介绍如何在HBlock中开启监控数据推送配置,将HBlock监控数据推送至Prometheus的pushgateway中。 应用场景 HBlock自带监控及告警功能,Web控制台及命令行控制台均可查询监控及告警信息。 同时,HBlock也支持将自身的监控数据推送至用户侧的Prometheus平台,方便用户统一对HBlock及用户侧的其他应用进行监控。 前提条件 用户侧已安装Prometheus监控平台,以及pushgateway组件。 HBlock集群可以访问pushgateway组件的访问地址。 具体操作 1. 在HBlock中执行./stor config add i monitor命令,开启监控数据推送至pushgateway的配置。监控数据的默认采集频率为20s。 命令格式: ./stor config add i monitor pushgateway pushgatewayIp:pushgatewayPort pushgatewaylabels tag1:userdefinetag 示例1如下所示,含义:pushgateway访问地址为10.10.10.1:9091,监控数据不携带用户自定义标签 ./stor config add i monitor pushgateway 10.10.10.1:9091 示例2如下所示,含义:pushgateway访问地址为10.10.10.1:9091,监控数据携带用户自定义标签idc:idc101 ./stor config add i monitor pushgateway 10.10.10.1:9091 pushgatewaylabels idc:idc101 2. 如果使用Prometheus+Grafana方案,可以通过Grafana面板查看HBlock推送监控数据。以下为Grafana建议面板配置。 { "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" } ] }, "editable": true, "fiscalYearStartMonth": 0, "graphTooltip": 0, "id": 176, "iteration": 1718276013721, "links": [], "liveNow": false, "panels": [ { "collapsed": false, "datasource": { "type": "prometheus", "uid": "${DS}" }, "gridPos": { "h": 1, "w": 24, "x": 0, "y": 0 }, "id": 61, "panels": [], "targets": [ { "datasource": { "type": "prometheus", "uid": "${DS}" }, "refId": "A" } ], "title": "系统指标", "type": "row" }, { "datasource": { "type": "prometheus", "uid": "${DS}" }, "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null } ] }, "unit": "s" }, "overrides": [] }, "gridPos": { "h": 4, "w": 3, "x": 0, "y": 1 }, "id": 54, "options": { "colorMode": "value", "graphMode": "area", "justifyMode": "auto", "orientation": "auto", "reduceOptions": { "calcs": [ "lastNotNull" ], "fields": "", "values": false }, "textMode": "value" }, "pluginVersion": "8.4.4", "targets": [ { "datasource": { "type": "prometheus", "uid": "${DS}" }, "exemplar": false, "expr": "sum(time() hblockosboottimeseconds{idc"$idc",clusterId"$clusterId",serverIp"$serverIp", job"hblock"})", "instant": true, "interval": "", "legendFormat": "", "refId": "A" } ], "title": "系统运行时间", "type": "stat" }, { "datasource": { "type": "prometheus", "uid": "${DS}" }, "description": "一分钟内 CPU 所有内核的平均负载率", "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, "mappings": [ { "options": { "NULL": { "index": 0, "text": "N/A" } }, "type": "value" } ], "max": 100, "min": 0, "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "yellow", "value": 80 }, { "color": "red", "value": 90 } ] }, "unit": "percent" }, "overrides": [] }, "gridPos": { "h": 4, "w": 4, "x": 3, "y": 1 }, "id": 18, "options": { "orientation": "auto", "reduceOptions": { "calcs": [ "lastNotNull" ], "fields": "", "values": false }, "showThresholdLabels": false, "showThresholdMarkers": true }, "pluginVersion": "8.4.4", "targets": [ { "datasource": { "type": "prometheus", "uid": "${DS}" }, "exemplar": false, "expr": "avg(hblockload1{idc"$idc",clusterId"$clusterId",serverIp"$serverIp", job"hblock"}) / count(hblockcpusecondsidle{idc"$idc",clusterId"$clusterId",serverIp"$serverIp", job"hblock"}) 100", "interval": "", "legendFormat": "", "refId": "A" } ], "title": "CPU System Load (1m avg)", "type": "gauge" }, { "datasource": { "type": "prometheus", "uid": "${DS}" }, "description": "", "fieldConfig": { "defaults": { "color": { "mode": "paletteclassic" }, "custom": { "hideFrom": { "legend": false, "tooltip": false, "viz": false } }, "decimals": 2, "mappings": [ { "options": { "NULL": { "index": 0, "text": "N/A" } }, "type": "value" } ], "max": 100, "min": 0, "unit": "percent" }, "overrides": [ { "matcher": { "id": "byName", "options": "idle" }, "properties": [ { "id": "color", "value": { "fixedColor": "green", "mode": "fixed" } } ] }, { "matcher": { "id": "byName", "options": "usr" }, "properties": [ { "id": "color", "value": { "fixedColor": "red", "mode": "fixed" } } ] } ] }, "gridPos": { "h": 8, "w": 6, "x": 7, "y": 1 }, "id": 19, "options": { "displayLabels": [ "name" ], "legend": { "displayMode": "table", "placement": "right", "showLegend": true, "sortBy": "Value", "sortDesc": true, "values": [ "value" ] }, "pieType": "pie", "reduceOptions": { "calcs": [ "lastNotNull" ], "fields": "", "values": false }, "tooltip": { "mode": "single", "sort": "none" } }, "pluginVersion": "8.4.3", "targets": [ { "datasource": { "type": "prometheus", "uid": "${DS}" }, "exemplar": false, "expr": "avg(rate(hblockcpusecondsuser{idc"$idc",clusterId"$clusterId",serverIp"$serverIp", job"hblock"}[5m])) by (serverIp) 100", "interval": "", "legendFormat": "usr", "refId": "A" }, { "datasource": { "type": "prometheus", "uid": "${DS}" }, "exemplar": false, "expr": "avg(rate(hblockcpusecondsiowait{idc"$idc",clusterId"$clusterId",serverIp"$serverIp", job"hblock"}[5m])) by (serverIp) 100", "hide": false, "interval": "", "legendFormat": "iowait", "refId": "B" }, { "datasource": { "type": "prometheus", "uid": "${DS}" }, "exemplar": false, "expr": "avg(rate(hblockcpusecondssystem{idc"$idc",clusterId"$clusterId",serverIp"$serverIp", job"hblock"}[5m])) by (serverIp) 100", "hide": false, "interval": "", "legendFormat": "system", "refId": "C" }, { "datasource": { "type": "prometheus", "uid": "${DS}" }, "exemplar": false, "expr": "avg(rate(hblockcpusecondssoftirq{idc"$idc",clusterId"$clusterId",serverIp"$serverIp", job"hblock"}[5m])) by (serverIp) 100", "hide": false, "interval": "", "legendFormat": "softirq", "refId": "D" }, { "datasource": { "type": "prometheus", "uid": "${DS}" }, "exemplar": false, "expr": "avg(rate(hblockcpusecondsidle{idc"$idc",clusterId"$clusterId",serverIp"$serverIp", job"hblock"}[5m])) by (serverIp) 100", "hide": false, "interval": "", "legendFormat": "idle", "refId": "E" } ], "title": "CPU ", "type": "piechart" }, { "datasource": { "type": "prometheus", "uid": "${DS}" }, "fieldConfig": { "defaults": { "color": { "mode": "thresholds", "seriesBy": "last" }, "custom": { "axisLabel": "", "axisPlacement": "auto", "axisSoftMin": 0, "barAlignment": 0, "drawStyle": "line", "fillOpacity": 10, "gradientMode": "none", "hideFrom": { "legend": false, "tooltip": false, "viz": false }, "lineInterpolation": "linear", "lineWidth": 1, "pointSize": 5, "scaleDistribution": { "type": "linear" }, "showPoints": "never", "spanNulls": true, "stacking": { "group": "A", "mode": "none" }, "thresholdsStyle": { "mode": "off" } }, "mappings": [], "min": 0, "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "