惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

ike‘s blog

mac软件推荐 用Siri来控制Windows电脑开机关机吧 clickhouse的一些优化建议和工具 2023sumppary 记录一下我的第一个网页游戏Mazeball 如何使用Clickhouse的索引 如何从zookeeper切换为clickhouse—keeper cloki分布式查询和clickhouse副本存储 使用ilogtail+cloki+clickhouse来做日志系统吧 clickhouse集群部署指南 快速安装部署clickhouse和cloki 如何使用go的jwt 如何修改git commit记录 业务容器化需要注意的一些地方 游戏企划 Prometheus Metrics精简优化2 来在线听音乐吧 Chatgpt的API入门 简单搭建国内也可以使用的chatgpt Prometheus Metrics精简优化 Kubernetes的探针机制 本地部署chatAI【chatglm】 AI绘画工具webui简单入门 之 高清化 写在地下城邂逅Ⅳ·灾厄篇·完结之后 如何部署gitalk作为评论系统 AI绘画工具webui简单入门 之 工具安装 grafanadb迁移到mysql kubectl常用命令 开始写博客啦 隐私政策URL Markdown Example Include Video in the Posts Markdown Extended Features Simple Guides for Fuwari Golang net/http & HTTP Serve 源码分析
快速部署thanos架构
2023-07-21 · via ike‘s blog

介绍#

Thanos 是一个用于扩展 Prometheus 的开源项目,通过将多个 Prometheus 实例和其他数据源组合在一起,实现了跨多个集群和地理位置的高可用性、长期存储和查询功能。Thanos 架构可以被描述为以下四个组件:

  • Prometheus:Thanos 使用 Prometheus 作为数据源,用于收集、存储和查询监控数据。Prometheus 是一个功能强大的开源监控系统,可以监控各种应用程序、服务和网络基础设施。
  • Thanos Sidecar:Thanos Sidecar 是一个负责将 Prometheus 数据推送到远程存储桶的代理。它可以将 Prometheus 实例的数据集成到 Thanos 系统中,通过使用 Thanos Store API,使得 Prometheus 实例的数据在 Thanos 中可查询。
  • Thanos Store Gateway:Thanos Store Gateway 是一个用于跨多个 Prometheus 实例聚合、存储和查询数据的组件。它可以将 Prometheus 实例和远程存储桶中的数据作为一个整体进行查询,提供了一个统一的数据视图。
  • Thanos Query:Thanos Query 是一个用于查询 Thanos Store Gateway 中存储的数据的组件。它提供了一个类似于 Prometheus 的查询语言,并能够跨多个 Prometheus 实例和存储桶进行查询,以提供全局的监控数据视图。

通过以上四个组件的协作,Thanos 架构实现了扩展性和高可用性,能够有效地存储和查询大量的监控数据。Thanos 还提供了许多其他的功能,例如数据压缩、数据分片、数据去重、数据合并等,可以进一步提高数据存储和查询的效率。

ps:thanos的receive模式这里就先不讲了,有兴趣的可以百度或者官网查看

前因#

网上检索thanos大部分是简介或者架构啥的,部署也都是容器部署,不够简单上手,其实基础的thanos架构搭建很容易。

安装#

github地址
下载后直接放到linux目录下就好了,每个prometheus节点都要部署一个!

部署#

先直接上service文件: thanos-query.service

[Unit]
Description=Thanos Query
After=network-online.target

[Service]
Restart=on-failure
# --query.replica-label "replica" --query.replica-label "datacenter" --> 加上后,thanos query 查询同一节点的数据时,会自动去重
ExecStart=/opt/thanos/thanos query --http-address 0.0.0.0:19192 --grpc-address=0.0.0.0:11901 --store=10.0.0.1:19090,10.0.0.2:19090

[Install]
WantedBy=multi-user.target

thanos-sidecar.service

[Unit]
Description=Thanos Sidecar
After=network-online.target

[Service]
Restart=on-failure
# --prometheus.url 配置对应的prometheus 地址
# --tsdb.path 配置对应的prometheus 数据目录
ExecStart=/opt/thanos/thanos sidecar --prometheus.url=http://localhost:9090 --tsdb.path=/data/prometheus-data --grpc-address=0.0.0.0:19090 --http-address=0.0.0.0:19091

[Install]
WantedBy=multi-user.target

步骤#

service文件和thanos文件都放好后,只需要 1、修改prometheus的配置新增额外标签:

global:
  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.
  external_labels:
        datacenter: prometheus-02  #额外标签
rule_files:
   - "rules/*.yaml"
···下面配置省略···

2、在prometheus节点上都启动sidecar的服务。
3、在thanos节点上启动query的服务。
4、确认服务都正常启动完毕。

完毕!然后就可以访问thanos的http://10.0.0.1:19192 就可以访问thanos页面啦,点击Stores就可以看到有几个thanos节点正常连接了。

后续#

如果你单个prometheus太大了,也可以使用thanos的架构来进行水平分片,把job_name多分几个,降低单个prometheus负载。 如果还是会超时或者负载严重,可以换成receive模式,相当于prometheus把数据直接远程写入到thanos,然后thanos直接从本地数据里进行指标拉取。