暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

0048.S Prometheus+Grafana监控StarRocks(一)

rundba 2022-05-23
1638

StarRocks提供两种监控报警的方案,第一种是使用内置的StarRocks Manager,其自带的Agent从各个Host采集监控信息上报到Center Service然后做可视化展示,也提供了邮件和Webhook的方式发送报警通知。

但是如果用户为了二次开发需求,需要自己搭建部署监控服务,也可以使用开源的Prometheus+Grafana的方案,StarRocks提供了兼容Prometheus的信息采集接口,可以通过直接链接BE/FE的HTTP端口来获取集群的监控信息。

如果采购StarRocks企业版,则提供StarRocks Manager进行监控;

如果使用StarRocks区版Apache Doris、百度Palo,则需要采用开源Prometheus+Grafana监控方案。






0. ENV


1) 介质环境准备

    prometheus主程序:prometheus-2.27.1.linux-amd64.tar.gz
    prometheus主机监控程序:node_exporter-1.1.2.linux-amd64.tar.gz
    grafana主程序:grafana-7.5.7-1.x86_64.rpm
    已安装StarRocks版本:StarRocks 1.15.2


    2) 监控环境

      Prometheusgrafana服务器:192.168.80.30
      StarRocks服务器:sr01sr02sr03


      3) 端口使用情况

        prometheus  9090
        grafana 3000
        fe 8030
        be 8040



        1. Prometheus+Grafana监控方案


        未购买StarRocks企业版用户,需要自建监控告警系统,使用开源的Prometheus+Grafana方案。

        如果仅仅需要将监控数据接入自有的Prometheus系统,可以通过下列接口访问:

          FE:  fe_host:fe_http_port/metrics
          BE: be_host:be_web_server_port/metrics

          如果需要JSON格式可以访问:

            FE:  fe_host:fe_http_port/metrics?type=json
            BE: be_host:be_web_server_port/metrics?type=json

            本文只配置了对StarRocks监控,对StarRocks主机监控未配置,且未配置StarRocks告警。



            2. 安装prometheus


            1) 介质下载

            下载页面:

            https://prometheus.io/download/


            也可直接下载:

              wget https://github.com/prometheus/prometheus/releases/download/v2.27.1/prometheus-2.27.1.linux-amd64.tar.gz
              wget https://github.com/prometheus/node_exporter/releases/download/v1.1.2/node_exporter-1.1.2.linux-amd64.tar.gz


              2)安装GO语言

              prometheus及相关组件如node_exporter、mysqld_exporter都是GO语言开发,需要先安装golang。

                # wget -O etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
                # yum -y install go
                # go version
                go version go1.15.5 linux/amd64


                3) 安装prometheus

                 a. 二进制版,解压就能用

                  # tar zxvf prometheus-2.27.1.linux-amd64.tar.gz -C monitor/

                  b.创建软连接,便于管理

                    # ln -sv monitor/prometheus-2.27.1.linux-amd64/ /monitor/prometheus

                    c.创建prometheus用户和组

                      groupadd -g 3434 prometheus
                      useradd -u 3434 -g 3434 -s /sbin/nologin -M prometheus

                      d.创建prometheus数据目录

                        mkdir /monitor/prometheus/data
                        chown -R prometheus:prometheus /monitor/prometheus/data
                        chown -R prometheus:prometheus /monitor/prometheus

                        e.配置prometheus服务

                          vim /usr/lib/systemd/system/prometheus.service    #新建并添加如下内容


                          [Unit]
                          Description=prometheus
                          After=network.target
                          [Service]
                          Type=simple
                          User=prometheus
                          ExecStart=/monitor/prometheus/prometheus \
                          --config.file=/monitor/prometheus/prometheus.yml \
                          --storage.tsdb.path=/monitor/prometheus/data \
                          --storage.tsdb.retention=15d \
                          --web.read-timeout=5m \
                          --web.max-connections=10 \
                          --query.max-concurrency=20 \
                          --query.timeout=2m \
                          --web.enable-lifecycle \
                          --web.enable-admin-api
                          Restart=on-failure
                          [Install]
                          WantedBy=multi-user.target

                          f.参数解释

                            --config.file=/etc/prometheus/prometheus.yml       #prometheus配置文件
                            --storage.tsdb.path=/var/lib/prometheus #prometheus 存储数据路径
                            --storage.tsdb.retention=15d #prometheus采集数据保留时间
                            --web.read-timeout=5m #请求链接的最大等待时间          
                            --web.max-connections=10 #最大链接数
                            --query.max-concurrency=20 #最大支持的并发查询量
                            --query.timeout=2m #单个查询超时时间
                            --web.enable-lifecycle #热加载
                            --web.enable-admin-api #可以删除时序数据

                            g.启动prometheus

                              [root@monitor ~]# systemctl enable prometheus
                              [root@monitor ~]# systemctl start prometheus

                              h.查看端口已启用

                                [root@monitor ~]# netstat -anlptu | grep :9090

                                i.访问Prometheus的web界面

                                http://192.168.80.30:9090



                                3. 安装grafnana


                                1) 下载并安装

                                进入下载页面:

                                https://grafana.com/grafana/download

                                选择当前版本7.5.7,Open Source版本,系统选择Linux

                                  Red Hat, CentOS, RHEL, and Fedora(64 Bit)SHA256: 5e7649985bed0e4994f10b86c938bd1e895e394e39b58946dc08e2ff3573e89b
                                  # wget https://dl.grafana.com/oss/release/grafana-7.5.7-1.x86_64.rpm
                                  # yum -y install grafana-7.5.7-1.x86_64.rpm

                                  可以视需求更改grafana数据、插件路径,此处默认。


                                  2) 启动grafana服务

                                    [root@monitor soft]# systemctl enable grafana-server
                                    [root@monitor soft]# systemctl start grafana-server
                                    [root@monitor soft]# systemctl status grafana-server
                                    [root@monitor soft]# ss -antlp | grep 3000
                                    LISTEN 0 128 [::]:3000 [::]:* users:(("grafana-server",pid=24985,fd=8))


                                    3) 登录gra

                                    打开浏览器

                                      http://192.168.80.30:3000
                                      输入用户名和口令admin/admin => 首次登陆更改密码
                                      --  未完待续  --


                                      作者:王坤,微信公众号:rundba,欢迎转载,转载请注明出处。

                                      如需公众号转发,请联系wx:landnow。



                                      文章转载自rundba,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

                                      评论