618年中限时 5折! 详情

hyperf 必威手机app监控之Prometheus+Grafana项目必威app精装版下载

2191 0 1

阅读目录

  • Prometheus
  • 什么是 Prometheus ?
  • docker 安装 Prometheus
  • 配置 Prometheus
  • hypef 集成 Prometheus
  • 集成 Grafana
  • docker 安装 Grafana
  • 启动 Grafana
  • Grafana 配置 Prometheus 数据源
  • 导入官方提供的 Grafana 指标
  • 自定义统计指标
  • 必威手机app上线之后,我们需要清楚的知道各个必威手机app的健康状态、必威手机app器资源使用情况、慢查询、业务埋点数据等等。通过监控了解各个盲区,进一步优化系统。

    业内常见的解决方案就是我们今天要介绍的主题 Prometheus 和 Grafana,这是一对绝佳CP。

    那什么是 Prometheus 和 Grafana 呢?

    Prometheus(普罗米修斯) 是由 SoundCloud 开发的开源监控报警系统和时序列数据库(TSDB),Prometheus 使用 Go 语言开发,是 Google BorgMon 监控系统的开源版本。

    Grafana 是一个跨平台的开源的度量分析和可视化工具,可以通过将采集的数据查询然后可视化的展示,并及时通知。

    简单来说,Prometheus 是时间序列数据库,它提供数据指标,Grafana 负责对这些数据指标进行可视化展示。

    这里不会对他们进行过多详细的介绍,你只需要了解 Prometheus 是时序数据库,Grafana 是可视化工具即可。

    docker 安装 Prometheus

    docker pull prom/prometheus
    

    配置 Prometheus

    新建配置文件 prometheus.yml 如下:

    # 全局配置
    global:
      # 每15秒向目标采样点拉取数据
      scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
      evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
      # scrape_timeout is set to the global default (10s).
    # Alertmanager configuration
    # 告警管理器(Alertmanager)的配置
    alerting:
      alertmanagers:
      - static_configs:
        - targets:
          # - alertmanager:9093
    # Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
    # 告警规则有哪些
    rule_files:
      # - "first_rules.yml"
      # - "second_rules.yml"
    # A scrape configuration containing exactly one endpoint to scrape:
    # Here it's Prometheus itself.
    # 抓取监控信息的目标,一个job_name就是一个目标
    scrape_configs:
      # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
      - job_name: 'prometheus'
        # metrics_path defaults to '/metrics'
        # scheme defaults to 'http'.
        static_configs:
        - targets: ['192.168.72.80:9091']
      - job_name: 'hyperf'
        # 默认路由是 /metrics
        static_configs:
        - targets: ['192.168.72.80:9503']
      - job_name: 'grafana'
        static_configs:
        - targets: ['192.168.72.80:3000']
    

    Prometheus 的配置分为四部分,分别是 global 全局配置、alerting

    继续阅读

    还有75%的精彩内容,购买继续阅读