首页
/ 3分钟搭建企业级监控!Apache Doris全链路可视化告警方案

3分钟搭建企业级监控!Apache Doris全链路可视化告警方案

2026-02-05 04:04:15作者:钟日瑜

你是否还在为Doris集群故障排查焦头烂额?当业务方投诉查询延迟时,是否只能盲目重启服务?本文将带你从零构建Prometheus+Grafana监控告警体系,实时掌握集群健康状态,提前预警潜在风险。

读完本文你将获得:

  • 3步完成监控组件部署
  • 核心指标可视化看板配置
  • 智能告警规则设置指南
  • 常见故障排查流程图解

监控架构总览

Apache Doris监控体系采用指标采集-存储-可视化-告警的经典架构,通过以下组件实现全链路可观测性:

graph TD
    A[Doris FE/BE节点] -->|暴露指标| B(Prometheus Exporter)
    B -->|拉取数据| C[Prometheus Server]
    C -->|存储时序数据| D[(TSDB)]
    C -->|查询接口| E[Grafana]
    E -->|可视化面板| F[业务监控大屏]
    C -->|告警规则| G[Alertmanager]
    G -->|通知渠道| H[Email/Slack/企业微信]

关键实现模块:

  • 指标暴露:fe/src/main/java/org/apache/doris/metric/
  • 采集配置:conf/prometheus.yml
  • 告警规则:conf/alert.rules.yml

环境准备与部署

前置条件检查

部署前请确认以下环境要求:

快速部署三件套

通过项目提供的Docker Compose一键部署Prometheus、Grafana和Alertmanager:

cd docker/runtime/doris-compose
docker-compose up -d prometheus grafana alertmanager

查看服务状态:

docker-compose ps

成功启动后可访问:

  • Prometheus:http://localhost:9090
  • Grafana:http://localhost:3000
  • Alertmanager:http://localhost:9093

核心指标采集配置

Doris指标暴露

修改FE和BE配置文件开启指标暴露功能:

  1. 配置FE:conf/fe.conf
# 启用Prometheus指标
enable_metric_prometheus = true
metric_prometheus_port = 8030
  1. 配置BE:conf/be.conf
# 启用Prometheus指标
enable_metric_prometheus = true
metric_prometheus_port = 8040
  1. 重启服务使配置生效:
sh bin/stop_fe.sh && sh bin/start_fe.sh --daemon
sh bin/stop_be.sh && sh bin/start_be.sh --daemon

Prometheus采集配置

创建Doris专用采集配置文件conf/prometheus/doris.yml:

scrape_configs:
  - job_name: 'doris_fe'
    static_configs:
      - targets: ['fe_host:8030']
        labels:
          cluster: 'prod-cluster'
          component: 'fe'
          
  - job_name: 'doris_be'
    static_configs:
      - targets: ['be_host1:8040', 'be_host2:8040']
        labels:
          cluster: 'prod-cluster'
          component: 'be'

在主配置中引用:

rule_files:
  - "alert.rules.yml"
  
scrape_configs:
  - import_configs:
      - "doris.yml"

可视化看板配置

Grafana数据源配置

  1. 登录Grafana后添加Prometheus数据源:

    • 名称:Doris-Prometheus
    • URL:http://prometheus:9090
    • 其余保持默认设置
  2. 导入Doris官方看板:

    • 导入ID:12892(Doris Cluster Monitor)
    • 选择已配置的Prometheus数据源

核心监控面板解析

FE核心指标看板

FE监控面板

关键指标区域:

BE性能监控看板

BE监控面板

重点关注:

智能告警规则设置

关键指标告警阈值

在conf/alert.rules.yml中配置核心告警规则:

groups:
- name: doris_fe_alerts
  rules:
  - alert: FEMemoryHigh
    expr: fe_jvm_memory_used_bytes / fe_jvm_memory_max_bytes > 0.8
    for: 5m
    labels:
      severity: warning
    annotations:
      summary: "FE内存使用率过高"
      description: "FE节点 {{ $labels.instance }} 内存使用率超过80% (当前值: {{ $value }})"

  - alert: QueryLatencyHigh
    expr: histogram_quantile(0.95, sum(rate(fe_query_duration_seconds_bucket[5m])) by (le)) > 10
    for: 3m
    labels:
      severity: critical
    annotations:
      summary: "查询延迟过高"
      description: "95%查询延迟超过10秒 (当前值: {{ $value }})"

告警渠道配置

配置Alertmanager发送告警到企业微信:conf/alertmanager.yml

route:
  receiver: 'wechat'
receivers:
- name: 'wechat'
  webhook_configs:
  - url: 'http://wechat-webhook:8080/send'

故障排查工作流

当收到告警时,可按照以下流程图进行故障定位:

graph LR
    A[收到告警] --> B{告警类型}
    B -->|FE高内存| C[检查慢查询]
    B -->|BE节点离线| D[查看心跳状态]
    B -->|查询失败率高| E[检查元数据一致性]
    C --> F[优化SQL或增加资源]
    D --> G[检查网络或重启BE]
    E --> H[执行元数据修复工具]

常用诊断工具:

部署验证与最佳实践

监控有效性验证

执行以下命令生成测试负载,验证监控指标是否正常采集:

# 运行压力测试脚本
cd regression-test/script
sh run_tpch.sh --scale 10

在Grafana中观察指标变化,确认QPS、延迟等指标是否实时更新。

生产环境优化建议

  1. 指标采集优化:

    • 调整采集间隔:conf/prometheus.yml
    • 增加样本保留时间:--storage.tsdb.retention.time=30d
  2. 高可用配置:

    • Prometheus联邦集群:docs/federation.md
    • Grafana多组织隔离:conf/grafana.ini
  3. 安全加固:

    • 启用HTTPS:conf/ssl/
    • 配置RBAC权限:docs/rbac.md

总结与进阶学习

通过本文介绍的Prometheus+Grafana监控方案,你已经掌握了Apache Doris集群的全方位监控能力。建议进一步学习:

  • 自定义指标开发:fe-plugins/sparksql-converter/
  • 分布式追踪集成:be/src/runtime/trace.cpp
  • 监控数据持久化:docs/monitoring/long_term_storage.md

完整监控方案代码示例可参考:samples/monitoring/

立即部署监控体系,让你的Doris集群运维从此化被动为主动!

登录后查看全文
热门项目推荐
相关项目推荐