查看原文
其他

云原生爱好者周刊:揪出 Prometheus 中的时间戳抖动

KubeSphere 社区 KubeSphere云原生 2022-11-11

开源项目推荐

O11y toolkit[1]

O11y toolkit 是一个工具集,用来维护、调试和增强你的可观测性系统,改善我们日常对指标、日志和链路追踪的使用体验。例如 oy-scrape-jitter 就是用来解决 Prometheus 抓取的指标时间戳间隔不一致的问题。Prometheus 使用的是 delta-of-delta 编码[2]和时间戳 XOR 压缩技术,这就意味着当指标抓取的时间间隔完全一致时,一个时间戳存储到 TSDB 中只需占用一个比特(bit),可以大大节省磁盘的空间。虽然从理论上来说 Promtheus 每次抓取指标的间隔应该是一样的,但实际上会出现抖动的情况,抓取间隔并不是完全一致的,因此会浪费磁盘空间。oy-scrape-jitter 可以找出那些抓取间隔发生抖动的指标,例如:

$ ./oy-scrape-jitter --prometheus.url=https://prometheus.demo.do.prometheus.io/ --plot.file=jitter.png
level=info metric="up{env=\"demo\", instance=\"demo.do.prometheus.io:9093\", job=\"alertmanager\"}" aligned=239 unaligned=0 max_ms=0 pc=100.00%
level=info metric="up{env=\"demo\", instance=\"demo.do.prometheus.io:9100\", job=\"node\"}" aligned=233 unaligned=6 max_ms=23 pc=97.49%
level=info metric="up{instance=\"demo.do.prometheus.io:3000\", job=\"grafana\"}" aligned=237 unaligned=2 max_ms=14 pc=99.16%
level=info metric="up{instance=\"demo.do.prometheus.io:8996\", job=\"random\"}" aligned=179 unaligned=60 max_ms=2 pc=74.90%
level=info metric="up{instance=\"demo.do.prometheus.io:8997\", job=\"random\"}" aligned=239 unaligned=0 max_ms=0 pc=100.00%
level=info metric="up{instance=\"demo.do.prometheus.io:8998\", job=\"random\"}" aligned=237 unaligned=2 max_ms=3 pc=99.16%
level=info metric="up{instance=\"demo.do.prometheus.io:8999\", job=\"random\"}" aligned=237 unaligned=2 max_ms=4 pc=99.16%
level=info metric="up{instance=\"demo.do.prometheus.io:9090\", job=\"prometheus\"}" aligned=237 unaligned=2 max_ms=8 pc=99.16%
level=info metric="up{instance=\"http://localhost:9100\", job=\"blackbox\"}" aligned=233 unaligned=6 max_ms=2 pc=97.49%
level=info metric="up{instance=\"localhost:2019\", job=\"caddy\"}" aligned=239 unaligned=0 max_ms=0 pc=100.00%
level=info aligned_targets=3 unaligned_targets=7 max_ms=23

输出结果里有一条是这样的:

level=info metric="up{instance=\"demo.do.prometheus.io:8996\", job=\"random\"}" aligned=179 unaligned=60 max_ms=2 pc=74.90%

这表示指标 {instance="demo.do.prometheus.io:8996", job="random"} 有超过 25% 的样本抓取时间间隔不一致。

Korb[3]

Korb 可以用来在 Kubernetes 集群中将 PVC 迁移到不同的 StorageClasses 中。例如:

$ ./korb --new-pvc-storage-class ontap-ssd redis-data-redis-master-0
DEBU[0000] Created client from kubeconfig                component=migrator kubeconfig=/home/jens/.kube/config
DEBU[0000] Got current namespace                         component=migrator namespace=prod-beryju-org
DEBU[0000] Got Source PVC                                component=migrator name=redis-data-redis-master-0 uid=e4b5476f-b965-4e81-bfee-d7cbbf4f6317
DEBU[0000] No new Name given, using old name             component=migrator
DEBU[0000] Compatible Strategies:                        component=migrator
DEBU[0000] Copy the PVC to the new Storage class and with new size and a new name, delete the old PVC, and copy it back to the old name.  component=migrator
DEBU[0000] Only one compatible strategy, running         component=migrator
DEBU[0000] Set timeout from PVC size                     component=strategy strategy=copy-twice-name timeout=8m0s
WARN[0000] This strategy assumes you've stopped all pods accessing this data.  component=strategy strategy=copy-twice-name
DEBU[0000] creating temporary PVC                        component=strategy stage=1 strategy=copy-twice-name
DEBU[0002] starting mover job                            component=strategy stage=2 strategy=copy-twice-name
DEBU[0004] Pod not in correct state yet                  component=mover-job phase=Pending
DEBU[0006] Pod not in correct state yet                  component=mover-job phase=Pending
[...]
[mover logs]: sending incremental file list
[mover logs]: ./
[mover logs]: appendonly.aof
              0 100%    0.00kB/s    0:00:00 (xfr#1, to-chk=1/3)
[mover logs]: dump.rdb
            175 100%    0.00kB/s    0:00:00 (xfr#2, to-chk=0/3)
DEBU[0022] Cleaning up successful job                    component=mover-job
DEBU[0022] deleting original PVC                         component=strategy stage=3 strategy=copy-twice-name
DEBU[0024] creating final destination PVC                component=strategy stage=4 strategy=copy-twice-name
DEBU[0024] starting mover job to final PVC               component=strategy stage=5 strategy=copy-twice-name
DEBU[0026] Pod not in correct state yet                  component=mover-job phase=Pending
DEBU[0028] Pod not in correct state yet                  component=mover-job phase=Pending
[...]
[mover logs]: sending incremental file list
[mover logs]: ./
[mover logs]: appendonly.aof
              0 100%    0.00kB/s    0:00:00 (xfr#1, to-chk=1/3)
[mover logs]: dump.rdb
            175 100%    0.00kB/s    0:00:00 (xfr#2, to-chk=0/3)
DEBU[0048] Cleaning up successful job                    component=mover-job
DEBU[0048] deleting temporary PVC                        component=strategy stage=6 strategy=copy-twice-name
INFO[0050] And we'
re done                                component=strategy strategy=copy-twice-name
INFO[0050] Cleaning up...                                component=strategy strategy=copy-twice-name

websocat[4]

websocat 与 curl 类似,但专门为 Websockets 而设计,更便于测试 Websockets。例如:

A$ websocat -s 1234
Listening on ws://127.0.0.1:1234/
ABC
123

B$ websocat ws://127.0.0.1:1234/
ABC
123

《站点可靠性工作手册》中文版[5]

本书是 Google SRE 工作手册的续集,偏实践,这是本书的中文翻译。

文章推荐

👉快速上手 OpenFunction Node.js 异步函数服务开发

近日,“OpenFunction 顺利通过了云原生计算基金会 CNCF 技术监督委员会(TOC)的投票,正式进入 CNCF 沙箱(Sandbox)托管”。作为 OpenFunction 社区的一份子,非常期待能有更多开发者和合作伙伴参与到项目中来,共同建设和发展社区,“使 Serverless 函数与应用运行更简单”!同时,作为 Node.js 函数框架(Function Framework)目前的 Maintainer 之一,也想借此机会和大家分享一下 Node.js 函数框架最近的研发进展,特别是在 0.4.1 版本中已经实现的对于异步函数的支持。

本文将从以下几方面来介绍 Node.js 函数框架目前的研发进展和之后的工作展望。

👉国星宇航 SaaS 系统容器化最佳实践

国星宇航是一家 Al 卫星互联网科技公司,期望基于 K8s 搭建 PaaS 云计算基础平台,多租户管理使用资源,集成 CI/CD、支持灵活扩容与升级集群,构建企业级一站式 DevOps 架构,提高集群资源可监控性,可溯源操作审计。本文介绍了国星宇航如何使用 KubeSphere 来实现这个目标。

使用 Cilium Service Mesh 实现新一代的双向认证[6]

双向认证(Mutual Authentication)一直是安全的基石,我们日常使用的 SSH、mTLS 或 IPsec 等协议和技术都依赖于双向认证,云原生的世界也不例外,我们希望使用强大的双向认证来确保 Kubernetes 和整个云原生基础设施中服务之间的相互通信。

这篇文章研究了 Cilium 和 Cilium Service Mesh 是如何利用 eBPF 为服务提供一种新的基于身份的双向认证的方式,其高性能的数据平面可以支持任何网络协议,而不需要对应用程序进行更改,也无需注入 Sidecar。

云原生动态

存储容量跟踪在 Kubernetes 1.24 中达到通用标准[7]

Kubernetes 1.24 版本将存储容量跟踪作为一个普遍可用的功能。

存储容量跟踪允许 CSI 驱动发布关于剩余容量的信息。然后,当 Pod 具有仍需要配置的卷时,kube-scheduler 使用该信息为 Pod 选择合适的节点。

如果没有这些信息,Pod 可能会被卡住而无法被安排到合适的节点上,因为 kube-scheduler 不得不盲目选择而且最终总是选择一个无法配置卷的节点,因为由 CSI 驱动程序管理的底层存储系统确实如此没有足够的容量。

因为 CSI 驱动程序发布的存储容量信息在以后可能不再是最新的时候被使用,所以仍然可能会发生一个节点被选中而最终无法正常工作。卷配置通过通知调度程序它需要使用不同的节点重试来从中恢复。

👉KubeKey 2.1.0 发布,增强 K8s 离线交付体验

2022 年 5 月 6 日,KubeKey 2.1.0 正式发布,这是 KubeKey 的第 8 个正式版本。该版本增强了离线部署能力和交付体验,同时支持“一云多芯”,即同一个 K8s 集群中可以同时包含 ARM64 节点和 AMD64 节点。

KubeKey v2.1.0 不兼容 KubeKey v2.0.0 制作的制品,请使用 KubeKey v2.1.0 重新导出 KubeKey 制品。这是因为 KubeKey v2.1.0 优化了制品的存储结构。目前制品采用 OCI 标准对镜像进行拉取和归档保存,实现了复用基础镜像层,其存储空间占用可降低近一半。

Argo CD 发布 v2.4 RC 版本[8]

日前,Argo CD 发布了第一个 v2.4 候选版本。该版本有以下变化:

  • Argo CD 提供了一个 web 用户界面,作为一个超级强大的 Kubernetes 仪表板,帮助开发人员更好地了解他们的应用程序;
  • 引入了额外的访问控制设置,以控制对 Kubernetes Pod 日志和新的 Web 终端功能的访问;
  • v2.4 版本引入了 OpenTelemery 追踪集成,为 Argo CD 操作器(operator)提供了更多可见性;
  • 支持的架构列表已经扩展,现在包括 IBM Z(s390x)和 PowerPC(ppc64le)。从 v2.4 版本开始,官方 quay.io 仓库将提供 amd64、arm64、ppc64le 和 s390x 架构的镜像。

有关更多详细信息和安装说明,请查看发布说明[9]升级说明[10]

Docker 提供 Docker Extensions,适用于 Linux 的 Docker Desktop[11]

Docker 在其产品组合中添加了新产品,以帮助开发人员查找工具并将其添加到 Docker Desktop,并协助开发人员在基于 Linux 的系统上工作。

在 DockerCon 2022 虚拟会议上,Docker 宣布了 Docker Extensions 和适用于 Linux 的 Docker Desktop。由多个合作伙伴构建的 Docker 扩展可帮助开发人员免去安装、配置和管理新工具的繁琐工作。

为了提高开发人员的工作效率,Docker Desktop for Linux 预装了 Docker Compose、Docker CLI 和 Kubernetes 等工具,简化了该工具的安装和更新过程。

2022 年欧洲 KubeCon + CloudNativeCon 即将开启[12]

2022 年 5 月 16 日至 5 月 20 日,KubeCon + CloudNativeCon Europe 2022 将在西班牙的瓦伦西亚,线下+线上同步召开!

此次盛会,得到了国内外众多 IT 巨头的鼎力支持,汇聚了全球最活跃的开源云原生社区、最先进的技术代表以及最优秀的行业落地实践!

OpenFunction 的创始人霍秉杰将于北京时间 5 月 18 日 21:25-22:00 带来主题分享[13]:用云原生 Serverless 技术赋能自动驾驶。欢迎大家关注!

引用链接

[1]

O11y toolkit: https://github.com/o11ydev/oy-toolkit

[2]

delta-of-delta 编码: https://github.com/prometheus/prometheus/blob/main/tsdb/docs/bstream.md

[3]

Korb: https://github.com/BeryJu/korb

[4]

websocat: https://github.com/vi/websocat

[5]

《站点可靠性工作手册》中文版: https://github.com/redbearder/The-Site-Reliability-Workbook-CHS

[6]

使用 Cilium Service Mesh 实现新一代的双向认证: https://isovalent.com/blog/post/2022-05-03-servicemesh-security

[7]

存储容量跟踪在 Kubernetes 1.24 中达到通用标准: https://kubernetes.io/blog/2022/05/06/storage-capacity-ga/

[8]

Argo CD 发布 v2.4 RC 版本: https://blog.argoproj.io/argo-cd-v2-4-release-candidate-d1a0eef6b908

[9]

发布说明: https://github.com/argoproj/argo-cd/releases/tag/v2.4.0-rc1

[10]

升级说明: https://argo-cd.readthedocs.io/en/latest/operator-manual/upgrading/2.3-2.4/

[11]

Docker 提供 Docker Extensions,适用于 Linux 的 Docker Desktop: https://thenewstack.io/docker-delivers-docker-extensions-docker-desktop-for-linux/

[12]

2022 年欧洲 KubeCon + CloudNativeCon 即将开启: https://events.linuxfoundation.org/kubecon-cloudnativecon-europe/

[13]

主题分享: https://kccnceu2022.sched.com/event/ytmN/empower-autonomous-driving-with-cloud-native-serverless-technologies-benjamin-huo-qingcloud-technologies-xiuming-lu-uisee?iframe=no


国星宇航 SaaS 系统容器化最佳实践

2022-05-13

KubeKey 2.1.0 发布,增强 K8s 离线交付体验

2022-05-12

快速上手 OpenFunction Node.js 异步函数服务开发

2022-05-11




关于 KubeSphere

KubeSphere (https://kubesphere.io)是在 Kubernetes 之上构建的开源容器混合云,提供全栈的 IT 自动化运维的能力,简化企业的 DevOps 工作流。

KubeSphere 已被 Aqara 智能家居、爱立信、本来生活、东软、华云、新浪、三一重工、华夏银行、四川航空、国药集团、微众银行、杭州数跑科技、紫金保险、去哪儿网、中通、中国人民银行、中国银行、中国人保寿险、中国太平保险、中国移动、中国联通、中国电信、天翼云、中移金科、Radore、ZaloPay 等海内外数千家企业采用。KubeSphere 提供了开发者友好的向导式操作界面和丰富的企业级功能,包括 Kubernetes 多云与多集群管理、DevOps (CI/CD)、应用生命周期管理、边缘计算、微服务治理 (Service Mesh)、多租户管理、可观测性、存储与网络管理、GPU support 等功能,帮助企业快速构建一个强大和功能丰富的容器云平台。


 ✨ GitHub:https://github.com/kubesphere
 💻 官网(中国站):https://kubesphere.com.cn
 👨‍💻‍ 微信群:请搜索添加群助手微信号 kubesphere
 🔗 企业服务:https://kubesphere.cloud



您可能也对以下帖子感兴趣

文章有问题?点此查看未经处理的缓存