From 419035ede90bb0460c1545eab27c5844d349aa96 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 17 Jun 2024 19:25:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E7=AB=AF=E5=8F=A3=E5=8F=B7=E5=90=8E=EF=BC=8Cpromethus=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E8=8E=B7=E5=8F=96=E8=87=AA=E5=AE=9A=E4=B9=89=E7=AB=AF?= =?UTF-8?q?=E5=8F=A3=E5=8F=B7=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deps/3_prometheus/init.sh | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/deps/3_prometheus/init.sh b/deps/3_prometheus/init.sh index ed8316fa..0f8e3367 100644 --- a/deps/3_prometheus/init.sh +++ b/deps/3_prometheus/init.sh @@ -2,34 +2,50 @@ BaseDir=$(dirname $(readlink -f "$0")) SERVICE_NAME=sysom-prometheus +SERVER_PORT1=$(echo $SERVER_PORT) +if [ -z "$SERVER_PORT" ]; then + SERVER_PORT1=80 +fi + add_auto_discovery() { pushd ${DEPS_HOME}/prometheus + # pushd /usr/local/sysom/deps/prometheus mkdir -p node - cat << EOF >> prometheus.yml - - job_name: 'auto_discovery' + # Check if job_name already exists in prometheus.yml + if ! grep -q 'job_name: "auto_discovery"' prometheus.yml; then + cat << EOF >> prometheus.yml + - job_name: "auto_discovery" metrics_path: '/metrics' scheme: 'http' http_sd_configs: - - url: 'http://localhost/api/v1/monitor/prometheus/sd_config' + - url: 'http://localhost:$SERVER_PORT1/api/v1/monitor/prometheus/sd_config' refresh_interval: 10s + tls_config: + insecure_skip_verify: true +EOF + fi + + if ! grep -q 'job_name: "cec_monitor"' prometheus.yml; then + cat << EOF >> prometheus.yml - job_name: "cec_monitor" metrics_path: "/api/v1/channel/cec_status/metrics" static_configs: - targets: ["localhost:7003"] +EOF + fi + + if ! grep -q 'job_name: "cluster_health"' prometheus.yml; then + cat << EOF >> prometheus.yml - job_name: "cluster_health" metrics_path: "/metrics" static_configs: - targets: ["localhost:7020"] - - job_name: "colocation" - metrics_path: "/metrics" - static_configs: - - targets: ["localhost:7022"] - EOF + fi - popd + popd } init_conf() { @@ -48,4 +64,5 @@ init_app() { init_app # Start -bash -x $BaseDir/start.sh \ No newline at end of file +bash -x $BaseDir/start.sh + -- Gitee