一、创建配置文件
mkdir -p /etc/promethues
cat > /etc/promethues/promethues.xml <<EOF
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'cluster-kong-custom-apis'
file_sd_configs:
- files:
- /etc/promethues/targets/kong-custom-apis.yml
refresh_interval: 1m
relabel_configs:
- source_labels: [__address__]
regex: (.*)
target_label: instance
replacement: kong-custom-apis-${1}
EOF
二、配置服务发现
mkdir -p /etc/promethues/targets/
cat > /etc/promethues/targets/kong-custom-apis.yml << EOF
- targets:
- 10.0.0.1:8001
labels:
cluster: "kong-custom-apis"
EOF
cat > /etc/promethues/targets/kong-custom-scs-apis.yml << EOF
- targets:
- 10.0.0.1:8001
EOF
三、启动Prometheus
pkill prometheus
./prometheus \
--config.file=/etc/promethues/promethues.xml \
--storage.tsdb.retention.time=15d \
--web.enable-admin-api >> /var/log/prometheus.log &
网友评论