From 8d4acada4c328322a53ebee0384b8e5a494b73d9 Mon Sep 17 00:00:00 2001 From: "Xinwei Xiong(cubxxw)" <3293172751nss@gmail.com> Date: Tue, 14 Nov 2023 15:56:17 +0800 Subject: [PATCH] fix: fix prom config file them Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> --- config/prometheus.yml | 36 ++++++++++++++-------------- deployments/templates/prometheus.yml | 4 ++-- scripts/genconfig.sh | 15 +++++++++--- scripts/install/environment.sh | 3 ++- scripts/lib/util.sh | 12 +++------- 5 files changed, 37 insertions(+), 33 deletions(-) diff --git a/config/prometheus.yml b/config/prometheus.yml index c5b5b4071..9c62923b1 100644 --- a/config/prometheus.yml +++ b/config/prometheus.yml @@ -6,9 +6,9 @@ global: # Alertmanager configuration alerting: - #alertmanagers: - # - static_configs: - # - targets: ['172.29.166.17:9093'] #alertmanager地址 +#alertmanagers: +# - static_configs: +# - targets: ['172.29.166.17:9093'] #alertmanager地址 # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. rule_files: @@ -19,67 +19,67 @@ rule_files: # A scrape configuration containing exactly one endpoint to scrape: # Here it's Prometheus itself. scrape_configs: - # The job name is added as a label `job=` to any timeseries scraped from this config. - # prometheus抓取的监控的信息 + # The job name is added as a label to any timeseries scraped from this config. + # Monitored information captured by prometheus - job_name: 'node-exporter' static_configs: - - targets: [ '172.29.166.17:19100' ] + - targets: [ '172.28.0.1:19100' ] labels: namespace: 'default' - # prometheus抓取应用服务 + # prometheus fetches application services - job_name: 'openimserver-openim-api' static_configs: - - targets: [ '172.29.166.17:20100' ] + - targets: [ '172.28.0.1:20100' ] labels: namespace: 'default' - job_name: 'openimserver-openim-msggateway' static_configs: - - targets: [ '172.29.166.17:20140' ] + - targets: [ '172.28.0.1:20140' ] labels: namespace: 'default' - job_name: 'openimserver-openim-msgtransfer' static_configs: - - targets: [ '172.29.166.17:21400','172.29.166.17:21401','172.29.166.17:21402','172.29.166.17:21403' ] + - targets: [ 172.28.0.1:21400, 172.28.0.1:21401, 172.28.0.1:21402, 172.28.0.1:21403 ] labels: namespace: 'default' - job_name: 'openimserver-openim-push' static_configs: - - targets: [ '172.29.166.17:20170' ] + - targets: [ '172.28.0.1:20170' ] labels: namespace: 'default' - job_name: 'openimserver-openim-rpc-auth' static_configs: - - targets: [ '172.29.166.17:20160' ] + - targets: [ '172.28.0.1:20160' ] labels: namespace: 'default' - job_name: 'openimserver-openim-rpc-conversation' static_configs: - - targets: [ '172.29.166.17:20230' ] + - targets: [ '172.28.0.1:20230' ] labels: namespace: 'default' - job_name: 'openimserver-openim-rpc-friend' static_configs: - - targets: [ '172.29.166.17:20120' ] + - targets: [ '172.28.0.1:20120' ] labels: namespace: 'default' - job_name: 'openimserver-openim-rpc-group' static_configs: - - targets: [ '172.29.166.17:20150' ] + - targets: [ '172.28.0.1:20150' ] labels: namespace: 'default' - job_name: 'openimserver-openim-rpc-msg' static_configs: - - targets: [ '172.29.166.17:20130' ] + - targets: [ '172.28.0.1:20130' ] labels: namespace: 'default' - job_name: 'openimserver-openim-rpc-third' static_configs: - - targets: [ '172.29.166.17:21301' ] + - targets: [ '172.28.0.1:21301' ] labels: namespace: 'default' - job_name: 'openimserver-openim-rpc-user' static_configs: - - targets: [ '172.29.166.17:20110' ] + - targets: [ '172.28.0.1:20110' ] labels: namespace: 'default' diff --git a/deployments/templates/prometheus.yml b/deployments/templates/prometheus.yml index 84cd68830..20d63f870 100644 --- a/deployments/templates/prometheus.yml +++ b/deployments/templates/prometheus.yml @@ -20,14 +20,14 @@ rule_files: # Here it's Prometheus itself. scrape_configs: # The job name is added as a label `job=` to any timeseries scraped from this config. - # prometheus抓取的监控的信息 + # Monitored information captured by prometheus - job_name: 'node-exporter' static_configs: - targets: [ '${NODE_EXPORTER_ADDRESS}:${NODE_EXPORTER_PORT}' ] labels: namespace: 'default' - # prometheus抓取应用服务 + # prometheus fetches application services - job_name: 'openimserver-openim-api' static_configs: - targets: [ '${OPENIM_SERVER_ADDRESS}:${API_PROM_PORT}' ] diff --git a/scripts/genconfig.sh b/scripts/genconfig.sh index 9c5f39a11..2371edc9d 100755 --- a/scripts/genconfig.sh +++ b/scripts/genconfig.sh @@ -13,8 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -# 本脚本功能:根据 scripts/environment.sh 配置,生成 OPENIM 组件 YAML 配置文件。 -# 示例:./scripts/genconfig.sh scripts/install/environment.sh scripts/template/config.yaml +# Function of this script: Generate the OPENIM component YAML configuration file according to the scripts/environment.sh configuration. +# eg:./scripts/genconfig.sh scripts/install/environment.sh scripts/template/config.yaml # Read: https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/init-config.md env_file="$1" @@ -29,8 +29,17 @@ if [ $# -ne 2 ];then exit 1 fi -# Check if the required commands exist openim::util::require-dig +result=$? +if [ $result -ne 0 ]; then + openim::log::info "Please install 'dig' to use this feature." + openim::log::info "Installation instructions:" + openim::log::info " For Ubuntu/Debian: sudo apt-get install dnsutils" + openim::log::info " For CentOS/RedHat: sudo yum install bind-utils" + openim::log::info " For macOS: 'dig' should be preinstalled. If missing, try: brew install bind" + openim::log::info " For Windows: Install BIND9 tools from https://www.isc.org/download/" + openim::log::error_exit "Error: 'dig' command is required but not installed." +fi source "${env_file}" diff --git a/scripts/install/environment.sh b/scripts/install/environment.sh index abe47604a..aa1e0b212 100755 --- a/scripts/install/environment.sh +++ b/scripts/install/environment.sh @@ -376,7 +376,8 @@ readonly THIRD_PROM_PORT=${THIRD_PROM_PORT:-'21301'} # Message Transfer 服务的 Prometheus 端口列表 readonly MSG_TRANSFER_PROM_PORT=${MSG_TRANSFER_PROM_PORT:-'21400, 21401, 21402, 21403'} -readonly MSG_TRANSFER_PROM_ADDRESS_PORT="${DOCKER_BRIDGE_GATEWAY}:21400, ${DOCKER_BRIDGE_GATEWAY}:21401, ${DOCKER_BRIDGE_GATEWAY}:21402, ${DOCKER_BRIDGE_GATEWAY}:21403" +readonly MSG_TRANSFER_PROM_ADDRESS_PORT=${MSG_TRANSFER_PROM_ADDRESS_PORT:-"${DOCKER_BRIDGE_GATEWAY}:21400, ${DOCKER_BRIDGE_GATEWAY}:21401, ${DOCKER_BRIDGE_GATEWAY}:21402, ${DOCKER_BRIDGE_GATEWAY}:21403"} + ###################### OpenIM openim-api ###################### def "OPENIM_API_HOST" "127.0.0.1" def "OPENIM_API_BINARY" "${OPENIM_OUTPUT_HOSTBIN}/openim-api" # OpenIM openim-api 二进制文件路径 diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index de94d8ceb..ad3baa6bf 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -1121,8 +1121,7 @@ function openim::util::check-file-in-alphabetical-order { # Checks whether jq is installed. function openim::util::require-jq { if ! command -v jq &>/dev/null; then - echo "jq not found. Please install." 1>&2 - return 1 + openim::log::errexit "jq not found. Please install." 1>&2 fi } @@ -1130,15 +1129,10 @@ function openim::util::require-jq { # Checks whether dig is installed and provides installation instructions if it is not. function openim::util::require-dig { if ! command -v dig &>/dev/null; then - echo "dig command not found." - echo "Please install 'dig' to use this feature." - echo "Installation instructions:" - echo " For Ubuntu/Debian: sudo apt-get install dnsutils" - echo " For CentOS/RedHat: sudo yum install bind-utils" - echo " For macOS: 'dig' should be preinstalled. If missing, try: brew install bind" - echo " For Windows: Install BIND9 tools from https://www.isc.org/download/" + openim::log::error "dig command not found." return 1 fi + return 0 } # outputs md5 hash of $1, works on macOS and Linux