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

推荐订阅源

酷 壳 – 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

博客园 - 乔闻

关于NVIDIA-geforce 1650和tesla-P4系列显卡,共用一个驱动的办法。其他型号一样。 记一次安装nvidia-container-runtme后,作为containerd默认的runtime,k8s节点挂掉的问题。 Docker Swarm Keepalived Operator:高可用集群虚拟 IP 管理方案 scheduler报错: Failed to watch *v1beta1.PodDisruptionBudget: failed to list *v1beta1.PodDisruptionBudget, no kind "KubeSchedulerConfiguration" is registered for version "componentconfig/v1alpha1" EOS:dfuse stream 保证不会错过一个心跳 ubuntu18.04安装时ACPI error 无法进入系统的问题 Supervisor-类unix系统下的进程控制工具 windows10 自带的OpenSSH Client(Beta) windows10 易升 下载失败 解决方法 Visual Studio for Mac 安装时无法连接到网络等问题 用VsCode编辑TypeScript OWIN是什么? Dapper 实例字段与静态字段区别 ref - 按引用传递参数 TweenMax 前台脚本库 如何使用CSS Sprites技术进行图片合并 QQ群开放接口 使用 Hexo 生成一套静态博客网页
介绍一个prometheus监控数据生成工具
乔闻 · 2024-01-10 · via 博客园 - 乔闻

prometheus-data-generator

Prometheus数据模拟工具旨在通过配置文件模拟Prometheus数据,用于测试和开发目的。该工具允许您生成用于测试和开发的合成数据。

配置

工具的配置信息存储在一个YAML文件中。以下部分描述了可用的选项:

template_dir: ./templates
output_dir: ./output
template_value_dir: ./template_values

global_config:
  template_value_path: ./template_values_without_unix.json
  days: 1
  resolution_seconds: 15
  endtime_unix: 1698048047

template_without_unix_configs:
  - name: nvidia_gpu_exporter
    template_value_path: gpu_node_2.json

template_with_unix_configs:
  - name: nvidia_gpu_exporter_with_unix
    template_value_path: samples_gpu_node_1.json

全局配置

全局配置部分包含适用于所有模板的设置,这些设置在global_config键下指定。可用的选项有:

  • template_value_path: 包含模板值的JSON文件的路径。默认情况下,工具在template_values目录中查找此文件。
  • days: 生成数据的天数。默认值为30。
  • resolution_seconds: 生成数据的分辨率(秒)。默认值为15。
  • endtime_unix: 生成数据的结束时间的Unix时间戳。默认值为1698048047。

模板配置

模板配置定义了各个模板及其特定设置。有两种类型的模板配置:

  • 无Unix时间戳的模板
    在template_without_unix_configs键下定义无Unix时间戳的模板配置。每个模板配置包括以下选项:

    • name: 模板的名称。
    • template_value_path: 包含此模板特定模板值的JSON文件的路径。默认情况下,工具在template_values目录中查找此文件。
  • 带Unix时间戳的模板
    在template_with_unix_configs键下定义带Unix时间戳的模板配置。每个模板配置包括以下选项:

    • name: 模板的名称。
    • template_value_path: 包含此模板特定模板值的JSON文件的路径。默认情况下,工具在template_values目录中查找此文件。

模板格式

格式为golang的text/template格式,具体模板参考 https://github.com/gmodx/prometheus-data-generator/tree/main/templates

{{ range t := .Timestamps }}{{ range .Items -}}
DCGM_FI_DEV_FB_FREE{instance="{{.IP}}:9400",gpu="{{.Index}}",UUID="{{.ID}}",device="{{.Vendor}}",modelName="{{.Model}}",Hostname="{{.IP}}"} {{ .RandomInt 501 10000 }} {{t}}
DCGM_FI_DEV_FB_USED{instance="{{.IP}}:9400",gpu="{{.Index}}",UUID="{{.ID}}",device="{{.Vendor}}",modelName="{{.Model}}",Hostname="{{.IP}}"} {{ .RandomInt 1 500 }} {{t}}
DCGM_FI_DEV_GPU_UTIL{instance="{{.IP}}:9400",gpu="{{.Index}}",UUID="{{.ID}}",device="{{.Vendor}}",modelName="{{.Model}}",Hostname="{{.IP}}"} {{ .RandomInt 1 100 }} {{t}}
DCGM_FI_DEV_POWER_USAGE{instance="{{.IP}}:9400",gpu="{{.Index}}",UUID="{{.ID}}",device="{{.Vendor}}",modelName="{{.Model}}",Hostname="{{.IP}}"} {{ .RandomInt 1 500 }} {{t}}
{{ end -}}{{ end -}}

使用

./prometheus-data-generator --config.file=config.yaml
Dec  1 03:46:22.488 nvidia_gpu_exporter, 2023-10-22T08:00:47Z -> 2023-10-23T08:00:47Z, step: 15s
Dec  1 03:46:22.488 progress: 0%, 2023-10-22T08:00:47Z -> 2023-10-22T10:00:00Z
Dec  1 03:46:22.488 process template...
Dec  1 03:46:22.722 create blocks...
BLOCK ULID                  MIN TIME                       MAX TIME                       DURATION     NUM SAMPLES  NUM CHUNKS   NUM SERIES   SIZE
01HGHQR4GFSFXM8Q5SSNW7Y1RJ  2023-10-22 08:00:47 +0000 UTC  2023-10-22 09:59:47 +0000 UTC  1h59m0.001s  30528        256          64           72KiB840B
Dec  1 03:46:22.950 progress: 8%, 2023-10-22T10:00:00Z -> 2023-10-22T12:00:00Z
Dec  1 03:46:22.950 process template...
Dec  1 03:46:23.118 create blocks...

文件下载

https://github.com/gmodx/prometheus-data-generator/releases/tag/v1.0.1

源码

https://github.com/gmodx/prometheus-data-generator