prometheus时序数据库

时序数据库理论部分,参考时序数据库_vm时序数据库-CSDN博客

时序数据库一般采取拉的方式,在配置文件中配置每个采集任务的url地址,采集周期,然后周期到每个采集节点去http get数据。

需要先启动一个exporter(即上报器,其实是个http服务,等待prometheus或其它时序数据库周期拉取数据)

1、下载node_exporter-1.11.1.linux-amd64,解压后执行node_exporter

2、可以看到这个node_exporter的端口是9100

time=2026-09-19T19:29:14.811+08:00 level=INFO source=tls_config.go:354 msg="Listening on" address=:::9100

time=2026-09-19T19:29:14.811+08:00 level=INFO source=tls_config.go:357 msg="TLS is disabled." http2=false address=:::9100

3、在浏览器中输入http://localhost:9100/metrics,可以看到上报了很多测量指标,如下是node_cpu_seconds_total这个指标,标签是cpu和mode,值是最后一列

复制代码
# HELP node_cpu_seconds_total Seconds the CPUs spent in each mode.
# TYPE node_cpu_seconds_total counter
node_cpu_seconds_total{cpu="0",mode="idle"} 5.07908674e+06
node_cpu_seconds_total{cpu="0",mode="iowait"} 969.37
node_cpu_seconds_total{cpu="0",mode="irq"} 32883.31
node_cpu_seconds_total{cpu="0",mode="nice"} 7.24
node_cpu_seconds_total{cpu="0",mode="softirq"} 20080.27
node_cpu_seconds_total{cpu="0",mode="steal"} 5129.01
node_cpu_seconds_total{cpu="0",mode="system"} 424382.12
node_cpu_seconds_total{cpu="0",mode="user"} 572838.97
node_cpu_seconds_total{cpu="1",mode="idle"} 5.12986934e+06
node_cpu_seconds_total{cpu="1",mode="iowait"} 734.44
node_cpu_seconds_total{cpu="1",mode="irq"} 30868.19
node_cpu_seconds_total{cpu="1",mode="nice"} 6.8
node_cpu_seconds_total{cpu="1",mode="softirq"} 22270.78
node_cpu_seconds_total{cpu="1",mode="steal"} 5002.12
node_cpu_seconds_total{cpu="1",mode="system"} 419887.83
node_cpu_seconds_total{cpu="1",mode="user"} 534317.43
node_cpu_seconds_total{cpu="2",mode="idle"} 5.0708136e+06
node_cpu_seconds_total{cpu="2",mode="iowait"} 911.12
node_cpu_seconds_total{cpu="2",mode="irq"} 34315.67
node_cpu_seconds_total{cpu="2",mode="nice"} 6.49
node_cpu_seconds_total{cpu="2",mode="softirq"} 19021.82
node_cpu_seconds_total{cpu="2",mode="steal"} 5081.08
node_cpu_seconds_total{cpu="2",mode="system"} 428523.02
node_cpu_seconds_total{cpu="2",mode="user"} 575346.52

然后下载解压prometheus-3.11.3.linux-386,

1、在prometheus.yml中配置这个exporter

javascript 复制代码
global:
  scrape_interval: 15s

scrape_configs:
  # 已有的 Prometheus 自身监控任务
  - job_name: 'prometheus'
    static_configs:
      - targets: ['localhost:9090']

  # 新增:Node Exporter 监控任务
  - job_name: 'node'
    static_configs:
      - targets: ['localhost:9100']
        labels:
          instance: 'my-server'

2、启动prometheus

3、打开http://127.0.0.1:9090/

点击 Status->Target Health可以看到这个采集点的URL和状态。

3.1 在查询页面可以输入PromQL查询条件,

比如直接输入指标名称node_cpu_seconds_total

或者node_cpu_seconds_total{cpu="2",mode="user"} ,

或者5分钟内的数据node_cpu_seconds_total{cpu="2",mode="user"}5m

3.2 也可以调用http接口查询,比如

curl -G 'http://localhost:9090/api/v1/query' --data-urlencode 'query=node_cpu_seconds_total{cpu="0",mode="idle"}5m'

相关推荐
Duang007_1 天前
生产可观测性:从“系统慢“到“根因“的完整链路(Go / TypeScript)
后端·python·golang·typescript·prometheus
JWASX1 天前
go 学习 - prometheus 指标学习
学习·golang·prometheus
JWASX1 天前
go 学习 - prometheus 指标协程池监控
学习·golang·prometheus
爱琴孩3 天前
记一次Prometheus的WAL异常,导致服务器磁盘占用过高
prometheus·wal
Cheney Pan4 天前
第12篇 Prometheus 高可用与长期存储
prometheus
飞鸟真人4 天前
应用性能监测(APM)之 (五)Prometheus与OpenMetrics协议
prometheus·apm·open telemetry·openmetrics
Cheney Pan4 天前
第13篇 监控安全与权限治理
安全·prometheus
蓝胖的四次元口袋6 天前
Prometheus+Grafana知识梳理(2)
grafana·prometheus
Cheney Pan7 天前
第8篇 关键指标分析方法:RED/USE 与黄金信号
prometheus
Cheney Pan8 天前
第7篇 业务数据监控:SQL Exporter 与自定义业务指标
prometheus·exporter