栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

prometheus 监控服务器性能

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

prometheus 监控服务器性能

服务器上安装了docker,在装docker服务器上进行

参考地址:https://www.cnblogs.com/momoyan/p/11520676.html
docker安装执行下列命令即可

docker run -d --net="host" --pid="host" --name=node-exporter -v "/:/host:ro,rslave" prom/node-exporter --path.rootfs /host --web.listen-address=":19100"

非docker安装执行下列四步

第一步

下载 node_exporter,下载地址
https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz

第二步

上传到服务器 /opt/exporter下
解压: tar -xvzf node_exporter-0.14.0.linux-amd64.tar.gz

第三部

进入解压后的文件夹,执行命令:
./node_exporter --web.listen-address=:19100 &

然后在服务器上开放19100 端口,测试用ip+19100端口即可访问到数据
contOS6 版本的防火墙重启 : /etc/init.d/iptables restart 
contOS7 版本的防火墙重启 :service iptables restart

第四步

prometheus.yml 配置

  - job_name: '214服务器'

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

    static_configs:
      #      - targets: ['166.16.6.75:9090']
      - targets: [ '172.16.8.214:19100']

全部配置文件:

# 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:
            - 172.16.8.214:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"
  - "/etc/prometheus/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: '普罗米修斯214服务器'
    static_configs:
      - targets: [ '172.16.8.214:19100']
        labels:
          instance: '普罗米修斯214服务器'
          
  - job_name: '鞍山调剂数据库服务器'
    static_configs:
      - targets: [ '172.16.8.195:19100' ]
        labels:
          instance: '鞍山调剂平台服务器'

  - job_name: '鞍山调剂平台服务器'
    static_configs:
      - targets: [ '172.16.8.193:19100' ]
        labels:
          instance: '鞍山调剂平台服务器'

  - job_name: '鞍山监管数据库服务器'
    static_configs:
      - targets: [ '172.16.8.194:19100' ]
        labels:
          instance: '鞍山监管数据库服务器'

  - job_name: '鞍山监管平台服务器'
    static_configs:
      - targets: [ '172.16.8.192:19100' ]
        labels:
          instance: '鞍山监管平台服务器'
          
  - job_name: '成都调剂数据库服务器'
    static_configs:
      - targets: [ '172.16.8.218:19100' ]
        labels:
          instance: '成都调剂数据库服务器'

  - job_name: '成都调剂平台服务器'
    static_configs:
      - targets: [ '172.16.8.217:19100' ]
        labels:
          instance: '成都调剂平台服务器'

  - job_name: '成都监管数据库服务器'
    static_configs:
      - targets: [ '172.16.8.215:19100' ]
        labels:
          instance: '成都监管数据库服务器'

  - job_name: '成都监管平台服务器'
    static_configs:
      - targets: [ '172.16.8.216:19100' ]
        labels:
          instance: '成都监管平台服务器'

  - job_name: 'tomcat'
    file_sd_configs:
    #引用刚才编写的配置文件
    - files: ['/etc/prometheus/tomcat.yml'] 
      refresh_interval: 15s
  # 监控 mysql
  - job_name: 'mysql210'
    static_configs:
      - targets: [ '172.16.8.214:9104' ] #填写mysqld-exporter的docker服务ip:端口或者宿主机ip:映射的端口
        labels:
          instance: '210数据库' #实例名称或ip

  - job_name: 'mysql195'
    static_configs:
      - targets: [ '172.16.8.214:9105' ] #填写mysqld-exporter的docker服务ip:端口或者宿主机ip:映射的端口
        labels:
          instance: '鞍山调剂数据库195' #实例名称或ip

  - job_name: 'mysql194'
    static_configs:
      - targets: [ '172.16.8.214:9106' ] #填写mysqld-exporter的docker服务ip:端口或者宿主机ip:映射的端口
        labels:
          instance: '鞍山监管数据库194' #实例名称或ip
          
  - job_name: 'mysql218'
    static_configs:
      - targets: [ '172.16.8.218:9107' ] #填写mysqld-exporter的docker服务ip:端口或者宿主机ip:映射的端口
        labels:
          instance: '成都调剂数据库218' #实例名称或ip

  - job_name: 'mysql215'
    static_configs:
      - targets: [ '172.16.8.214:9108' ] #填写mysqld-exporter的docker服务ip:端口或者宿主机ip:映射的端口
        labels:
          instance: '成都监管数据库215' #实例名称或ip

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/338385.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号