prometheus修改配置不需要停掉,只要修改yml之后用docker restart重启
docker run --name postgres_name -e POSTGRES_PASSWORD=123456 -p 54321:5432 -d postgres:9.6.19
# my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
# 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.
- job_name: 'prometheus'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
## MUST
static_configs:
- targets: ['localhost:9090']
- job_name: 'kong'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
## MUST
static_configs:
- targets: ['192.168.200.137:8091']
version: '3'
services:
dc-prometheus:
image: prom/prometheus:v2.13.1
container_name: dc-prometheus
networks:
- kong-net
ports:
- "9090:9090"
volumes:
- /opt/dcprometheus/prometheus.yml:/etc/prometheus/prometheus.yml
- /etc/localtime:/etc/localtime
restart: always
networks:
kong-net:
driver: bridge
curl -X POST http://192.168.200.137:8001/plugins/
–data “name=http-log”
–data “config.http_endpoint=http://192.168.200.137:8998/apike/v1/kong”
–data “config.method=POST”
–data “config.timeout=1000”
–data “config.keepalive=1000”
curl -X POST http://192.168.200.137:8001/plugins/
–data “name=http-log”
–data “config.http_endpoint=http://192.168.200.137:8091/apike/v1/kong”
–data “config.method=POST”
–data “config.timeout=1000”
–data “config.keepalive=1000”
curl -X POST http://192.168.400.71:8001/plugins/
–data “name=http-log”
–data “config.http_endpoint=http://192.168.400.70:30671/apike/v1/kong”
–data “config.method=POST”
–data “config.timeout=1000”
–data “config.keepalive=1000”
curl -X POST http://192.168.400.72:8001/plugins/
–data “name=http-log”
–data “config.http_endpoint=http://10.12.6.24:31691/apike/v1/kong”
–data “config.method=POST”
–data “config.timeout=1000”
–data “config.keepalive=1000”
cd /opt/dcprometheus
sudo su
vim prometheus.yml
curl -i -X POST
–url http://192.168.200.137:8001/services/
–data ‘name=example-service’
–data ‘url=http://mockbin.org’
curl -i -X POST
–url http://192.168.200.137:8001/services/
–data ‘name=monitor_metrics’
–data ‘url=http://192.168.232.137:8091/metrics’
curl -i -X POST
–url http://192.168.400.71:8001/services/
–data ‘name=monitor_httpbin’
–data ‘url=http://httpbin.org/get’
curl -i -X POST
–url http://192.168.400.71:8001/services/
–data ‘name=monitor_metrics’
–data ‘url=http://192.168.400.71:8080/metrics’
curl -i -X POST
–url http://192.168.400.72:8001/services/
–data ‘name=monitor_metrics’
–data ‘url=http://192.168.400.72:8080/metrics’
curl -i -X POST
–url http://192.168.200.137:8001/services/example-service/routes
–data ‘hosts[]=192.168.200.137’
–data ‘paths[]=/test’
curl -i -X POST
–url http://192.168.200.137:8001/services/monitor_metrics/routes
–data ‘hosts[]=192.168.200.137’
–data ‘name=monitor_getmetrics’
–data ‘paths[]=/metrics’
curl -i -X POST
–url http://192.168.200.137:8001/services/example-service/routes
–data ‘hosts[]=192.168.200.137’
–data ‘paths[]=/testroute’
curl -i -X POST
–url http://192.168.200.137:8001/services/example-service/routes
–data ‘hosts[]=192.168.200.137’
–data ‘paths[]=/anotherroute’
curl -i -X DELETE
–url http://192.168.200.137:8001/services/example-service/routes/aafb73dc-323d-460a-9fc0-e1eda0e93c76
curl -i -X POST
–url http://192.168.400.71:8001/services/monitor_httpbin/routes
–data ‘hosts[]=192.168.400.71’
–data ‘name=monitor_get’
–data ‘paths[]=/get’
curl -i -X POST
–url http://192.168.400.71:8001/services/monitor_metrics/routes
–data ‘hosts[]=192.168.400.71’
–data ‘name=monitor_getmetrics’
–data ‘paths[]=/metrics’
curl -i -X POST
–url http://192.168.400.72:8001/services/monitor_metrics/routes
–data ‘hosts[]=192.168.400.72’
–data ‘name=monitor_getmetrics’
–data ‘paths[]=/metrics’
curl -i -X POST
–url http://192.168.200.137:8001/consumers
–data ‘username=user1’
–data ‘custom_id=appinstance001’
curl -i -X POST
–url http://192.168.200.137:8001/consumers
–data ‘username=user2’
–data ‘custom_id=appinstance002’
curl -i -X POST
–url http://192.168.400.71:8001/consumers
–data ‘username=monitor_user1’
–data ‘custom_id=monitor_appinstance001’
curl -i -X POST
–url http://192.168.400.71:8001/consumers
–data ‘username=monitor_user2’
–data ‘custom_id=monitor_appinstance002’
curl -i -X POST
–url http://192.168.400.72:8001/consumers
–data ‘username=monitor_user1’
–data ‘custom_id=monitor_appinstance001’
curl -i -X POST
–url http://192.168.200.137:8001/services/example-service/plugins/
–data ‘name=key-auth’
curl -i -X POST
–url http://192.168.200.137:8001/services/monitor_metrics/plugins/
–data ‘name=key-auth’
curl -i -X POST
–url http://192.168.400.71:8001/services/monitor_metrics/plugins/
–data ‘name=key-auth’
curl -i -X POST
–url http://192.168.400.72:8001/services/monitor_metrics/plugins/
–data ‘name=key-auth’
curl -i -X POST
–url http://192.168.200.137:8001/consumers/user1/key-auth/
–data ‘key=123456-asdfg’
curl -i -X POST
–url http://192.168.200.137:8001/consumers/user2/key-auth/
–data ‘key=67890-zxcv’
curl -i -X POST
–url http://192.168.400.71:8001/consumers/monitor_user1/key-auth/
–data ‘key=monitor_user1’
curl -i -X POST
–url http://192.168.400.71:8001/consumers/monitor_user2/key-auth/
–data ‘key=monitor_user2’
curl -i -X POST
–url http://192.168.400.72:8001/consumers/monitor_user1/key-auth/
–data ‘key=monitor_user1’
curl -i -X POST
–url http://localhost:8001/apis/
–data ‘name=example-api’
–data ‘hosts=example.com’
–data ‘upstream_url=http://www.baidu.com’
{
——kong-exporter metrics包含启动后某一时刻的累加数据(只有结果);prometheue存储的是定时拉取的metrics