Prometheus 实战
  • 前言
  • 修订记录
  • 如何贡献
  • Prometheus 简介
    • Prometheus 是什么
    • 为什么选择 Prometheus
  • Prometheus 安装
    • 二进制包安装
    • Docker 安装
  • 基础概念
    • 数据模型
    • 指标类型
    • 作业与实例
  • PromQL
    • PromQL 基本使用
    • 与 SQL 对比
  • 数据可视化
    • Web Console
    • Grafana
    • Promlens
  • Prometheus 配置
    • 全局配置
    • 告警配置
    • 规则配置
    • 数据拉取配置
    • 远程可写存储
    • 远程可读存储
    • 服务发现
    • 配置样例
  • 服务发现
    • 静态服务发现
    • 文件服务发现
    • HTTP服务发现
    • Consul服务发现
    • moby服务发现
    • kubernetes服务发现
  • Exporter
    • 文本格式
    • Sample Exporter
    • Node Exporter 安装使用
    • Node Exporter 常用查询
    • 其他 Exporter 介绍
  • Pushgateway
    • Pushgateway 是什么
    • 如何使用 Pushgateway
  • 数据存储
    • Local Store
    • Remote Store
  • 告警/记录规则
    • 如何配置
    • 触发逻辑
  • Alertmanager
    • Alertmanager 是什么
    • 配置详情
    • 通过 Email 接收告警
    • 通过企业微信接收告警
    • 通过 Slack 接收告警
    • 通过 Webhook 接收告警
    • 其他告警接收方案
  • Prometheus 工具
    • Promtool 介绍和使用
    • Client SDK
  • Prometheus 性能调优
    • Metrics 仪表盘
    • 启动参数优化
    • 日志查询
  • Prometheus 与容器
    • Docker
    • Kubernetes
  • 高可用方案探讨
    • Prometheus Server 的高可靠
    • AlertManager 的高可靠
  • 实战练习
    • NodeExporter
    • 配置告警规则
    • Grafana 集成
    • Alertmanager 告警
  • 常见问题收录
    • 如何热加载新配置
    • 如何通过认证后拉取数据
Powered by GitBook
On this page

Was this helpful?

  1. Prometheus 配置

全局配置

global 属于全局的默认配置,它主要包含 4 个属性,

  • scrape_interval: 拉取 targets 的默认时间间隔。

  • scrape_timeout: 拉取一个 target 的超时时间。

  • evaluation_interval: 执行 rules 的时间间隔。

  • external_labels: 额外的属性,会添加到拉取的数据并存到数据库中。

其代码结构体定义为:

 // GlobalConfig configures values that are used across other configuration
// objects.
type GlobalConfig struct {
    // How frequently to scrape targets by default.
    ScrapeInterval model.Duration `yaml:"scrape_interval,omitempty"`
    // The default timeout when scraping targets.
    ScrapeTimeout model.Duration `yaml:"scrape_timeout,omitempty"`
    // How frequently to evaluate rules by default.
    EvaluationInterval model.Duration `yaml:"evaluation_interval,omitempty"`
    // The labels to add to any timeseries that this Prometheus instance scrapes.
    ExternalLabels model.LabelSet `yaml:"external_labels,omitempty"`

    // Catches all undefined fields and must be empty after parsing.
    XXX map[string]interface{} `yaml:",inline"`
}

配置文件结构大概为:

global:
  scrape_interval:     15s # By default, scrape targets every 15 seconds.
  evaluation_interval: 15s # By default, scrape targets every 15 seconds.
  scrape_timeout: 10s # is set to the global default (10s).

  # Attach these labels to any time series or alerts when communicating with
  # external systems (federation, remote storage, Alertmanager).
  external_labels:
    monitor: 'codelab-monitor'
PreviousPrometheus 配置Next告警配置

Last updated 4 years ago

Was this helpful?