diff --git a/deps/3_prometheus/init.sh b/deps/3_prometheus/init.sh index ed8316fa3ce4822d62a8a0375c62411a3f6dbd3a..0f8e3367ca6978dc7b556aac7dfb1c58fdccf9c3 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 +