gpt4 book ai didi

elasticsearch - 无法使用 elasticsearch 和 metricbeat 检索标准化 CPU 利用率百分比

转载 作者:行者123 更新时间:2023-12-03 00:49:42 24 4
gpt4 key购买 nike

我正在尝试使用以下查询检索标准化的 CPU 利用率百分比。

curl -H "Content-Type: application/json" -X POST  http://localhost:12001/metricbeat*/_search?pretty=true -d '{"query":{"bool":{"must": [{"range": {"system.cpu.total.norm.pct": {"gte": 0.1}}},{"range": {"@timestamp": {"gte": "now-10m","lte": "now/m"}}}]}}}'

我想要过去 10 分钟的标准化百分比,但我没有得到任何数据。以下是回应。
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 8,
"successful" : 8,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}

但是,如果我使用“ system.cpu.total.pct ”查询 elasticsearch,我会得到数据。此外,我使用“ cpu.metrics: [“percentages”、“normalized_percentages”、“ticks”] 更新了“CPU”的配置。

谁能让我知道为什么规范化查询不起作用?

下面是我的 metricbeat.reference.yml 配置。
module: system
metricsets:
- cpu # CPU usage
- load # CPU load averages
- memory # Memory usage
- network # Network IO
- process # Per process metrics
- process_summary # Process summary
- uptime # System Uptime
- core # Per CPU core usage
#- diskio # Disk IO
- filesystem # File system usage for each mountpoint
#- fsstat # File system summary metrics
#- raid # Raid
#- socket # Sockets and connection info (linux only)
enabled: true
period: 10s
processes: ['.*']

# Configure the metric types that are included by these metricsets.
cpu.metrics: ["percentages", "normalized_percentages", "ticks"] # The other available options are normalized_percentages and ticks.
core.metrics: ["percentages"] # The other available option is ticks.

Elasticsearch 模块:
module: elasticsearch
metricsets:
- node
- node_stats
#- index
#- index_recovery
#- index_summary
#- shard
#- ml_job
period: 10s
hosts: ["localhost:8881"]

我已启用 kibana 作为输出主机:
# Starting with Beats version 6.0.0, the dashboards are loaded via the Kibana API.
# This requires a Kibana endpoint configuration.
setup.kibana:

# Kibana Host
# Scheme and port can be left out and will be set to the default (http and 5601)
# In case you specify and additional path, the scheme is required: http://localhost:5601/path
# IPv6 addresses should always be defined as: https://[2001:db8::1]:5601
host: "localhost:8882"

最佳答案

您使用的是哪个版本的 metricsbeat? system.cpu.total.norm.pct 是相对较新的字段,不存在于旧的 metricsbeat 版本中。
这可能是字段 system.cpu.total.norm.pct 本身不属于 metricsbeat 或 system.cpu.total.norm.pct 大于 0.1 的条件未完全填充。

如果您只想检索一个字段,那么它应该是 _source 下包含部分的一部分,而不是像下面这样的条件本身

curl -H "Content-Type: application/json" -X POST  http://localhost:12001/metricbeat*/_search?pretty=true -d '{ "_source": {"includes": [ "system.cpu.total.norm.pct"]},"query":{"bool":{"must": [{"range": {"@timestamp": {"gte": "now-10m","lte": "now/m"}}}]}}}'

metricsbeat 模块配置说明

由于 metricbeat.reference.yml 发生了变化,让我解释一下 metricsbeat 如何读取输入模块的配置的流程。

Metricsbeat 默认读取 metricbeat.yml。

在这个文件的第一部分是 metricbeat.config.modules 它定义了它应该使用的所有输入模块
metricbeat.config.modules:
# Glob pattern for configuration loading
path: ${path.config}/modules.d/*.yml

因此它包括 modules.d 目录下存在的所有文件,并具有后缀 yml。

默认情况下,只有 system.yml 处于事件状态,其他文件扩展名被禁用,因此它们不是事件模块的一部分
modules.d/aerospike.yml.disabled
modules.d/apache.yml.disabled
modules.d/ceph.yml.disabled
modules.d/couchbase.yml.disabled
modules.d/docker.yml.disabled
modules.d/dropwizard.yml.disabled
modules.d/elasticsearch.yml.disabled
modules.d/envoyproxy.yml.disabled
modules.d/etcd.yml.disabled
modules.d/golang.yml.disabled
modules.d/graphite.yml.disabled
modules.d/haproxy.yml.disabled
modules.d/http.yml.disabled
modules.d/jolokia.yml.disabled
modules.d/kafka.yml.disabled
modules.d/kibana.yml.disabled
modules.d/kubernetes.yml.disabled
modules.d/kvm.yml.disabled
modules.d/logstash.yml.disabled
modules.d/memcached.yml.disabled
modules.d/mongodb.yml.disabled
modules.d/munin.yml.disabled
modules.d/mysql.yml.disabled
modules.d/nginx.yml.disabled
modules.d/php_fpm.yml.disabled
modules.d/postgresql.yml.disabled
modules.d/prometheus.yml.disabled
modules.d/rabbitmq.yml.disabled
modules.d/redis.yml.disabled
modules.d/system.yml
modules.d/traefik.yml.disabled
modules.d/uwsgi.yml.disabled
modules.d/vsphere.yml.disabled
modules.d/windows.yml.disabled
modules.d/zookeeper.yml.disabled

如您所见,只有 system.yml 没有扩展名 .disabled 并满足包含模块 path: ${path.config}/modules.d/*.yml 的条件所以它包括在内。

您可以通过运行以下命令列出所有启用和禁用的模块
$ ./metricbeat modules list
Enabled:
system

Disabled:
aerospike
apache
ceph
couchbase
docker
dropwizard
elasticsearch
envoyproxy
etcd
golang
graphite
haproxy
http
jolokia
kafka
kibana
kubernetes
kvm
logstash
memcached
mongodb
munin
mysql
nginx
php_fpm
postgresql
prometheus
rabbitmq
redis
traefik
uwsgi
vsphere
windows
zookeeper

并通过运行以下命令将事件更改为禁用和禁用
$ ./metricbeat modules
Manage configured modules

Usage:
metricbeat modules [command]

Available Commands:
disable Disable one or more given modules
enable Enable one or more given modules
list List modules

Flags:
-h, --help help for modules

Global Flags:
-E, --E setting=value Configuration overwrite
-c, --c string Configuration file, relative to path.config (default "metricbeat.yml")
-d, --d string Enable certain debug selectors
-e, --e Log to stderr and disable syslog/file output
--path.config string Configuration path
--path.data string Data path
--path.home string Home path
--path.logs string Logs path
--plugin pluginList Load additional plugins
--strict.perms Strict permission checking on config files (default true)
-v, --v Log at INFO level


因此,如果您想启用 kafka 模块,可以按如下方式完成
$ ./metricbeat modules enable kafka
Enabled kafka

然后检查它是否活跃
$ ./metricbeat modules list
Enabled:
kafka
system

Disabled:
aerospike
apache
ceph
couchbase
docker
dropwizard
elasticsearch
envoyproxy
etcd
golang
graphite
haproxy
http
jolokia
kibana
kubernetes
kvm
logstash
memcached
mongodb
munin
mysql
nginx
php_fpm
postgresql
prometheus
rabbitmq
redis
traefik
uwsgi
vsphere
windows
zookeeper

运行上述命令后,它将重命名文件 modules.d/kafka.yml.disabledmodules.d/kafka.yml并且您可以更新修改 modules.d/kafka.yml 下的配置

我希望这个解释有助于改变 metricsbeat 配置。

关于elasticsearch - 无法使用 elasticsearch 和 metricbeat 检索标准化 CPU 利用率百分比,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55691164/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com