tencent cloud

Prometheus 监控服务

产品简介
产品概述
产品优势
应用场景
基本概念
相关限制
功能特性
开服地域
购买指南
计费概述
按量付费(后付费)
免费试用介绍
托管采集器付费介绍
归档存储付费介绍
购买方式
欠费说明
快速入门
接入指南
抓取配置说明
自定义监控
EMR 接入
Java 应用接入
Golang 应用接入
Exporters 接入
Nacos 接入
通用组件监控
健康巡检
TKE 集群内安装组件说明
云监控
非腾讯云主机监控
通过 Remote Read 读取云托管 Prometheus 实例数据
Agent 自助接入
Pushgateway 接入
安全组开放说明
操作指南
实例
容器监控
集成中心
数据多写
预聚合
实例诊断
归档存储
告警策略
标签管理
访问控制
Grafana
API 使用指南
容器服务指标
相关资源使用及计费说明
实践教程
自建 Prometheus 迁入
云服务器场景下自定义接入
容器场景监控
TKE Serverless 集群如何放通外网
Prometheus 监控服务如何接入本地 Grafana
Prometheus 实例访问公网
配置 Prometheus 公网地址
Terraform
Terraform 概述
使用 Terraform 管理 Prometheus 实例
使用 Terraform 管理 Prometheus 实例的集成中心
使用 Terraform 采集容器监控数据
使用 Terraform 配置告警策略
常见问题
基础问题
集成容器服务相关
产品咨询
使用&技术问题
云监控问题
服务等级协议
TMP 政策
TMP 隐私协议
TMP 数据处理和安全协议
文档Prometheus 监控服务接入指南通过 Remote Read 读取云托管 Prometheus 实例数据

通过 Remote Read 读取云托管 Prometheus 实例数据

PDF
聚焦模式
字号
最后更新时间: 2024-01-29 15:55:14

操作场景

Prometheus 提供了 Remote read 接口,该接口支持将一系列 Prometheus 协议的数据源组织为单一数据源查询。本文介绍如何使用自建 Prometheus 通过 Remote read 读取云托管 Prometheus 实例的数据。

Remote Read 配置

推荐配置 prometheus.yml如下:
remote_read:
- url: 'http://prom_ip:prom_port/api/v1/read'
read_recent: true
basic_auth:
username: app_id
password: token
推荐使用 Basic Auth 方式访问云托管 Prometheus 实例,username 为账号 AppID ,password 为 Prometheus 控制台 > 基本信息 > 服务地址中获取的 Token。




注意事项

配置 Remote read 的 Prometheus 需谨慎配置 global:external_labels: external_labels 会被附加在 Remote read 的查询条件中,不正确的 label 可能导致查询不到需要的数据。 filter_external_labels: false 配置项可以避免将 external_labels 加入查询条件(v2.34 版本以上支持)。
避免出现相同的 series: 对于完全相同的两个 series,Prometheus 会在查询合并时在每个时间点在随机一个 series 取值组成新的 series 作为查询结果,这会导致查询结果不准确。 在 Prometheus 的设计理念中不存在多副本冗余存储的情况,所以不会对这种场景提供支持。

Remote read 完整配置项

说明:
[]中的配置项为可选项(本文展示 Prometheus:v2.40 版本配置,低版本可能缺少部分配置项,详见 prometheus 官方文档
# remote read 目标 prometheus 实例的 api 地址
url: <string>

# 标识一个唯一的 remote read 配置名称
[ name: <string> ]

# 查询 promql 中必须包含以下 label 过滤条件才会进行 remote read 查询
required_matchers:
[ <labelname>: <labelvalue> ... ]

# remote read 查询超时时间
[ remote_timeout: <duration> | default = 1m ]

# 自定义 remote read 请求中附带的 headers,无法覆盖 prometheus 原本添加的 headers
headers:
[ <string>: <string> ... ]

# 在本地有完整数据存储的时间范围是否进行 remote read 查询
[ read_recent: <boolean> | default = false ]

# 为每个 remote read 请求添加 Authorization header,password password_file 二选一
basic_auth:
[ username: <string> ]
[ password: <secret> ]
[ password_file: <string> ]

# 自定义 Authorization header 配置
authorization:
# 认证类型
[ type: <string> | default: Bearer ]
# 认证密钥,credentials credentials_file 二选一
[ credentials: <secret> ]
# 密钥从文件中获取
[ credentials_file: <filename> ]

# OAuth2.0认证,不能与 basic_auth authorization 同时使用
oauth2:
[ <oauth2> ]

# TLS 配置
tls_config:
[ <tls_config> ]

# 代理 URL
[ proxy_url: <string> ]

# 查询请求是否接受3XX 跳转
[ follow_redirects: <boolean> | default = true ]

# 是否启用 HTTP2
[ enable_http2: <bool> | default: true ]

# 是否在 remote read 时附加 external_labels
[ filter_external_labels: <boolean> | default = true ]


帮助和支持

本页内容是否解决了您的问题?

填写满意度调查问卷,共创更好文档体验。

文档反馈