ASM流量調度套件支援通過QuotaSchedulingPolicy實現指定請求調用配額下的請求優先順序調度。當系統中正在處理的請求速率超過指定的配額時,後續的請求將會被排隊,同時優先順序高的請求能夠被更快處理。本文介紹如何使用流量調度套件提供的QuotaSchedulingPolicy來實現請求調用配額管理。
背景資訊
QuotaSchedulingPolicy通過令牌桶演算法來控制調用指定服務的請求速率,並在速率超過指定配額時對請求進行排隊處理。大致工作流程如下:
使用限流器對請求進行速率限制:使用令牌桶演算法對請求進行限流,有關限流器的演算法實現,可詳細參考使用RateLimitingPolicy實現分使用者限流情境的背景資訊。
請求調度:請求速率超過配額限制後,後續請求將會被排隊,等待先前請求處理完成後再發送給服務,以保證請求速率始終保持在給定數值。同時,高優先順序的請求有更大的機會被從隊列中取出發送給服務。
和限流的情境不同,使用QuotaSchedulingPolicy時,若請求速率超過限制,此時請求不會被直接拒絕,而是進入一個優先順序隊列,在保證請求速率始終在限制內的同時對請求進行優先順序調度。
前提條件
已添加Kubernetes託管版叢集到ASM執行個體,且ASM執行個體為1.21.6.95版本及以上。具體操作,請參見添加叢集到ASM執行個體。
已通過kubectl串連至ACK叢集。 具體操作,請參見擷取叢集KubeConfig並通過kubectl工具串連叢集。
已開啟ASM流量調度套件。具體操作,請參見開啟ASM流量調度套件。
已為Kubernetes叢集中的default命名空間開啟自動注入。具體操作,請參見管理全域命名空間。
已建立名為ingressgateway的入口網關,並開啟80連接埠。具體操作,請參見建立入口網關。
已經部署httpbin應用,並且可以通過網關訪問。具體操作,請參見部署httpbin應用。
步驟一:建立QuotaSchedulingPolicy配額管理規則
使用kubectl串連到ASM執行個體,具體操作,請參見通過控制面kubectl訪問Istio資源。
使用以下內容建立quotaschedulingpolicy.yaml檔案
apiVersion: istio.alibabacloud.com/v1 kind: QuotaSchedulingPolicy metadata: name: quotascheduling namespace: istio-system spec: quota_scheduler: bucket_capacity: 10 fill_amount: 10 rate_limiter: interval: 1s scheduler: workloads: - label_matcher: match_labels: http.request.header.user_type: guest parameters: priority: 50.0 name: guest - label_matcher: match_labels: http.request.header.user_type: subscriber parameters: priority: 200.0 name: subscriber selectors: - service: httpbin.default.svc.cluster.local
部分配置項說明如下。關於配置項的更多資訊,請參見QuotaSchedulingPolicy CRD說明。
配置項
說明
fill_amount
在interval指定的時間間隔內填充令牌的數量。樣本中指定為10,即每過interval指定的時間間隔後便向令牌桶填充10個令牌。
interval
向令牌桶中填充令牌的時間間隔。樣本中指定為1s,即每過1秒後便向令牌桶填充10個令牌。
bucket_capacity
令牌桶內的令牌數量上限。當請求速率小於令牌桶填充速率時,令牌桶內的令牌數量會持續增加,最大將達到
bucket_capacity
。使用bucket_capacity
可以容許一定程度的突發流量。樣本中設定為10,和fill_amount
相同,即不允許任何突發流量。workloads
根據請求header中的
user_type
定義了兩類請求,分別是guest
和subscriber
。guest
類型的請求優先順序是50,subscriber
類型的請求優先順序是200。selectors
指定應用限流策略的多個服務。樣本中使用httpbin.default.svc.cluster.local 服務進行並行度限制。
執行以下命令,建立配額管理規則
kubectl apply -f quotaschedulingpolicy.yaml
步驟二:測試請求配額管理效果
本步驟使用壓測工具fortio進行測試,安裝方式請參見安裝fortio。
同時開啟兩個終端,並分別運行下面兩個壓測命令(儘可能同時開始這兩個測試),整個測試期間,請確保不要關閉對應的終端。兩個測試都使用10並發、10000預期QPS的設定對服務發起調用,遠遠超過了服務的預期並發度限制。
fortio load -c 10 -qps 10000 -H "user_type:guest" -t 30s -timeout 60s -a http://${ASM網關IP}/status/201
fortio load -c 10 -qps 10000 -H "user_type:subscriber" -t 30s -timeout 60s -a http://${ASM網關IP}/status/202
說明請將上述指令中的
${ASM網關IP}
替換為ASM網關的IP地址。有關擷取ASM網關IP地址的具體操作,請參見使用Istio資源實現版本流量路由。測試1的預期輸出:
... # target 50% 4.83333 # target 75% 5.20763 # target 90% 5.38203 # target 99% 5.48668 # target 99.9% 5.49714 Sockets used: 10 (for perfect keepalive, would be 10) Uniform: false, Jitter: false Code 201 : 70 (100.0 %) Response Header Sizes : count 70 avg 249.94286 +/- 0.2871 min 248 max 250 sum 17496 Response Body/Total Sizes : count 70 avg 249.94286 +/- 0.2871 min 248 max 250 sum 17496 All done 70 calls (plus 10 warmup) 4566.839 ms avg, 2.1 qps Successfully wrote 4693 bytes of Json data to 2024-07-26-232250_114_55_5_155_status_201_iZbp1cz9ur77robaiv085tZ.json
測試2的預期輸出:
fortio load -c 10 -qps 10000 -H "user_type:subscriber" -t 30s -timeout 60s -a http://114.55.xx.xx/status/202 ... # target 50% 0.253333 # target 75% 1.875 # target 90% 4.26635 # target 99% 4.47301 # target 99.9% 4.49367 Sockets used: 10 (for perfect keepalive, would be 10) Uniform: false, Jitter: false Code 202 : 250 (100.0 %) Response Header Sizes : count 250 avg 250.264 +/- 0.4408 min 250 max 251 sum 62566 Response Body/Total Sizes : count 250 avg 250.264 +/- 0.4408 min 250 max 251 sum 62566 All done 250 calls (plus 10 warmup) 1226.657 ms avg, 8.0 qps Successfully wrote 4509 bytes of Json data to 2024-07-26-232250_114_55_5_155_status_202_iZbp1cz9ur77robaiv085tZ.json
可以看到,測試2的平均請求延遲約為測試1的四分之一,QPS約為測試1的四倍。這是由於先前定義的策略中,subscriber類型的請求優先順序是guest類型的請求的四倍。同時,兩個測試在30秒內總共完成了320個請求,除去最開始預熱使用的20個請求,服務收到的請求速率正好是1秒鐘10個請求,證明服務收到的請求始終在給定限額之內。
相關操作
您可以通過Grafana大盤來觀測QuotaSchedulingPolicy策略的執行效果。請確保Grafana使用的資料來源Prometheus執行個體已經完成配置採集ASM流量調度套件相關指標。
將以下內容匯入到Grafana,建立QuotaSchedulingPolicy策略的大盤。
展開查看JSON內容
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"id": 44,
"links": [],
"liveNow": false,
"panels": [
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"description": "Signal derived from periodic execution of query: (sum(rate(workload_requests_total{policy_name=\"quotascheduling\",component_id=\"root.0\",decision_type=\"DECISION_TYPE_ACCEPTED\"}[30s])) / sum(rate(workload_requests_total{policy_name=\"quotascheduling\",component_id=\"root.0\"}[30s]))) * 100",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"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": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": ""
},
"overrides": []
},
"gridPos": {
"h": 10,
"w": 24,
"x": 0,
"y": 0
},
"id": 1,
"interval": "10s",
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "v10.1.0",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"editorMode": "code",
"expr": "(sum by (policy_name)(rate(workload_requests_total{component_id=\"root.0\",decision_type=\"DECISION_TYPE_ACCEPTED\"}[30s])) / sum by (policy_name)(rate(workload_requests_total{component_id=\"root.0\"}[30s]))) * 100",
"intervalFactor": 1,
"legendFormat": "policy={{policy_name}}",
"range": true,
"refId": "A"
}
],
"title": "ACCEPT_PERCENTAGE - runs every 10s, metrics: workload_requests_total",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"description": "",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "Decisions",
"axisPlacement": "auto",
"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": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "reqps"
},
"overrides": []
},
"gridPos": {
"h": 10,
"w": 24,
"x": 0,
"y": 10
},
"id": 2,
"interval": "10s",
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "v10.1.0",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"expr": "sum by(decision_type) (rate(workload_requests_total{component_id=\"root.0\",policy_name=\"quotascheduling\"}[$__rate_interval]))",
"intervalFactor": 1,
"refId": "A"
}
],
"title": "Workload Decisions",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"description": "",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "Decisions",
"axisPlacement": "auto",
"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": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "reqps"
},
"overrides": []
},
"gridPos": {
"h": 10,
"w": 24,
"x": 0,
"y": 20
},
"id": 3,
"interval": "10s",
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "v10.1.0",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"expr": "sum by(workload_index, decision_type) (rate(workload_requests_total{component_id=\"root.0\",policy_name=\"quotascheduling\",decision_type=\"DECISION_TYPE_ACCEPTED\"}[$__rate_interval]))",
"intervalFactor": 1,
"refId": "A"
}
],
"title": "Workload Decisions (accepted)",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"description": "",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "Decisions",
"axisPlacement": "auto",
"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": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "reqps"
},
"overrides": []
},
"gridPos": {
"h": 10,
"w": 24,
"x": 0,
"y": 30
},
"id": 4,
"interval": "10s",
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "v10.1.0",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"editorMode": "code",
"expr": "sum by(workload_index, decision_type, policy_name) (rate(workload_requests_total{component_id=\"root.0\",decision_type=\"DECISION_TYPE_REJECTED\"}[$__rate_interval]))",
"intervalFactor": 1,
"range": true,
"refId": "A"
}
],
"title": "Workload Decisions (rejected)",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"noValue": "No data",
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "blue",
"value": null
}
]
},
"unit": "short"
},
"overrides": []
},
"gridPos": {
"h": 10,
"w": 8,
"x": 0,
"y": 40
},
"id": 5,
"options": {
"colorMode": "value",
"graphMode": "area",
"justifyMode": "center",
"orientation": "horizontal",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"textMode": "auto"
},
"pluginVersion": "10.0.9",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"editorMode": "code",
"expr": "sum by (policy_name)(increase(workload_requests_total{component_id=\"root.0\"}[$__range]))",
"instant": false,
"intervalFactor": 1,
"legendFormat": "{{ policy_name }}",
"range": true,
"refId": "A"
}
],
"title": "Total Requests",
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"noValue": "No data",
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
},
"unit": "short"
},
"overrides": []
},
"gridPos": {
"h": 10,
"w": 8,
"x": 8,
"y": 40
},
"id": 6,
"options": {
"colorMode": "value",
"graphMode": "area",
"justifyMode": "center",
"orientation": "horizontal",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"textMode": "auto"
},
"pluginVersion": "10.0.9",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"editorMode": "code",
"expr": "sum by (policy_name)(increase(workload_requests_total{component_id=\"root.0\",decision_type=\"DECISION_TYPE_ACCEPTED\"}[$__range]))",
"instant": false,
"intervalFactor": 1,
"legendFormat": "{{ policy_name }}",
"range": true,
"refId": "A"
}
],
"title": "Total Accepted Requests",
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"noValue": "No rejected requests",
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "red",
"value": null
}
]
},
"unit": "short"
},
"overrides": []
},
"gridPos": {
"h": 10,
"w": 8,
"x": 16,
"y": 40
},
"id": 7,
"options": {
"colorMode": "value",
"graphMode": "area",
"justifyMode": "center",
"orientation": "horizontal",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"textMode": "auto"
},
"pluginVersion": "10.0.9",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"editorMode": "code",
"expr": "sum by (policy_name)(increase(workload_requests_total{component_id=\"root.0\",decision_type=\"DECISION_TYPE_REJECTED\"}[$__range]))",
"instant": false,
"intervalFactor": 1,
"legendFormat": "{{ policy_name }}",
"range": true,
"refId": "A"
}
],
"title": "Total Rejected Requests",
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"description": "",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "Latency",
"axisPlacement": "auto",
"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": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "ms"
},
"overrides": []
},
"gridPos": {
"h": 10,
"w": 24,
"x": 0,
"y": 50
},
"id": 8,
"interval": "10s",
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "v10.1.0",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"editorMode": "code",
"expr": "(sum by (workload_index, policy_name) (increase(workload_latency_ms_sum{component_id=\"root.0\"}[$__rate_interval])))/(sum by (workload_index, policy_name) (increase(workload_latency_ms_count{component_id=\"root.0\"}[$__rate_interval])))",
"intervalFactor": 1,
"range": true,
"refId": "A"
}
],
"title": "Workload Latency",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"description": "",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "Wait Time",
"axisPlacement": "auto",
"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": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "ms"
},
"overrides": []
},
"gridPos": {
"h": 10,
"w": 12,
"x": 0,
"y": 60
},
"id": 9,
"interval": "10s",
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "v10.1.0",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"editorMode": "code",
"expr": "(sum by (workload_index, policy_name) (increase(request_in_queue_duration_ms_sum{component_id=\"root.0\"}[$__rate_interval])))/ ((sum by (workload_index, policy_name) (increase(request_in_queue_duration_ms_count{component_id=\"root.0\"}[$__rate_interval]))) != 0)",
"intervalFactor": 1,
"range": true,
"refId": "A"
}
],
"title": "Request in Queue Duration",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisGridShow": true,
"axisLabel": "",
"axisPlacement": "hidden",
"fillOpacity": 80,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineWidth": 1,
"scaleDistribution": {
"type": "linear"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "ms"
},
"overrides": []
},
"gridPos": {
"h": 10,
"w": 12,
"x": 12,
"y": 60
},
"id": 10,
"options": {
"barRadius": 0,
"barWidth": 0.97,
"colorByField": "",
"fullHighlight": false,
"groupWidth": 0.7,
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"orientation": "horizontal",
"showValue": "auto",
"stacking": "none",
"tooltip": {
"mode": "single",
"sort": "sort"
},
"xTickLabelRotation": 0,
"xTickLabelSpacing": 0
},
"pluginVersion": "v10.1.0",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"editorMode": "code",
"expr": "topk(10, (sum by(workload_index, policy_name) (increase(request_in_queue_duration_ms_sum{component_id=\"root.0\"}[$__range])) ) / ((sum by(workload_index, policy_name) (increase(request_in_queue_duration_ms_count{component_id=\"root.0\"}[$__range])) )) != 0)",
"format": "time_series",
"instant": true,
"intervalFactor": 1,
"legendFormat": "",
"range": false,
"refId": "A"
}
],
"title": "Request in Queue Duration",
"type": "barchart"
},
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"description": "",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "Token Rate",
"axisPlacement": "auto",
"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": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": ""
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 70
},
"id": 13,
"interval": "10s",
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "v10.1.0",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"editorMode": "code",
"expr": "sum by (policy_name)(rate(incoming_tokens_total{component_id=\"root.0\"}[$__rate_interval]))",
"intervalFactor": 1,
"range": true,
"refId": "A"
}
],
"title": "Incoming Token Rate",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"description": "",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "Token Rate",
"axisPlacement": "auto",
"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": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": ""
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 70
},
"id": 14,
"interval": "10s",
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "v10.1.0",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"editorMode": "code",
"expr": "sum by (policy_name)(rate(accepted_tokens_total{component_id=\"root.0\"}[$__rate_interval]))",
"intervalFactor": 1,
"legendFormat": "Accepted Token Rate",
"range": true,
"refId": "A"
},
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"editorMode": "code",
"expr": "sum by (policy_name)(rate(rejected_tokens_total{component_id=\"root.0\"}[$__rate_interval]))",
"intervalFactor": 1,
"legendFormat": "Rejected Token Rate",
"range": true,
"refId": "B"
}
],
"title": "Accepted Token Rate vs Rejected Token Rate",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"noValue": "No data",
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "blue",
"value": null
}
]
},
"unit": "short"
},
"overrides": []
},
"gridPos": {
"h": 10,
"w": 8,
"x": 0,
"y": 78
},
"id": 15,
"options": {
"colorMode": "value",
"graphMode": "area",
"justifyMode": "center",
"orientation": "horizontal",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"textMode": "auto"
},
"pluginVersion": "10.0.9",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"editorMode": "code",
"expr": "sum by (policy_name)(increase(incoming_tokens_total{component_id=\"root.0\"}[$__range]))",
"instant": false,
"intervalFactor": 1,
"legendFormat": "{{ instance }} - {{ policy_name }}",
"range": true,
"refId": "A"
}
],
"title": "Total Incoming Tokens",
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"noValue": "No data",
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
},
"unit": "short"
},
"overrides": []
},
"gridPos": {
"h": 10,
"w": 8,
"x": 8,
"y": 78
},
"id": 16,
"options": {
"colorMode": "value",
"graphMode": "area",
"justifyMode": "center",
"orientation": "horizontal",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"textMode": "auto"
},
"pluginVersion": "10.0.9",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"editorMode": "code",
"expr": "sum by (policy_name)(increase(accepted_tokens_total{component_id=\"root.0\"}[$__range]))",
"instant": false,
"intervalFactor": 1,
"legendFormat": "{{ instance }} - {{ policy_name }}",
"range": true,
"refId": "A"
}
],
"title": "Total Accepted Tokens",
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"noValue": "No data",
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "red",
"value": null
}
]
},
"unit": "short"
},
"overrides": []
},
"gridPos": {
"h": 10,
"w": 8,
"x": 16,
"y": 78
},
"id": 17,
"options": {
"colorMode": "value",
"graphMode": "area",
"justifyMode": "center",
"orientation": "horizontal",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"textMode": "auto"
},
"pluginVersion": "10.0.9",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"editorMode": "code",
"expr": "sum by (policy_name)(increase(rejected_tokens_total{component_id=\"root.0\"}[$__range]))",
"instant": false,
"intervalFactor": 1,
"legendFormat": "{{ instance }} - {{ policy_name }}",
"range": true,
"refId": "A"
}
],
"title": "Total Rejected Tokens",
"type": "stat"
}
],
"refresh": false,
"schemaVersion": 38,
"style": "dark",
"tags": [],
"templating": {
"list": [
{
"hide": 0,
"includeAll": false,
"label": "Data Source",
"multi": false,
"name": "datasource",
"options": [],
"query": "prometheus",
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"type": "datasource"
}
]
},
"time": {
"from": "now-5m",
"to": "now"
},
"timepicker": {},
"timezone": "browser",
"title": "Policy Summary - quotascheduling",
"version": 1,
"weekStart": ""
}
大盤效果如下。