• prometheus监控实战--基础


    1、简介

    prometheus就是监控系统+TSDB(时间序列数据库),通过pull方式从exporter获取时间序列数据,存入本地TSDB,被监控端需安装exporter作为http端点暴露指标数据

    prometheus server只提供一套内置查询语言PromQL,一个表达式浏览器和一个浏览数据的图形界面

    2、prometheus部署

    安装prometheus之前必须安装ntp时间同步,因为prometheus采集的T_S数据对系统时间的准确性要求

    2.1 二进制安装
    mkdir /application
    wget https://github.com/prometheus/prometheus/releases/download/v2.22.0/prometheus-2.22.0.linux-amd64.tar.gz
    tar xf prometheus-2.22.0.linux-amd64.tar.gz -C /application/
    cd /applicaiton &&mv prometheus-2.22.0.linux-amd64 prometheus
    
    2.2 配置
    cd /prometheus
    vim prometheus.yml
    # 全局配置
    global:
      scrape_interval:     15s             # 采集数据的时间间隔为15s(时间越短,存储压力越大)
      evaluation_interval: 15s             # 监控规则评估时间间隔(检查报警规则rule的间隔时间)
    
    # Alertmanager配置(prometheus的警报)
    alerting:	#服务器的警报配置
      alertmanagers:	#列出服务器使用的每个alertmanager
      - static_configs:
        - targets:
          # - alertmanager:9093
    
    # 规则设置(包含记录规则和警报规则)
    rule_files:
      # - "first_rules.yml"
      # - "second_rules.yml"
    
    # Prometheus 监控数据抓取配置
    scrape_configs:
      - job_name: 'prometheus'               # 定义job名称(分组)
        static_configs:                      #静态配置
        - targets: ['localhost:9090']        # exporters的主机和端口
          labels:                            #标签配置
              env: 'jd'                      #标签为键值对形式
    
    2.3、启动
    mkdir logs
    nohup /application/prometheus/prometheus --config.file=/application/prometheus/prometheus.yml >/application/prometheus/logs/prometheus.log 2>&1 &
    #nohup:启动后可关闭连接终端;&:后台运行
    

    启动相关参数

    --config.file= #指定配置文件

    --storage.tsdb.path=/prometheus #指定tsdb路径/ssd

    --storage.tsdb.retention.time=24h #指定数据存储时间

    --web.enable-lifecycle #提供类似nginx的reload功能,调用指令curl -X POST http://localhost:9090/-/reload

    --storage.tsdb.no-lockfile #如果用k8s的deployment管理要开启

    --web.listen-address=0.0.0.0:9090 #监听端口

    --web.read-timeout=5m #web读取超时时间

    --web.max-connnections=10 #web最大连接数

    --query.max-concurrency=20 #并发执行的最大查询数

    --query.timeout=2m #查询超时时间

    2.4、测试

    访问http://localhost:9090/metrics查看抓取的指标数据,prometheus默认通过自身9090端口进行自我监控

    转载请注明出处,谢谢!!!
  • 相关阅读:
    ipandao markdown mathjax版本
    我们是不是太关注于语法而忽略了算法
    SVGG.JS 入门教程
    关于ipandao编辑器手机访问换行问题
    启明星采购系统新版发布
    仿MSDN的帮助系统
    十分钟打造一款在线的数学公式编辑器
    Search Filter Syntax
    从华为养猪说起,聊聊我对中国计算机发展的一个遗憾-为何我们没有开发出自己的编程语言
    从.NET看微软的焦虑
  • 原文地址:https://www.cnblogs.com/haijunzhang/p/14034314.html
Copyright © 2020-2023  润新知