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

25 篇文章 0 订阅
2 篇文章 1 订阅

本人文章陆续转向本人微信公账号发布 公众号:搬砖码农SmallNNN,期望您要是搬砖码农,一起学习探讨,祝您阅读愉快。 
最近在部署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文件用的不多,以后涨记性了。

评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值