【发布时间】:2021-09-18 10:55:43
【问题描述】:
我一直在与 Prometheus 和 Grafana 合作,我试图将它们整合在一起。我目前的问题是我的节点导出器当前正在重定向到我能够做到的端口 9100:
然而,这只是总结了整个计算机的状态,但我想做的是我想获得每个目标的 RAM 使用情况:
# Sample config for Prometheus.
global:
scrape_interval: 1s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 1s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
# Attach these labels to any time series or alerts when communicating with
# external systems (federation, remote storage, Alertmanager).
external_labels:
monitor: 'example'
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets: ['localhost:9093']
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
- job_name: node
# If prometheus-node-exporter is installed, grab stats about the local
# machine by default.
static_configs:
- targets: [
'localhost:8000',
'localhost:8001',
'localhost:8002',
'localhost:8003',
'localhost:8004',
'localhost:8005',
'localhost:8006',
'localhost:8007',
'localhost:8008',
'localhost:8009',
'localhost:8010',
'localhost:8011',
'localhost:8012',
'localhost:8013',
'localhost:8014',
'localhost:8015',
'localhost:8016',
'localhost:8002',
'localhost:8017',
'localhost:8018',
'localhost:8019',
'localhost:8020',
'localhost:8021',
'localhost:8022',
'localhost:8023',
'localhost:8024',
'localhost:8025',
'localhost:8026',
'localhost:8027',
'localhost:8028',
'localhost:8029',
'localhost:8030',
'localhost:8030',
'localhost:8031',
'localhost:8032',
'localhost:8033',
'localhost:8034',
'localhost:8035',
'localhost:8036',
'localhost:8037',
'localhost:8038',
'localhost:8039',
'localhost:8040',
'localhost:9100'
]
现在我被困在我不知道如何或是否有可能获得不同端口正在使用的 RAM 使用量的地方?
我想做的输出是:
编辑:
如何为每个节点运行一个节点导出器并使用实例标签来区分不同的节点/计算机?
【问题讨论】:
-
您的抓取配置引用了在单台计算机 (localhost) 上运行的多个节点导出器。您应该为要监控的每台计算机指定主机名/IP 地址,否则您将复制指标,因为您要多次抓取一台计算机。有一个实例标签,您可以使用它来过滤/分组您的可视化,从而为您提供正在监控的每个节点/计算机的指标。
-
嗨@BrandonMcClure - 是的,但如果我可能会问,怎么可能做到这一点?如果它甚至可能做到呢??
-
您是否询问是否可以在单个实例(节点/计算机)上运行多个 node_exporter 并从每个实例中获取一些指标子集,答案是否定的。您应该只为每个节点运行 1 个 node_exporter 并使用实例标签来区分不同的节点/计算机。我认为通过在单台计算机上运行多个 node_exporters 来编辑您的问题,这对您有帮助。
-
嗨@BrandonMcClure 我现在已经在最底部更新了我的问题。在你解释之前,我不确定它是如何工作的。但我不确定如何为每个端口添加实例标签。基本上如果它有意义......我有例如我正在运行的 5 个 py 脚本,我们可以调用 main1.py main2.py mainN.py - 每个 py 文件在启动脚本时都有自己的端口(端口 8000、8001、8002 ...),我希望能够获取每个脚本的 RAM USAGE/CPU USAGE 而不是总数。
标签: prometheus grafana