zoukankan      html  css  js  c++  java
  • prometheus + grafana安装部署(centos6.8)

     

     

    官方网址:https://prometheus.io/

    GitHub网址:https://github.com/prometheus/prometheus

    软件下载地址:https://prometheus.io/download/

    第三方中文介绍:https://github.com/1046102779/prometheus

    prometheus介绍

           Prometheus是一个开源的系统监控和报警的工具包,最初由SoundCloud发布。

    特点:

    • 多维数据模型(有metric名称和键值对确定的时间序列)
    • 灵活的查询语言
    • 不依赖分布式存储
    • 通过pull方式采集时间序列,通过http协议传输
    • 支持通过中介网关的push时间序列的方式
    • 监控数据通过服务或者静态配置来发现
    • 支持图表和dashboard等多种方式

    组件:

    • Prometheus 主程序,主要是负责存储、抓取、聚合、查询方面。
    • Alertmanager 程序,主要是负责实现报警功能。
    • Pushgateway 程序,主要是实现接收由Client push过来的指标数据,在指定的时间间隔,由主程序来抓取。
    • *_exporter 这类是不同系统已经实现了的集成。

    架构:

    prometheus部署

    1、下载安装包prometheus-1.6.2.linux-amd64.tar.gz

    https://github.com/prometheus/prometheus/releases/tag/v1.6.2

    2、解压

    1
    2
    tar -xvf prometheus-1.6.2.linux-amd64.tar.gz
    cd prometheus-1.6.2.linux-amd64

    3、配置prometheus.yml 

    • scrape_interval: 15s   # 默认15秒到目标处抓取数据

    4、启动

    1
    2
    3
    nohup ./prometheus -config.file=prometheus.yml &
    nohup /opt/prometheus-1.6.2.linux-amd64/prometheus &

    5、WEB页面访问http://localhost:9090/ ,可以看到Prometheus的graph页面。

    备注:参考文章 http://www.cnblogs.com/vovlie/p/Prometheus_install.html

    grafana部署

    http://docs.grafana.org/installation/rpm/

    1、安装

    1
    2
    3
    wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-4.2.0-1.x86_64.rpm
    sudo yum install initscripts fontconfig -y
    sudo rpm -Uvh grafana-4.2.0-1.x86_64.rpm

    2、启动服务service grafana-server start

    3、访问页面http://localhost:3000 ,默认账号、密码admin/admin

    4、Prometheus 和 Grafana 的对接

    https://prometheus.io/docs/visualization/grafana/

    参考文章:http://www.cnblogs.com/sfnz/p/6566951.html

    MySQL的dashboards(Grafana)

    https://github.com/percona/grafana-dashboards

    1
    2
    git clone https://github.com/percona/grafana-dashboards.git
    cp -r grafana-dashboards/dashboards /var/lib/grafana/dashboards

    编辑Grafana配置文件

    1
    2
    3
    4
    vi /etc/grafana/grafana.ini
    [dashboards.json]
    enabled = true
    path = /var/lib/grafana/dashboards

    重启service grafana-server restart

    mysql监控部署

    在需要监控的mysql上安装 node_exporter和 mysqld_exporter

    下载 https://prometheus.io/download/

    1
    2
    3
    tar -xvf node_exporter-0.14.0.linux-amd64.tar.gz
    cd node_exporter-0.14.0.linux-amd64
    nohup ./node_exporter &
    1
    2
    3
    4
    5
    6
    7
    8
    9
    tar -xvf mysqld_exporter-0.10.0.linux-amd64.tar.gz
    cd mysqld_exporter-0.10.0.linux-amd64
     
    vi .my.cnf
    [client]
    user=root
    password=root
     
    ./mysqld_exporter -config.my-cnf=".my.cnf" &

    服务端配置,文件prometheus.yml

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    scrape_configs:
      - job_name: 'prometheus'
        static_configs:
          - targets: ['localhost:9090']
     
      - job_name: 'mysql'
        static_configs:
          - targets: ['10.10.83.162:9104']
            labels:
              instance: db-10.10.83.162

    redis监控部署

    下载 https://github.com/oliver006/redis_exporter/releases

    1
    2
    tar -xvf redis_exporter-v0.11.linux-amd64.tar.gz
    nohup /opt/redis_exporter -redis.addr "redis://10.10.83.162:16379" &

    grafana配置

    下载 redis_exporter-0.11.tar.gz

    1
    2
    3
    tar -xvf redis_exporter-0.11.tar.gz
    cd redis_exporter-0.11 
    cp *json /var/lib/grafana/dashboards/

    服务端配置,文件prometheus.yml

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    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: 'mysql'
        static_configs:
          - targets: ['10.10.83.162:9104']
            labels:
              instance: db-10.10.83.162
     
      - job_name: redis_exporter
        static_configs:
          - targets: ['10.10.83.162:9121']
            labels:
              instance: redis-10.10.83.162
  • 相关阅读:
    LeetCode---Remove Duplicates from Sorted List II
    hackerrank---Sets
    hackerrank---Find a string
    push的时候隐藏底部的tabbar
    选择性编译代码:如 #ifdef __IPHONE_7_0
    客户端的文件存储文件夹代表意义
    设置非ARC
    KVC设置系统自带属性,不管是不是私有的属性
    一些关于队列,同步,异步的概念
    要求两个异步任务都完成后, 才能回到主线程:dispatch_group_t
  • 原文地址:https://www.cnblogs.com/piwefei/p/10449386.html
Copyright © 2011-2022 走看看