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): disable features when prometheus plugin is turned off #11117

Merged

Conversation

shreemaan-abhishek
Copy link
Contributor

@shreemaan-abhishek shreemaan-abhishek commented Apr 3, 2024

Description

This PR allows disabling the export server when prometheus is removed from plugins list in config.yaml and then the plugin reload api is called.

Fixes #11046

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@shreemaan-abhishek shreemaan-abhishek force-pushed the fix/prometheus-disable-perf-problem branch from 86d0e0e to eab64d3 Compare April 6, 2024 16:51
@shreemaan-abhishek shreemaan-abhishek marked this pull request as ready for review April 7, 2024 17:14
t/cli/test_prometheus_reload.sh Outdated Show resolved Hide resolved
apisix/plugins/prometheus/exporter.lua Outdated Show resolved Hide resolved
@@ -344,6 +346,15 @@ function _M.load(config)
if not ok then
core.log.error("failed to load plugins: ", err)
end

local enabled = core.table.array_find(http_plugin_names, "prometheus") ~= nil
local active = exporter.get_prometheus() ~= nil
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we don't need to get the active status.
Since the exporter.destroy is harmless.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you are right

Copy link
Contributor

Choose a reason for hiding this comment

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

And so do line355 ~ line357

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no I think the second if check needs the active status. Consider this case:

  • apisix is running with prometheus active and enabled
  • hit plugin reload

In this case enabled == true and active == true. But we need not call http_init() in prometheus because it is already running during this operation.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it.

t/plugin/prometheus4.t Outdated Show resolved Hide resolved
t/plugin/prometheus4.t Outdated Show resolved Hide resolved
t/plugin/prometheus4.t Show resolved Hide resolved
@moonming moonming changed the title fix: disable features when plugin is turned off fix(prometheus): disable features when prometheus plugin is turned off Apr 9, 2024
@moonming moonming merged commit 6edd863 into apache:master Apr 10, 2024
70 checks passed
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: Disable All Prometheus-related Features When Prometheus Plugin is Turned Off
3 participants