投资菜地

屋后的一亩三分绿色菜园地

2019-10-15

prometheus服务器监控解决方案

Prometheus

启动node-exporter

docker run -d -p 9100:9100  -v "/proc:/host/proc:ro" -v "/sys:/host/sys:ro" -v "/:/rootfs:ro" --net="host"  prom/node-exporter

启动prometheus

mkdir /opt/prometheus cd /opt/prometheus/ vim prometheus.yml

global:
  scrape_interval:     60s
  evaluation_interval: 60s
  web: 
     listen_address: '0.0.0.0:8088'
scrape_configs:
- job_name: prometheus
  static_configs:
  - targets: ['localhost:9090']
    labels:
      instance: prometheus
- job_name: 'consul'
  consul_sd_configs:
  - server: 'localhost:8500'
  relabel_configs:
  - source_labels: [__meta_consul_tags]
    regex: .*,prome,.*
    action: keep
  - source_labels: [__meta_consul_service]
    target_label: job

- job_name: linux
  static_configs:
  - targets: ['192.168.91.132:9100']  # exporter地址
    labels:
      instance: localhost
docker run -d -p 9090:9090 -v /opt/prometheus:/etc/prometheus --name prometheus prom/prometheus

启动grafana

mkdir /opt/grafana-storage
chmod 777 -R /opt/grafana-storage
docker run -d -p 3000:3000 --name=grafana -v /opt/grafana-storage:/var/lib/grafana grafana/grafana

设置

goto: http://localhost:3000/

admin/admin

add datasource Prometheus

开源项目(更多)