-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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(prometheus): support collect metrics works in the priviledged agent #8434
Merged
Merged
Changes from 19 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
dc8505e
feat(prometheus): support collect metrics works in the priviledged agent
tzssangglass bfaf952
fix lint
tzssangglass c8534d8
fix lint
tzssangglass aa328fc
exit_if_not_customed_nginx
tzssangglass 4e1faf2
use_apisix_openresty in ngx_tpl
tzssangglass 5e0df8b
move enable privileged agent to ngx_tpl
tzssangglass dc9bdff
sleep
tzssangglass b616fed
fix
tzssangglass fce28d3
debug
tzssangglass aa311b0
debug
tzssangglass f05c009
fix
tzssangglass 467bee8
Merge branch 'master' into prip
tzssangglass 0663c86
revert timeout
tzssangglass ab46fc1
resolve comments
tzssangglass 261a0b1
resolve commects
tzssangglass 011ab0c
revert exporter
tzssangglass 1814f4e
chore echo
tzssangglass 4c1b162
fix
tzssangglass bf4d8d4
resolve comments
tzssangglass 9e8b135
move exporter
tzssangglass File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
-- | ||
tzssangglass marked this conversation as resolved.
Show resolved
Hide resolved
|
||
-- Licensed to the Apache Software Foundation (ASF) under one or more | ||
-- contributor license agreements. See the NOTICE file distributed with | ||
-- this work for additional information regarding copyright ownership. | ||
-- The ASF licenses this file to You under the Apache License, Version 2.0 | ||
-- (the "License"); you may not use this file except in compliance with | ||
-- the License. You may obtain a copy of the License at | ||
-- | ||
-- http://www.apache.org/licenses/LICENSE-2.0 | ||
-- | ||
-- Unless required by applicable law or agreed to in writing, software | ||
-- distributed under the License is distributed on an "AS IS" BASIS, | ||
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
-- See the License for the specific language governing permissions and | ||
-- limitations under the License. | ||
-- | ||
local apisix = require("apisix") | ||
local core = require("apisix.core") | ||
local _M = {} | ||
|
||
|
||
function _M.http_init() | ||
return true | ||
end | ||
|
||
|
||
function _M.export_metrics() | ||
local process_type = require("ngx.process").type() | ||
core.log.info("process type: ", process_type) | ||
return core.response.exit(200) | ||
end | ||
|
||
|
||
return _M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
#!/usr/bin/env bash | ||
|
||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
. ./t/cli/common.sh | ||
|
||
git checkout conf/config.yaml | ||
|
||
exit_if_not_customed_nginx | ||
|
||
# prometheus run in privileged works when only http is enabled | ||
sleep 0.5 | ||
rm logs/error.log || true | ||
|
||
echo ' | ||
apisix: | ||
extra_lua_path: "\$prefix/example/?.lua" | ||
lua_module_hook: apisix.plugins.prometheus.exporter | ||
nginx_config: | ||
error_log_level: info | ||
' > conf/config.yaml | ||
|
||
make run | ||
sleep 0.1 | ||
|
||
curl -s -o /dev/null http://127.0.0.1:9091/apisix/prometheus/metrics | ||
|
||
if ! grep -E "process type: privileged agent" logs/error.log; then | ||
echo "failed: prometheus run in privileged can't work when only http is enabled" | ||
exit 1 | ||
fi | ||
|
||
make stop | ||
|
||
echo "prometheus run in privileged agent successfully when only http is enabled" | ||
|
||
|
||
# prometheus run in privileged works when both http & stream are enabled | ||
sleep 0.5 | ||
rm logs/error.log || true | ||
|
||
echo " | ||
apisix: | ||
extra_lua_path: "\$prefix/example/?.lua" | ||
lua_module_hook: apisix.plugins.prometheus.exporter | ||
enable_admin: true | ||
stream_proxy: | ||
tcp: | ||
- addr: 9100 | ||
stream_plugins: | ||
- prometheus | ||
nginx_config: | ||
error_log_level: info | ||
" > conf/config.yaml | ||
|
||
make run | ||
sleep 0.1 | ||
|
||
curl -s -o /dev/null http://127.0.0.1:9091/apisix/prometheus/metrics | ||
|
||
if ! grep -E " process type: privileged agent" logs/error.log; then | ||
echo "failed: prometheus run in privileged can't work when both http & stream are enabled" | ||
exit 1 | ||
fi | ||
|
||
echo "passed: prometheus run in privileged agent successfully when both http & stream are enabled" | ||
|
||
make stop | ||
|
||
|
||
# prometheus run in privileged works when only stream is enabled | ||
sleep 0.5 | ||
rm logs/error.log || true | ||
|
||
echo " | ||
apisix: | ||
extra_lua_path: "\$prefix/example/?.lua" | ||
lua_module_hook: apisix.plugins.prometheus.exporter | ||
enable_admin: false | ||
stream_proxy: | ||
tcp: | ||
- addr: 9100 | ||
stream_plugins: | ||
- prometheus | ||
nginx_config: | ||
error_log_level: info | ||
" > conf/config.yaml | ||
|
||
make run | ||
sleep 0.1 | ||
|
||
curl -s -o /dev/null http://127.0.0.1:9091/apisix/prometheus/metrics | ||
|
||
if ! grep -E " process type: privileged agent" logs/error.log; then | ||
echo "failed: prometheus run in privileged can't work when only stream is enabled" | ||
exit 1 | ||
fi | ||
|
||
echo "passed: prometheus run in privileged agent successfully when only stream is enabled" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I double-checked this line and it seems the
apisix
is not used?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove it, and this helped me to solve the problem of repeatedly requiring apisix, thanks.