如何获取每个目标的内存使用情况
How to get memory usage per target
我一直在与 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 使用率?
我想做的输出是:
编辑:
如何运行每个节点一个node exporter并使用实例标签区分不同nodes/computers?
出于历史目的保留此部分:
默认情况下,您的指标系列在被抓取时会被赋予标签。最小值是 job
和 instance
。
例如,如果您的公制系列是 node_memory_MemAvailable_bytes
您可以 select 来自您的一个目标的系列作为
node_memory_MemAvailable_bytes{instance="localhost:9100"}
这适用于任何类型的指标。
旁注:如果您的服务器上有多个 node_exporter 运行,您将不会看到不同的信息。
编辑:
所述问题是@ProtractorNewbie 希望能够从单个服务器导出 CPU 用法。理想情况下,他们想使用 node_exporter.
目前 node_exporter
无法逐个提供进程信息。
但是,可能会使用 collectd
配置并启用 cgroups
和 write_prometheus
插件。
那么您需要拥有这些服务中的每一个 running as systemd services。
您要使用的数据如下所示:
collectd_cgroups_cpu_total{cgroups="myservice.service",type="user",instance="myinstancename"} 0 1632740881417
从那里您可以执行任何典型的普罗米修斯操作。
我一直在与 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 使用率?
我想做的输出是:
编辑:
如何运行每个节点一个node exporter并使用实例标签区分不同nodes/computers?
出于历史目的保留此部分:
默认情况下,您的指标系列在被抓取时会被赋予标签。最小值是 job
和 instance
。
例如,如果您的公制系列是 node_memory_MemAvailable_bytes
您可以 select 来自您的一个目标的系列作为
node_memory_MemAvailable_bytes{instance="localhost:9100"}
这适用于任何类型的指标。
旁注:如果您的服务器上有多个 node_exporter 运行,您将不会看到不同的信息。
编辑:
所述问题是@ProtractorNewbie 希望能够从单个服务器导出 CPU 用法。理想情况下,他们想使用 node_exporter.
目前 node_exporter
无法逐个提供进程信息。
但是,可能会使用 collectd
配置并启用 cgroups
和 write_prometheus
插件。
那么您需要拥有这些服务中的每一个 running as systemd services。
您要使用的数据如下所示:
collectd_cgroups_cpu_total{cgroups="myservice.service",type="user",instance="myinstancename"} 0 1632740881417
从那里您可以执行任何典型的普罗米修斯操作。