- 1.安装go环境
- 2.安装openvpn_exporter
- 3.设置OpenVPN服务器状态日志文件的路径
- 4.编译成openvpn_exporter
- 5.修改prometheus
- 6.添加模版
- 7.systemd启动
go下载地址: https://golang.org/dl/
openvpn_exporter下载地址:https://github.com/kumina/openvpn_exporter/releases
wget https://golang.org/dl/go1.15.2.linux-amd64.tar.gz tar -C /usr/local -xzf go1.15.2.linux-amd64.tar.gz #添加环境变量 vim ~/.bashrc #追后一行添加 PATH=$PATH:$HOME/bin:/usr/local/go/bin source ~/.bashrc2.安装openvpn_exporter
mkdir -p /opt/tools wget https://github.com/kumina/openvpn_exporter/archive/v0.3.0.tar.gz tar xzf v0.3.0.tar.gz cd openvpn_exporter-0.3.0/3.设置OpenVPN服务器状态日志文件的路径
vim main.og
...
func main() {
var (
listenAddress = flag.String("web.listen-address", ":9176", "Address to listen on for web interface and telemetry.")
metricsPath = flag.String("web.telemetry-path", "/metrics", "Path under which to expose metrics.")
// openvpnStatusPaths = flag.String("openvpn.status_paths", "examples/client.status,examples/server2.status,examples/server3.status", "Paths at which OpenVPN places its status files.")
openvpnStatusPaths = flag.String("openvpn.status_paths", "/etc/openvpn/server/openvpn-status.log", "Paths at which OpenVPN places its status files.")
...
4.编译成openvpn_exporter
go build -o openvpn_exporter main.go cp openvpn_exporter /usr/local/bin #有防火墙的放行或关闭 firewall-cmd --add-port=9176/tcp --permanent firewall-cmd --reload #简单测试 端口是9176 ./openvpn_exporter5.修改prometheus
vim /etc/prometheus/prometheus.yml
...
# The job name is added as a label `job=` to any timeseries scraped from this config.
- job_name: 'prometheus'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
...
## 监控openvpn
- job_name: 'openvpn-metrics'
scrape_interval: 5s
static_configs:
- targets: ['192.168.11.46:9176']
#重启prometheus
systemctl restart prometheus
6.添加模版
https://grafana.com/grafana/dashboards/10562 #通过执行以下命令安装Grafana饼图插件。 grafana-cli plugins install grafana-piechart-panel #重启grafana systemctl restart grafana-server.service7.systemd启动
cat >/etc/systemd/system/openvpn_exporter.service <参考文章
https://kifarunix.com/monitor-openvpn-connections-with-prometheus-and-grafana/下面提供了上述仪表板的JSON文件(仪表板的修改版本10562):
{ "annotations": { "list": [ { "builtIn": 1, "datasource": "-- Grafana --", "enable": true, "hide": true, "iconColor": "rgba(0, 211, 255, 1)", "name": "Annotations & Alerts", "type": "dashboard" } ] }, "description": "OpenVPN Server status using Prometheus and OpenVPN exporter ", "editable": true, "gnetId": 10562, "graphTooltip": 0, "id": 15, "links": [ { "icon": "external link", "tags": [ "openvpn" ], "targetBlank": true, "type": "dashboards" } ], "panels": [ { "cacheTimeout": null, "colorBackground": false, "colorPostfix": false, "colorValue": true, "colors": [ "#299c46", "rgba(237, 129, 40, 0.89)", "#d44a3a" ], "datasource": "Prometheus", "decimals": 0, "fieldConfig": { "defaults": { "custom": {} }, "overrides": [] }, "format": "none", "gauge": { "maxValue": 100, "minValue": 0, "show": false, "thresholdLabels": false, "thresholdMarkers": true }, "gridPos": { "h": 5, "w": 6, "x": 0, "y": 0 }, "id": 10, "interval": null, "links": [], "mappingType": 1, "mappingTypes": [ { "name": "value to text", "value": 1 }, { "name": "range to text", "value": 2 } ], "maxDataPoints": 100, "nullPointMode": "connected", "nullText": null, "postfix": "", "postfixFontSize": "50%", "prefix": "", "prefixFontSize": "30%", "rangeMaps": [ { "from": "null", "text": "N/A", "to": "null" } ], "sparkline": { "fillColor": "rgba(31, 118, 189, 0.18)", "full": false, "lineColor": "rgb(31, 120, 193)", "show": false }, "tableColumn": "", "targets": [ { "expr": "time()-openvpn_status_update_time_seconds{job="openvpn-metrics"}", "format": "time_series", "instant": true, "intervalFactor": 1, "refId": "A" } ], "thresholds": "120, 180", "timeFrom": null, "timeShift": null, "title": "自状态更新以来", "type": "singlestat", "valueFontSize": "150%", "valueMaps": [ { "op": "=", "text": "N/A", "value": "null" } ], "valueName": "current" }, { "cacheTimeout": null, "colorBackground": false, "colorPrefix": false, "colorValue": true, "colors": [ "#d44a3a", "rgba(237, 129, 40, 0.89)", "#299c46" ], "datasource": "Prometheus", "decimals": null, "fieldConfig": { "defaults": { "custom": {} }, "overrides": [] }, "format": "none", "gauge": { "maxValue": 100, "minValue": 0, "show": false, "thresholdLabels": false, "thresholdMarkers": true }, "gridPos": { "h": 5, "w": 6, "x": 6, "y": 0 }, "id": 12, "interval": null, "links": [], "mappingType": 1, "mappingTypes": [ { "name": "value to text", "value": 1 }, { "name": "range to text", "value": 2 } ], "maxDataPoints": 100, "nullPointMode": "connected", "nullText": null, "postfix": "", "postfixFontSize": "50%", "prefix": "", "prefixFontSize": "150%", "rangeMaps": [ { "from": "null", "text": "N/A", "to": "null" } ], "sparkline": { "fillColor": "rgba(31, 118, 189, 0.18)", "full": false, "lineColor": "rgb(31, 120, 193)", "show": false }, "tableColumn": "", "targets": [ { "expr": "openvpn_up{job="openvpn-metrics"}", "format": "time_series", "instant": true, "intervalFactor": 1, "legendFormat": "", "refId": "A" } ], "thresholds": "1, 1", "timeFrom": null, "timeShift": null, "title": "状态", "type": "singlestat", "valueFontSize": "150%", "valueMaps": [ { "op": "=", "text": "N/A", "value": "null" }, { "op": "=", "text": "UP", "value": "1" }, { "op": "=", "text": "DOWN", "value": "0" } ], "valueName": "current" }, { "cacheTimeout": null, "colorBackground": false, "colorPrefix": false, "colorValue": true, "colors": [ "#5794F2", "#5794F2", "#5794F2" ], "datasource": "Prometheus", "decimals": 2, "fieldConfig": { "defaults": { "custom": {} }, "overrides": [] }, "format": "bytes", "gauge": { "maxValue": 100, "minValue": 0, "show": false, "thresholdLabels": false, "thresholdMarkers": true }, "gridPos": { "h": 5, "w": 6, "x": 12, "y": 0 }, "hideTimeOverride": true, "id": 19, "interval": null, "links": [], "mappingType": 1, "mappingTypes": [ { "name": "value to text", "value": 1 }, { "name": "range to text", "value": 2 } ], "maxDataPoints": 100, "nullPointMode": "connected", "nullText": null, "postfix": "", "postfixFontSize": "50%", "prefix": "", "prefixFontSize": "50%", "rangeMaps": [ { "from": "null", "text": "N/A", "to": "null" } ], "sparkline": { "fillColor": "rgba(31, 118, 189, 0.18)", "full": false, "lineColor": "rgb(31, 120, 193)", "show": false }, "tableColumn": "", "targets": [ { "expr": "sum(increase(openvpn_server_client_sent_bytes_total[1d]))", "format": "time_series", "instant": true, "interval": "", "intervalFactor": 1, "legendFormat": "", "refId": "A" } ], "thresholds": "1, 2", "timeFrom": "24h", "timeShift": null, "title": "今日发送", "type": "singlestat", "valueFontSize": "80%", "valueMaps": [ { "op": "=", "text": "N/A", "value": "null" } ], "valueName": "current" }, { "cacheTimeout": null, "colorBackground": false, "colorValue": true, "colors": [ "#5794F2", "#5794F2", "#5794F2" ], "datasource": "Prometheus", "decimals": 2, "fieldConfig": { "defaults": { "custom": {} }, "overrides": [] }, "format": "bytes", "gauge": { "maxValue": 100, "minValue": 0, "show": false, "thresholdLabels": false, "thresholdMarkers": true }, "gridPos": { "h": 5, "w": 6, "x": 18, "y": 0 }, "hideTimeOverride": true, "id": 18, "interval": null, "links": [], "mappingType": 1, "mappingTypes": [ { "name": "value to text", "value": 1 }, { "name": "range to text", "value": 2 } ], "maxDataPoints": 100, "nullPointMode": "connected", "nullText": null, "postfix": "", "postfixFontSize": "50%", "prefix": "", "prefixFontSize": "50%", "rangeMaps": [ { "from": "null", "text": "N/A", "to": "null" } ], "sparkline": { "fillColor": "rgba(31, 118, 189, 0.18)", "full": false, "lineColor": "rgb(31, 120, 193)", "show": false }, "tableColumn": "", "targets": [ { "expr": "sum(increase(openvpn_server_client_received_bytes_total[1d]))", "format": "time_series", "instant": true, "intervalFactor": 1, "refId": "A" } ], "thresholds": "1, 2", "timeFrom": "24h", "timeShift": null, "title": "今日接收", "type": "singlestat", "valueFontSize": "80%", "valueMaps": [ { "op": "=", "text": "N/A", "value": "null" } ], "valueName": "current" }, { "aliasColors": {}, "bars": true, "dashLength": 10, "dashes": false, "datasource": "Prometheus", "fieldConfig": { "defaults": { "custom": {} }, "overrides": [] }, "fill": 1, "fillGradient": 0, "gridPos": { "h": 7, "w": 9, "x": 0, "y": 5 }, "hiddenSeries": false, "id": 21, "legend": { "avg": false, "current": false, "max": false, "min": false, "show": false, "total": false, "values": false }, "lines": false, "linewidth": 2, "links": [], "nullPointMode": "connected", "options": { "alertThreshold": true }, "percentage": false, "pluginVersion": "7.4.3", "pointradius": 2, "points": false, "renderer": "flot", "seriesOverrides": [ { "$$hashKey": "object:1126", "alias": "/.+/i" } ], "spaceLength": 10, "stack": false, "steppedLine": false, "targets": [ { "exemplar": true, "expr": "topk(6,sum(count_values("connection_time",count_over_time(openvpn_server_client_received_bytes_total{common_name!="UNDEF"}[1d]))by(common_name))by(common_name)>1)", "format": "time_series", "instant": true, "interval": "", "intervalFactor": 1, "legendFormat": "{{ common_name }}", "refId": "A" } ], "thresholds": [], "timeFrom": "24h", "timeRegions": [], "timeShift": null, "title": "热门登录", "tooltip": { "shared": true, "sort": 2, "value_type": "individual" }, "type": "graph", "xaxis": { "buckets": null, "mode": "series", "name": null, "show": true, "values": [ "current" ] }, "yaxes": [ { "$$hashKey": "object:1131", "decimals": 0, "format": "short", "label": "", "logBase": 1, "max": null, "min": null, "show": true }, { "$$hashKey": "object:1132", "decimals": 0, "format": "short", "label": null, "logBase": 1, "max": null, "min": null, "show": true } ], "yaxis": { "align": false, "alignLevel": null } }, { "cacheTimeout": null, "colorBackground": false, "colorPostfix": false, "colorPrefix": false, "colorValue": true, "colors": [ "#d44a3a", "rgba(237, 129, 40, 0.89)", "#299c46" ], "datasource": "Prometheus", "fieldConfig": { "defaults": { "custom": {} }, "overrides": [] }, "format": "none", "gauge": { "maxValue": 256, "minValue": 0, "show": false, "thresholdLabels": false, "thresholdMarkers": true }, "gridPos": { "h": 7, "w": 5, "x": 9, "y": 5 }, "id": 2, "interval": null, "links": [], "mappingType": 1, "mappingTypes": [ { "name": "value to text", "value": 1 }, { "name": "range to text", "value": 2 } ], "maxDataPoints": 100, "nullPointMode": "connected", "nullText": null, "pluginVersion": "6.2.0-beta2", "postfix": "", "postfixFontSize": "50%", "prefix": "", "prefixFontSize": "50%", "rangeMaps": [ { "from": "null", "text": "N/A", "to": "null" } ], "sparkline": { "fillColor": "rgba(31, 118, 189, 0.18)", "full": true, "lineColor": "#5794F2", "show": true }, "tableColumn": "", "targets": [ { "expr": "openvpn_server_connected_clients", "format": "time_series", "instant": true, "interval": "", "intervalFactor": 1, "legendFormat": "", "refId": "A" } ], "thresholds": "0, 30", "timeFrom": null, "timeShift": null, "title": "客户端", "type": "singlestat", "valueFontSize": "150%", "valueMaps": [ { "op": "=", "text": "N/A", "value": "null" }, { "op": "=", "text": "No", "value": "0" } ], "valueName": "current" }, { "cacheTimeout": null, "colorBackground": false, "colorPostfix": false, "colorPrefix": false, "colorValue": true, "colors": [ "#FF9830", "#5794F2", "#5794F2" ], "datasource": "Prometheus", "fieldConfig": { "defaults": { "custom": {} }, "overrides": [] }, "format": "none", "gauge": { "maxValue": 256, "minValue": 0, "show": false, "thresholdLabels": false, "thresholdMarkers": true }, "gridPos": { "h": 7, "w": 5, "x": 14, "y": 5 }, "id": 15, "interval": null, "links": [], "mappingType": 1, "mappingTypes": [ { "name": "value to text", "value": 1 }, { "name": "range to text", "value": 2 } ], "maxDataPoints": 100, "nullPointMode": "connected", "nullText": null, "pluginVersion": "6.2.0-beta2", "postfix": "", "postfixFontSize": "50%", "prefix": "", "prefixFontSize": "50%", "rangeMaps": [ { "from": "null", "text": "N/A", "to": "null" } ], "sparkline": { "fillColor": "rgba(31, 118, 189, 0.18)", "full": true, "lineColor": "#5794F2", "show": true }, "tableColumn": "", "targets": [ { "exemplar": false, "expr": "openvpn_server_connected_clients", "format": "time_series", "instant": false, "interval": "", "intervalFactor": 1, "legendFormat": "", "refId": "A" } ], "thresholds": "1, 2", "timeFrom": null, "timeShift": null, "title": "服务器", "type": "singlestat", "valueFontSize": "150%", "valueMaps": [ { "op": "=", "text": "0", "value": "null" }, { "op": "=", "text": "0", "value": "0" } ], "valueName": "current" }, { "cacheTimeout": null, "colorBackground": false, "colorPostfix": false, "colorPrefix": false, "colorValue": true, "colors": [ "#FF9830", "#5794F2", "#5794F2" ], "datasource": "Prometheus", "fieldConfig": { "defaults": { "custom": {} }, "overrides": [] }, "format": "none", "gauge": { "maxValue": 256, "minValue": 0, "show": false, "thresholdLabels": false, "thresholdMarkers": true }, "gridPos": { "h": 7, "w": 5, "x": 19, "y": 5 }, "id": 16, "interval": null, "links": [], "mappingType": 1, "mappingTypes": [ { "name": "value to text", "value": 1 }, { "name": "range to text", "value": 2 } ], "maxDataPoints": 100, "nullPointMode": "connected", "nullText": null, "pluginVersion": "6.2.0-beta2", "postfix": "", "postfixFontSize": "50%", "prefix": "", "prefixFontSize": "50%", "rangeMaps": [ { "from": "null", "text": "N/A", "to": "null" } ], "sparkline": { "fillColor": "rgba(31, 118, 189, 0.18)", "full": true, "lineColor": "#5794F2", "show": true }, "tableColumn": "", "targets": [ { "expr": "count(openvpn_server_client_received_bytes_total{common_name=~"[a-zA-Z0-9]+"}) or absent(count(openvpn_server_client_received_bytes_total{common_name=~"[a-zA-Z0-9]+"}))-1", "format": "time_series", "instant": true, "interval": "", "intervalFactor": 1, "legendFormat": "", "refId": "A" } ], "thresholds": "1, 2", "timeFrom": null, "timeShift": null, "title": "用户", "type": "singlestat", "valueFontSize": "150%", "valueMaps": [], "valueName": "current" }, { "aliasColors": {}, "breakPoint": "100%", "cacheTimeout": null, "combine": { "label": "Others", "threshold": "0.025" }, "datasource": "Prometheus", "fieldConfig": { "defaults": { "custom": {} }, "overrides": [] }, "fontSize": "60%", "format": "decbytes", "gridPos": { "h": 9, "w": 12, "x": 0, "y": 12 }, "id": 8, "interval": null, "legend": { "percentage": true, "show": true, "sort": "current", "sortDesc": true, "values": false }, "legendType": "On graph", "links": [], "maxDataPoints": 3, "nullPointMode": "connected", "pieType": "pie", "strokeWidth": 1, "targets": [ { "expr": "sort(sum(increase(openvpn_server_client_received_bytes_total{common_name!="UNDEF"}[1d])+increase(openvpn_server_client_sent_bytes_total{common_name!="UNDEF"}[1d]))by(common_name))", "format": "time_series", "instant": true, "interval": "", "intervalFactor": 1, "legendFormat": "{{ common_name }}", "refId": "A" } ], "timeFrom": "24h", "timeShift": null, "title": "流量分配", "type": "grafana-piechart-panel", "valueName": "current" }, { "aliasColors": {}, "bars": true, "dashLength": 10, "dashes": false, "datasource": "Prometheus", "fieldConfig": { "defaults": { "custom": {} }, "overrides": [] }, "fill": 1, "fillGradient": 0, "gridPos": { "h": 9, "w": 12, "x": 12, "y": 12 }, "hiddenSeries": false, "id": 22, "legend": { "avg": false, "current": false, "max": false, "min": false, "show": false, "total": false, "values": false }, "lines": false, "linewidth": 2, "links": [], "nullPointMode": "connected", "options": { "alertThreshold": true }, "percentage": false, "pluginVersion": "7.4.3", "pointradius": 2, "points": false, "renderer": "flot", "seriesOverrides": [ { "$$hashKey": "object:1834", "alias": "/.+/i" } ], "spaceLength": 10, "stack": false, "steppedLine": false, "targets": [ { "exemplar": false, "expr": "topk(6, sum(increase(openvpn_server_client_received_bytes_total{common_name!="UNDEF"}[1d])+increase(openvpn_server_client_sent_bytes_total{common_name!="UNDEF"}[1d]))by(common_name))", "format": "time_series", "instant": true, "interval": "", "intervalFactor": 1, "legendFormat": "{{ common_name }}", "refId": "A" } ], "thresholds": [], "timeFrom": "24h", "timeRegions": [], "timeShift": null, "title": "最高流量", "tooltip": { "shared": true, "sort": 2, "value_type": "individual" }, "type": "graph", "xaxis": { "buckets": null, "mode": "series", "name": null, "show": true, "values": [ "current" ] }, "yaxes": [ { "$$hashKey": "object:1839", "decimals": 0, "format": "decbytes", "label": "", "logBase": 1, "max": null, "min": null, "show": true }, { "$$hashKey": "object:1840", "decimals": 0, "format": "short", "label": null, "logBase": 1, "max": null, "min": null, "show": true } ], "yaxis": { "align": false, "alignLevel": null } }, { "aliasColors": {}, "bars": false, "cacheTimeout": null, "dashLength": 10, "dashes": false, "datasource": "Prometheus", "decimals": 0, "fieldConfig": { "defaults": { "custom": {} }, "overrides": [] }, "fill": 1, "fillGradient": 0, "gridPos": { "h": 8, "w": 12, "x": 0, "y": 21 }, "hiddenSeries": false, "id": 14, "legend": { "avg": false, "current": false, "max": false, "min": false, "show": false, "total": false, "values": false }, "lines": true, "linewidth": 1, "links": [], "nullPointMode": "null as zero", "options": { "alertThreshold": true }, "percentage": false, "pluginVersion": "7.4.3", "pointradius": 2, "points": false, "renderer": "flot", "seriesOverrides": [], "spaceLength": 10, "stack": false, "steppedLine": false, "targets": [ { "expr": "sum(openvpn_server_connected_clients)", "format": "time_series", "instant": false, "interval": "", "intervalFactor": 1, "legendFormat": "Connected OpenVPN Clients", "refId": "A" } ], "thresholds": [], "timeFrom": null, "timeRegions": [], "timeShift": null, "title": "Clients Connected", "tooltip": { "shared": true, "sort": 0, "value_type": "individual" }, "type": "graph", "xaxis": { "buckets": null, "mode": "time", "name": null, "show": true, "values": [] }, "yaxes": [ { "$$hashKey": "object:1498", "decimals": 0, "format": "short", "label": "Clients", "logBase": 1, "max": null, "min": "0", "show": true }, { "$$hashKey": "object:1499", "format": "short", "label": null, "logBase": 1, "max": null, "min": null, "show": true } ], "yaxis": { "align": false, "alignLevel": null } }, { "aliasColors": {}, "bars": false, "dashLength": 10, "dashes": false, "datasource": "Prometheus", "decimals": 2, "fieldConfig": { "defaults": { "custom": {} }, "overrides": [] }, "fill": 0, "fillGradient": 0, "gridPos": { "h": 8, "w": 12, "x": 12, "y": 21 }, "hiddenSeries": false, "id": 6, "interval": "1m", "legend": { "alignAsTable": true, "avg": false, "current": true, "hideEmpty": true, "hideZero": true, "max": true, "min": false, "rightSide": true, "show": false, "sort": "total", "sortDesc": true, "total": true, "values": true }, "lines": true, "linewidth": 1, "links": [], "nullPointMode": "null as zero", "options": { "alertThreshold": true }, "percentage": false, "pluginVersion": "7.4.3", "pointradius": 2, "points": false, "renderer": "flot", "seriesOverrides": [ { "$$hashKey": "object:336", "alias": "/.+ - Rx$/i", "color": "#5794F2", "stack": "A", "transform": "negative-Y" }, { "$$hashKey": "object:337", "alias": "/.+ - Tx$/i", "color": "#73BF69", "stack": "B" }, { "$$hashKey": "object:338", "alias": "Rx - Others", "color": "#5794F2", "dashes": true, "stack": "A", "transform": "negative-Y" }, { "$$hashKey": "object:339", "alias": "Tx - Others", "color": "#73BF69", "dashes": true, "stack": "B" } ], "spaceLength": 10, "stack": true, "steppedLine": false, "targets": [ { "exemplar": false, "expr": "topk(6,sum(rate(openvpn_server_client_received_bytes_total{common_name!="UNDEF"}[2m]))by(common_name))", "format": "time_series", "instant": false, "interval": "2m", "intervalFactor": 1, "legendFormat": "{{ common_name }} - Rx", "refId": "A" }, { "exemplar": false, "expr": "topk(6, sum(rate(openvpn_server_client_sent_bytes_total{common_name!="UNDEF"}[2m]))by(common_name))", "format": "time_series", "instant": false, "interval": "2m", "intervalFactor": 1, "legendFormat": "{{ common_name }} - Tx", "refId": "B" }, { "exemplar": true, "expr": "sum(bottomk(scalar(openvpn_server_connected_clients)-6,sum(rate(openvpn_server_client_received_bytes_total{common_name!="UNDEF"}[2m]))by(common_name)))", "format": "time_series", "instant": true, "interval": "2m", "intervalFactor": 1, "legendFormat": "Rx - Others", "refId": "E" }, { "exemplar": true, "expr": "sum(bottomk(scalar(openvpn_server_connected_clients)-6,sum(rate(openvpn_server_client_sent_bytes_total{common_name!="UNDEF"}[1m]))by(common_name)))", "format": "time_series", "instant": true, "interval": "2m", "intervalFactor": 1, "legendFormat": "Tx - Others", "refId": "F" } ], "thresholds": [], "timeFrom": null, "timeRegions": [], "timeShift": null, "title": "前6名客户端网络活动", "tooltip": { "shared": true, "sort": 2, "value_type": "individual" }, "type": "graph", "xaxis": { "buckets": null, "mode": "time", "name": null, "show": true, "values": [] }, "yaxes": [ { "$$hashKey": "object:380", "format": "decbytes", "label": null, "logBase": 1, "max": null, "min": null, "show": true }, { "$$hashKey": "object:381", "decimals": null, "format": "bytes", "label": null, "logBase": 1, "max": null, "min": null, "show": true } ], "yaxis": { "align": false, "alignLevel": null } }, { "columns": [], "datasource": "Prometheus", "fieldConfig": { "defaults": { "custom": {} }, "overrides": [] }, "fontSize": "100%", "gridPos": { "h": 10, "w": 24, "x": 0, "y": 29 }, "id": 4, "links": [], "pageSize": 100, "scroll": true, "showHeader": true, "sort": { "col": null, "desc": false }, "styles": [ { "$$hashKey": "object:263", "alias": "Time", "align": "auto", "dateFormat": "YYYY-MM-DD HH:mm:ss", "pattern": "Time", "type": "hidden" }, { "$$hashKey": "object:264", "alias": "用户名", "align": "auto", "colorMode": null, "colors": [ "rgba(245, 54, 54, 0.9)", "rgba(237, 129, 40, 0.89)", "rgba(50, 172, 45, 0.97)" ], "decimals": 2, "pattern": "common_name", "thresholds": [], "type": "string", "unit": "short" }, { "$$hashKey": "object:265", "alias": "登录时间", "align": "auto", "colorMode": null, "colors": [ "rgba(245, 54, 54, 0.9)", "rgba(237, 129, 40, 0.89)", "rgba(50, 172, 45, 0.97)" ], "dateFormat": "YYYY-MM-DD HH:mm:ss", "decimals": null, "mappingType": 1, "pattern": "connection_time", "thresholds": [], "type": "date", "unit": "dateTimeFromNow" }, { "$$hashKey": "object:266", "alias": "地址", "align": "auto", "colorMode": null, "colors": [ "rgba(245, 54, 54, 0.9)", "rgba(237, 129, 40, 0.89)", "rgba(50, 172, 45, 0.97)" ], "dateFormat": "YYYY-MM-DD HH:mm:ss", "decimals": 2, "mappingType": 1, "pattern": "virtual_address", "thresholds": [], "type": "string", "unit": "short" }, { "$$hashKey": "object:267", "alias": "", "align": "auto", "colorMode": null, "colors": [ "rgba(245, 54, 54, 0.9)", "rgba(237, 129, 40, 0.89)", "rgba(50, 172, 45, 0.97)" ], "dateFormat": "YYYY-MM-DD HH:mm:ss", "decimals": 2, "mappingType": 1, "pattern": "Value", "thresholds": [], "type": "hidden", "unit": "short" }, { "$$hashKey": "object:268", "alias": "接收", "align": "auto", "colorMode": null, "colors": [ "rgba(245, 54, 54, 0.9)", "rgba(237, 129, 40, 0.89)", "rgba(50, 172, 45, 0.97)" ], "dateFormat": "YYYY-MM-DD HH:mm:ss", "decimals": 0, "mappingType": 1, "pattern": "Value #A", "thresholds": [], "type": "number", "unit": "bytes" }, { "$$hashKey": "object:269", "alias": "发送", "align": "auto", "colorMode": null, "colors": [ "rgba(245, 54, 54, 0.9)", "rgba(237, 129, 40, 0.89)", "rgba(50, 172, 45, 0.97)" ], "dateFormat": "YYYY-MM-DD HH:mm:ss", "decimals": 0, "mappingType": 1, "pattern": "Value #B", "thresholds": [], "type": "number", "unit": "bytes" } ], "targets": [ { "expr": "sort_desc(sum(label_replace(openvpn_server_client_received_bytes_total{common_name!="UNDEF"}, "connection_time", "${1}000", "connection_time", "(.*)"))by(common_name, connection_time, virtual_address))", "format": "table", "instant": true, "interval": "", "intervalFactor": 1, "legendFormat": "", "refId": "A" }, { "expr": "sum(label_replace(openvpn_server_client_sent_bytes_total{common_name!="UNDEF"}, "connection_time", "${1}000", "connection_time", "(.*)"))by(common_name, connection_time, virtual_address)", "format": "table", "instant": true, "interval": "", "intervalFactor": 1, "legendFormat": "", "refId": "B" } ], "timeFrom": null, "timeShift": null, "title": "Current OpenVPN Clients", "transform": "table", "type": "table-old" } ], "refresh": "5s", "schemaVersion": 27, "style": "dark", "tags": [ "openvpn" ], "templating": { "list": [] }, "time": { "from": "now-6h", "to": "now" }, "timepicker": { "refresh_intervals": [ "5s", "10s", "30s", "1m", "5m", "15m", "30m", "1h", "2h", "1d" ], "time_options": [ "5m", "15m", "1h", "6h", "12h", "24h", "2d", "7d", "30d" ] }, "timezone": "", "title": "OpenVPN", "uid": "_1DSF7HWk", "version": 10 }



