Prometheus 节点导出器没有一种禁用所有默认指标的简单方法,而不会向该进程传递20个标志。在documentation中,似乎可以有一种更简单的方法来仅获取相关指标:
过滤已启用的收集器
...
要进行高级使用,可以向node_exporter传递一个可选的收集器列表以过滤指标。 collect []参数可以多次使用。在Prometheus配置中,可以在scrape配置下使用此语法。
params: collect[]: - foo - bar
这对于让不同的Prometheus服务器从节点收集特定指标很有用。
我的假设是将 params 直接放在scrape_config下,因为存在一个匹配的 params 字段。但是, collect [] 下到底应该包含什么?示例 foo 和 bar 的描述性都没有那么差。是命令行参数(例如“ --collector.cpu”),收集器名称(例如“ cpu”),收集器度量名称(例如“ node_cpu”),实际度量(例如“ node_cpu_seconds_total” ”或其他内容?
答案 0 :(得分:1)
还有另一种通用解决方案,可以与所有出口商一起使用。 relabel_map_config是可在prometheus配置文件中设置的配置选项。如文档中所指定:
一种用途是将时间序列列入黑名单,而这对于 摄取。
因此,您可以删除或保留与正则表达式匹配的指标。例如,要仅存储由节点导出器收集的cpu指标,可以在prometheus.yml
文件中使用以下内容:
scrape_configs:
- job_name: node
static_configs:
- targets:
- localhost:9100
metric_relabel_configs:
- source_labels: [__name__]
regex: node_cpu_.*
action: keep
答案 1 :(得分:1)
正如 All Workers Are Essential 所说,import { StyleSheet, Text, View, FlatList, ActivityIndicator } from "react-native";
...
...
render(){
return(
<View style={{ flex: 1 }}>
{this.state.record ? (
<>
<Text>Data from firebase firestore</Text>
<FlatList
style={{ flex: 1 }}
data={this.state.record}
keyExtractor={(key, index) => key + index}
renderItem={(itemData) => {
return <Text>{itemData.item[0].age}</Text>;
}}
/>
</>
) : (
<View
style={{ flex: 1, justifyContent: "center", alignItems: "center" }}
>
<ActivityIndicator size="large" color="black" />
</View>
)}
</View>
);
}
参数中预期的参数是收集器的名称。
补充答案,您可以在下面找到节点导出器配置的工作示例,仅过滤 collect[]
、cpu
和 meminfo
收集器:
filesystem
请记住,仍然可以访问旧收集的指标,但是一旦重新启动 scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: 'prometheus'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['localhost:9090']
# Node exporter
- job_name: 'node_exporter'
static_configs:
- targets: ['localhost:9100']
params:
collect[]:
- cpu
- meminfo
- filesystem
服务,只有过滤的指标(prometheus
、cpu
和 meminfo
) 将可用。
答案 2 :(得分:0)
通过测试节点收集器, collect [] 参数必须为收集器名称。例如,--collector.cpu
的名称是cpu
。
如果您指定了无效的收集器(例如foo
),则会收到以下HTTP“ 400 Bad Request”消息:
Couldn't create missing collector: foo