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'

相关推荐
A心有千千结4 天前
Nginx网关可观测建设:打通流量入口,加速线上故障诊断
nginx·prometheus·devops
天天喝旺仔4 天前
Prometheus + Grafana 监控告警体系搭建实战:从 Exporter 指标采集、PromQL 查询到 Alertmanager 告警落地
容器·kubernetes·grafana·prometheus·时序数据库
川石课堂软件测试8 天前
涨薪技术|Prometheus之HTTP API中使用PromQL
网络协议·测试工具·jmeter·http·单元测试·postman·prometheus
IT界的老黄牛10 天前
Prometheus TSDB 拆不出来、也存不了一年:4 条外部存储出路 + 容量测算
prometheus·时序数据库·监控·thanos·victoriametrics·remote_write
Ningcode_cloud10 天前
Kubernetes 弹性伸缩实验手册:从集群搭建到 HPA / VPA 自动扩缩容
云原生·k8s·prometheus
2601_9620973611 天前
可观测性实战:Prometheus+Grafana+OTel构建监控
grafana·prometheus·微服务架构·可观测性·opentelemetry
IT界的老黄牛11 天前
Jenkins 监控一条龙:接入、看板 9964、11 条告警规则直接抄走
jenkins·grafana·prometheus·监控·ci-cd·告警规则
陈皮糖..12 天前
基于 Keepalived 的传统 Web 高可用架构的容器化改造与可观测性升级
运维·docker·性能优化·架构·云计算·prometheus
heimeiyingwang12 天前
【Prometheus·部署篇】存储与容量规划:本地存储、远程存储与长期保存
prometheus