Prometheus配置prometheus.yml监控多个mysql和服务器性能

最近在部署Prometheus监控mysql,搭建起来后配置prometheus.yml监控多个机器,结果遇到配置文件错误问题,配置文件如下:

# 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).

  # Attach these labels to any time series or alerts when communicating with
  # external systems (federation, remote storage, Alertmanager).
  external_labels:
      monitor: 'codelab-monitor'

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first.rules"
  # - "second.rules"

# 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=<job_name>` to any timeseries scraped from this config.
  - job_name: 'prometheus'

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
      - targets: ['localhost:9090']

  - job_name: linux
    static_configs:
      - targets: ['127.0.0.1:9100']
        labels:
          instance: db1

  - job_name: mysql
    static_configs:
      - targets: ['127.0.0.1:9104']
        labels:
          instance: db1

- job_name: linux_22  --40行(就是这类错误) 
    static_configs:
      - targets: ['192.168.23.22:9100']
        labels:
          instance: mysql_54

  - job_name: mysql_22
    static_configs:
      - targets: ['192.168.23.22:9104']
        labels:
          instance: mysql_54

报错信息:

time="2018-01-30T17:31:03+08:00" level=info msg="Starting prometheus (version=1.6.3, branch=master, revision=c580b60c67f2c5f6b638c3322161bcdf6d68d7fc)" source="main.go:88" 
time="2018-01-30T17:31:03+08:00" level=info msg="Build context (go=go1.8.1, user=root@a6410e65f5c7, date=20170522-09:15:06)" source="main.go:89" 
time="2018-01-30T17:31:03+08:00" level=info msg="Loading configuration file prometheus.yml" source="main.go:251" 
time="2018-01-30T17:31:03+08:00" level=error msg="Error loading config: couldn't load configuration (-config.file=prometheus.yml): yaml: line 40: did not find expected key" source="main.go:159" 

看了官方文档和也没觉得哪里写错,真是郁闷,百度,谷歌,bing,看到一哥们说是格式问题,缩进是必须的,我合计试一下反正也没别的方案了,结果尼玛真的可以了,大家看我再配置文件中标记了配置文件40行的位置,然后又研究了下yml文档格式要求,果然哭了yml格式,必须要求缩进,也是用yml文件用的不多,以后涨记性了。

猜你喜欢

转载自blog.csdn.net/u014180504/article/details/79209037