Skip to content

fix(prometheus): conflict between global rule and route configure#6579

Merged
spacewander merged 7 commits into
apache:masterfrom
shuaijinchao:bugfix/prometheus/between
Mar 15, 2022
Merged

fix(prometheus): conflict between global rule and route configure#6579
spacewander merged 7 commits into
apache:masterfrom
shuaijinchao:bugfix/prometheus/between

Conversation

@shuaijinchao

Copy link
Copy Markdown
Member

What this PR does / why we need it:

FIX #6555

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

name = plugin_name,
log = exporter.log,
schema = schema,
run_policy = "prefer_route",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does the nginx-lua-prometheus need update ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Does the nginx-lua-prometheus need update ?

No, APISIX from 2.7 to master, nginx-lua-prometheus has only one version upgrade, and this upgrade of nginx-lua-prometheus is not related to the current issue.

https://github.com/knyar/nginx-lua-prometheus/blob/master/CHANGELOG.md#020220127

tzssangglass
tzssangglass previously approved these changes Mar 13, 2022
tokers
tokers previously approved these changes Mar 13, 2022

@tokers tokers left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The way do work for fixing the problem but my concern is that are there other plugins have the same problem? Shall we have a generic mechanism to handle this situation?

Comment thread apisix/plugins/prometheus/exporter.lua Outdated
metrics.bandwidth:inc(vars.bytes_sent,
gen_arr("egress", route_id, service_id, consumer_name, balancer_ip))

core.log.info("prometheus run report")

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.

Can we check the result of prometheus instead of adding a new log just for testing?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this is not just for testing purposes. Currently, there is no log output when prometheus reports data. I think adding this log will also help developers watch it while developing and debugging.

what do you think?

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.

A hit will increase the metric:

metrics.status:inc(1,

There is no need to add another way.

@spacewander

Copy link
Copy Markdown
Member

The way do work for fixing the problem but my concern is that are there other plugins have the same problem? Shall we have a generic mechanism to handle this situation?

This has been discussed before. The run_policy used in this PR is the solution to it.

@shuaijinchao
shuaijinchao dismissed stale reviews from tokers and tzssangglass via 88b1bb3 March 14, 2022 02:51
Comment thread t/plugin/prometheus3.t Outdated
qr/prometheus run \w+/
--- grep_error_log_out
prometheus run report
--- error_code: 200

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.

The error_code check here is redundant?

Comment thread t/plugin/prometheus3.t Outdated
--- request
GET /apisix/prometheus/metrics
--- response_body eval
qr/apisix_http_status\{code="200",route="1",matched_uri="\/opentracing",matched_host="",service="",consumer="",node="127.0.0.1\"} \d+/

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.

It doesn't check the number this request is hit...

@spacewander
spacewander merged commit 95439a2 into apache:master Mar 15, 2022
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.

bug: Prometheus metrics igress and egress is inaccurate

5 participants