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

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

Merged
merged 7 commits into from
Mar 15, 2022

Conversation

shuaijinchao
Copy link
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

@@ -39,6 +39,7 @@ local _M = {
name = plugin_name,
log = exporter.log,
schema = schema,
run_policy = "prefer_route",
Copy link
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
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
Copy link
Contributor

@tokers tokers left a comment

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?

@@ -171,6 +171,8 @@ function _M.log(conf, ctx)

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
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
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
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
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
qr/prometheus run \w+/
--- grep_error_log_out
prometheus run report
--- error_code: 200
Copy link
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?

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