再多学一点吧

导航

Prometheus监控

1、Prometheus基本架构

2、Prometheus安装

主要安装Prometheus Service(核心服务)和Pushgateway(对数据做采集可以是flink)

1、Prometheus下的文件


修改Prometheus的配置文件

2、Pushgateway下的文件

3、Node Exporter(可选)

在 Prometheus 的架构设计中,Prometheus Server主要负责数据的收集,存储并且对外提供数据查询支持,而实际的监控样本数据的收集则是由 Exporter 完成。
启动命令

启动之后便可以通过地址:ip:9090/metrics 直接查到采集的服务器数据

4、Alertmanager(可选)

Alertmanger用于做告警信息

5、网页查询

IP:9090/targets

3、查询语言:PromQL

1、直接使用监控指标名称查询时,可以查询该指标下的所有时间序列

2、以当前时间为标准,查询最近 5 分钟内的所有样本数据:
prometheus_http_requests_total{}[5m]
3、位移操作offset
prometheus_http_requests_total{} offset 5m
prometheus_http_requests_total{}[1d] offset 1d
4、PromQL的聚合操作(sum,max等等)

4、Prometheus和Flink的集成

Flink提供的Metrics可以在Flink内部收集一些指标,通过这些指标可以通过Pushgateway传输到Prometheus上进行查看

具体实现

5、Prometheus和Grafana集成

安装启动Grafana
常用仪表盘Dashboard地址:https://grafana.com/dashboards
创建组件启动停止脚本

#!/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

posted on 2022-02-21 13:57  糟糟张  阅读(525)  评论(0编辑  收藏  举报