Skip to content

feat: add batch process metrics#3070

Merged
spacewander merged 18 commits into
apache:masterfrom
gy09535:feature/add-batch-process-metrics
Dec 24, 2020
Merged

feat: add batch process metrics#3070
spacewander merged 18 commits into
apache:masterfrom
gy09535:feature/add-batch-process-metrics

Conversation

@gy09535

@gy09535 gy09535 commented Dec 17, 2020

Copy link
Copy Markdown
Contributor

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(...)
clear_tab(inner_tab_arr)

local function gen_arr(...)

Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

got it.

Comment thread apisix/utils/batch-processor.lua Outdated
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

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

@gy09535
gy09535 requested a review from spacewander December 20, 2020 03:42
Comment thread apisix/utils/batch-processor.lua Outdated
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
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed.

Comment thread 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"/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Escape {?

@gy09535 gy09535 Dec 24, 2020

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

added.

@gy09535
gy09535 requested a review from spacewander December 24, 2020 03:47
Comment thread doc/plugins/prometheus.md Outdated
* `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
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

changed.

@gy09535
gy09535 requested a review from spacewander December 24, 2020 07:19
@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