Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change(prometheus): replace wrong apisix_nginx_http_current_connections{state="total"} label #6327

Merged
merged 2 commits into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions apisix/plugins/prometheus/exporter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ function _M.init()
"Number of HTTP connections",
{"state"})

metrics.requests = prometheus:gauge("http_requests_total",
"The total number of client requests since APISIX started")

metrics.etcd_reachable = prometheus:gauge("etcd_reachable",
"Config server etcd reachable from APISIX, 0 is unreachable")

Expand Down Expand Up @@ -199,9 +202,12 @@ local function nginx_status()
break
end

label_values[1] = name
metrics.connections:set(val[0], label_values)

if name == "total" then
metrics.requests:set(val[0])
else
label_values[1] = name
metrics.connections:set(val[0], label_values)
end
end
end

Expand Down
4 changes: 2 additions & 2 deletions docs/assets/other/json/apisix-grafana-dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
"tableColumn": "",
"targets": [
{
"expr": "sum(apisix_nginx_http_current_connections{state=\"total\", instance=~\"$instance\"})",
"expr": "sum(apisix_http_requests_total{instance=~\"$instance\"})",
"intervalFactor": 2,
"legendFormat": "Total",
"refId": "A"
Expand All @@ -157,7 +157,7 @@
"thresholds": "",
"timeFrom": null,
"timeShift": null,
"title": "Total Connections",
"title": "Total Requests",
"type": "singlestat",
"valueFontSize": "80%",
"valueMaps": [
Expand Down
4 changes: 3 additions & 1 deletion docs/en/latest/plugins/prometheus.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,15 @@ apisix_etcd_reachable 1
apisix_http_status{code="200",route="1",matched_uri="/hello",matched_host="",service="",consumer="",node="127.0.0.1"} 4
apisix_http_status{code="200",route="2",matched_uri="/world",matched_host="",service="",consumer="",node="127.0.0.1"} 4
apisix_http_status{code="404",route="",matched_uri="",matched_host="",service="",consumer="",node=""} 1
# HELP apisix_http_requests_total The total number of client requests
# TYPE apisix_http_requests_total gauge
apisix_http_requests_total 1191780
# HELP apisix_nginx_http_current_connections Number of HTTP connections
# TYPE apisix_nginx_http_current_connections gauge
apisix_nginx_http_current_connections{state="accepted"} 11994
apisix_nginx_http_current_connections{state="active"} 2
apisix_nginx_http_current_connections{state="handled"} 11994
apisix_nginx_http_current_connections{state="reading"} 0
apisix_nginx_http_current_connections{state="total"} 1191780
apisix_nginx_http_current_connections{state="waiting"} 1
apisix_nginx_http_current_connections{state="writing"} 1
# HELP apisix_nginx_metric_errors_total Number of nginx-lua-prometheus errors
Expand Down
4 changes: 3 additions & 1 deletion docs/zh/latest/plugins/prometheus.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,15 @@ apisix_etcd_reachable 1
apisix_http_status{code="200",route="1",matched_uri="/hello",matched_host="",service="",consumer="",node="127.0.0.1"} 4
apisix_http_status{code="200",route="2",matched_uri="/world",matched_host="",service="",consumer="",node="127.0.0.1"} 4
apisix_http_status{code="404",route="",matched_uri="",matched_host="",service="",consumer="",node=""} 1
# HELP apisix_http_requests_total The total number of client requests
# TYPE apisix_http_requests_total gauge
apisix_http_requests_total 1191780
# HELP apisix_nginx_http_current_connections Number of HTTP connections
# TYPE apisix_nginx_http_current_connections gauge
apisix_nginx_http_current_connections{state="accepted"} 11994
apisix_nginx_http_current_connections{state="active"} 2
apisix_nginx_http_current_connections{state="handled"} 11994
apisix_nginx_http_current_connections{state="reading"} 0
apisix_nginx_http_current_connections{state="total"} 1191780
apisix_nginx_http_current_connections{state="waiting"} 1
apisix_nginx_http_current_connections{state="writing"} 1
# HELP apisix_nginx_metric_errors_total Number of nginx-lua-prometheus errors
Expand Down