DevOps之prometheus监控

作者: OrangeLoveMilan | 来源:发表于2018-04-04 18:20 被阅读238次

    写在前面

    作为一个后端运维,监控是最重要,必不可少的一项工作。工作中我一共用过两种监控,zabbix和prometheus。先谈谈这两种监控的工具的优缺点,基于本人使用后的感受,仅供参考

    zabbix prometheus
    数据库(性能瓶颈) mysql、pg tsdb
    架构(后期运维) c/s 不需要安装客户端
    资料(友好程度) 老牌监控,网上资料多 小众监控,资料少,需要多看官方文档
    对象(应用场景) 适合面向工具,适合做中间件、交换机等监控 适合面向服务,适合做链路监控
    模板(工作量) 模板多 模板少
    UI(逼格) 自带画图,简洁,支持grafana 自身丑,grafana原生支持,用grafana后很炫酷
    规格 监控集群规模大了比较吃力,麻烦 轻松应对,服务自动发现

    个人比较喜欢prometheus,给人感觉很青春,自己写exporter,每个监控参数都可控,出问题也能很快定位到。这里先记录下利用容器快速搭建监控

    目录:

    • promettheus的搭建
    • grafana的搭建

    1.1、拉取prometheus镜像

    搜索prometheus的镜像、选择Stars最多的镜像
    sudo docker search prometheus

    lugo@iZuf6gfo7g3452fkrhq8xwZ:~$ sudo docker search prometheus
    NAME                                          DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
    prom/prometheus                                                                               382                                     [OK]
    infinityworks/prometheus-rancher-exporter     Exposes Service/Stack/Host status from the R…   6                                       [OK]
    basi/prometheus-swarm                         A sample image that can be used as a base fo…   6                                       [OK]
    argussecurity/cassandra-prometheus            Docker Official Cassandra image, with Promet…   4                                       [OK]
    sscaling/jmx-prometheus-exporter              A docker image containing a released version…   3                                       [OK]
    stackhub/prometheus                           Dynamically find cadvisor agents and aggrega…   2                                       [OK]
    lloesche/prometheus-dcos                      Prometheus on DC/OS                             1                                       [OK]
    wehkamp/prometheus-cloudflare-exporter        Prometheus Cloudflare exporter                  1
    functions/prometheus                          prometheus                                      1                                       [OK]
    bandsintown/prometheus                        Docker images for Prometheus based on Alpine…   1
    dbhi/prometheus-sql                           Prototype service for exposing metrics on SQ…   1                                       [OK]
    lloesche/prometheus-grafana-dcos              Grafana for Prometheus on DC/OS                 1                                       [OK]
    openshift/prometheus                          Prometheus images for OpenShift                 1
    vampouille/prometheus_rancher_metadata        Expose rancher metadata 'create_index' field…   1                                       [OK]
    appcelerator/amp-prometheus                   Prometheus image with a Docker swarm discove…   0
    
    
    

    sudo docker pull prom/prometheus

    1.2、启动prometheus服务

    mkdir prometheus
    cd prometheus
    vim prometheus.yml
    
    global:
      scrape_interval:     60s
      evaluation_interval: 60s
    
    scrape_configs:
      - job_name: prometheus
        static_configs:
          - targets: ['ip:port']
            labels:
              instance: prometheus
    

    sudo docker run -d -p 9090:9090 --net=host -v /home/lugo/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml --name Monitor prom/prometheus
    -d:容器后台运行
    -p:映射的端口
    --net:网络模式,这里选择主机模式,与宿主机公用一个network的namespace
    -v:将配置文件挂在出来
    --name:container名字

    2.1、拉取grafana镜像

    选择stars最多的镜像

    lugo@iZuf6gfo7g3452fkrhq8xwZ:~/grafana$ sudo docker search grafana
    NAME                                               DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
    grafana/grafana                                    The official Grafana docker container           682
    kamon/grafana_graphite                             All in one image running StatsD, Graphite an…   140
    monitoringartist/grafana-xxl                       Dockerized Grafana 4.x/3.x with all preinsta…   59                                      [OK]
    tutum/grafana                                      Grafana dashboard for InfluxDB. Please set "…   56                                      [OK]
    samuelebistoletti/docker-statsd-influxdb-grafana   Docker Image with Telegraf (StatsD), InfluxD…   48                                      [OK]
    fg2it/grafana-armhf                                Unofficial Grafana docker container for armhf   24
    appcelerator/grafana                               Grafana image based on Alpine linux             5                                       [OK]
    philhawthorne/docker-influxdb-grafana              A docker container to run InfluxDB and Grafa…   3                                       [OK]
    luzifer/grafana                                    Automated build from Grafana Debian package     3                                       [OK]
    hawkular/hawkular-grafana-datasource               Grafana with pre-installed Hawkular datasour…   2
    lloesche/prometheus-grafana-dcos                   Grafana for Prometheus on DC/OS                 1                                       [OK]
    

    2.2、启动grafana服务

    sudo docker run -d --net=host -v /home/lugo/grafana/grafana_db:/var/lib/grafana -e "GF_SECURITY_ADMIN_PASSWORD=passwd" --name grafana grafana/grafana

    地址:http://ip:3000/
    账号密码:admin/passwd

    相关文章

      网友评论

        本文标题:DevOps之prometheus监控

        本文链接:https://www.haomeiwen.com/subject/lhclhftx.html