test

发布时间 2023-06-07 19:51:19作者: france水
  • 服务或者应用部署在服务器上,prometheus对服务器进行数据采集,通过Grafana展示前端效果,告警信息通过其他组件发送给接收人

  • 特点

    • 核心部分仅为二进制文件,只需要一个磁盘
    • 主动拉取信息
    • 服务发现动态监管
    • 数据处理高效
    • 内置数据查询
  • 架构

    • 存储计算
      • prometheus server层
      • tsdb数据存储
      • retrieval拉取数据,取数组件
      • Service discovery,可以动态发现要监控的目标
    • 采集
      • 短作业:直接通过 API,在退出时间指标推送给 Pushgateway。
      • 长作业:Retrieval 组件直接从 Job 或者 Exporter 拉取数据。
    • 应用
      • AlertManage付费报警系统
      • Grafana可视化
  • 启动

    • ./prometheus --config.file=prometheus.yml > ./prometheus.log 2>&1 &
    • ./node_exporter
    • ./pushgateway --web.listen-address :9091 > ./pushgateway.log 2>&1 &
    • ./alertmanager --config.file=alertmanager.yml > ./alertmanager.log 2>&1 &
    • ./bin/grafana-server web > ./grafana.log 2>&1 &
  • promql

    • 直接查询瞬时向量
      • node_netstat_Tcp_RetransSegs{job="node exporter"}
    • 区间向量
      • node_netstat_Tcp_RetransSegs{job="node exporte"}[5h]
    • 位移
      • node_netstat_Tcp_RetransSegs{job="node exporter"} offset 1d
    • 聚合操作
      • sum (node_netstat_Tcp_RetransSegs{job="node exporter"})
  • grafana

    • 手动创建仪表盘
      • 选择数据源
      • 添加查询条件
    • 导入仪表盘
      • 在grafana下载dashboard仪表盘导入
  • 脚本

    • #!/bin/bash
      case $1 in
      "start"){
       echo '----- 启动 prometheus -----'
       nohup /opt/module/prometheus-2.29.1/prometheus --web.enable-admin-api
      --config.file=/opt/module/prometheus-2.29.1/prometheus.yml > 
      /opt/module/prometheus-2.29.1/prometheus.log 2>&1 &
       echo '----- 启动 pushgateway -----'
       nohup /opt/module/pushgateway-1.4.1/pushgateway --web.listen-address :9091 > 
      /opt/module/pushgateway-1.4.1/pushgateway.log 2>&1 &
       echo '----- 启动 grafana -----'
       nohup /opt/module/grafana-8.1.2/bin/grafana-server --homepath 
      /opt/module/grafana-8.1.2 web > /opt/module/grafana-8.1.2/grafana.log 2>&1 &
      };;
      "stop"){
       echo '----- 停止 grafana -----'
       pgrep -f grafana | xargs kill
       echo '----- 停止 pushgateway -----'
       pgrep -f pushgateway | xargs kill
       echo '----- 停止 prometheus -----'
       pgrep -f prometheus | xargs kill
      };;
      esac
      
      chmod +x flink-monitor.sh