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

feat: add batch process metrics #3070

Merged
merged 18 commits into from
Dec 24, 2020

Conversation

gy09535
Copy link
Contributor

@gy09535 gy09535 commented Dec 17, 2020

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:

  • Did you explain what problem does this PR solve? Or what new features have been added?
  • Have you added corresponding test cases?
  • Have you modified the corresponding document?
  • Is this PR backward compatible? If it is not backward compatible, please discuss on the mailing list first

@gy09535 gy09535 changed the title feat:add batch process metrics feat: Add batch process metrics Dec 17, 2020
@gy09535 gy09535 changed the title feat: Add batch process metrics feat: add batch process metrics Dec 17, 2020

local function gen_arr(...)
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it.

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))
Copy link
Member

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}.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

@Firstsawyou
Copy link
Contributor

The test case reported an error and we need to resolve it. ^ _ ^

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}
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

GET /apisix/prometheus/metrics
--- error_code: 200
--- response_body_like eval
qr/apisix_batch_process_entries{name="sys-logger",route_id="9"/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Escape {?

Copy link
Contributor Author

@gy09535 gy09535 Dec 24, 2020

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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added.

@@ -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.
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed.

@spacewander spacewander merged commit 0802c95 into apache:master Dec 24, 2020
@gy09535 gy09535 deleted the feature/add-batch-process-metrics branch February 20, 2021 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DISCUSS] Should we add metric for log sender and zipkin ?
4 participants