-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
feat: add batch process metrics #3070
feat: add batch process metrics #3070
Conversation
|
||
local function gen_arr(...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need this if we can't share the table.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got it.
apisix/utils/batch-processor.lua
Outdated
local entries = self.entry_buffer.entries | ||
table.insert(entries, entry) | ||
-- add batch metric for every route | ||
if batch_metrics then | ||
batch_metrics:set(#entries, prometheus.gen_arr(self.name, self.route_id, self.server_addr)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can store the table: self.xxx = {self.name, self.route_id, self.server_addr}
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
The test case reported an error and we need to resolve it. ^ _ ^ |
apisix/utils/batch-processor.lua
Outdated
local entries = self.entry_buffer.entries | ||
table.insert(entries, entry) | ||
-- add batch metric for every route | ||
if batch_metrics then | ||
local label = {self.name, self.route_id, self.server_addr} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look like we can store the label
in self
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
t/plugin/prometheus.t
Outdated
GET /apisix/prometheus/metrics | ||
--- error_code: 200 | ||
--- response_body_like eval | ||
qr/apisix_batch_process_entries{name="sys-logger",route_id="9"/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Escape {
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
plugin set error. 😄
if not batch_metrics and prometheus.get_prometheus() and self.name | ||
and self.route_id and self.server_addr then | ||
batch_metrics = prometheus.get_prometheus():gauge("batch_process_entries", | ||
"batch process remaining entries", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added.
doc/plugins/prometheus.md
Outdated
@@ -125,6 +125,7 @@ Or you can goto [Grafana official](https://grafana.com/grafana/dashboards/11719) | |||
* `Bandwidth`: Total Bandwidth (egress/ingress) flowing through apisix. This metric is available per service and as a sum across all services. | |||
* `etcd reachability`: A gauge type with a value of 0 or 1, representing if etcd can be reached by a apisix or not. | |||
* `Connections`: Various Nginx connection metrics like active, reading, writing, and number of accepted connections. | |||
* `Batch process entries`: A gauge type, when we use plugins such as: sys logger, http logger, sls logger, tcp logger, udp logger and zipkin, the surplus entries which not sended will be statistics in the metrics. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should mention the batch processor.
Some suggestions:
surplus entries
=> entries
not sended
=> hasn't been sent
statistics
=> counted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed.
What this PR does / why we need it:
fix: #2693
add metric for batch process, such as: sls logger, tcp logger ,udp logger , http logger, sys logger.
with this feature, users can use the metrics find how many entries remaining in batch process.
Pre-submission checklist: