我正在尝试通过使用以下查询来检索标准化的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"
答案 0 :(得分:1)
您正在使用哪个版本的metricsbeat? system.cpu.total.norm.pct是相对较新的字段,在较旧的metricsbeat版本中不存在。 这可能是字段system.cpu.total.norm.pct本身不属于metricsbeat的一部分,也不是system.cpu.total.norm.pct大于0.1的条件未完全填充的条件。
如果您只想检索一个字段,则它应该是_source下include部分的一部分,而不是像下面这样
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"}}}]}}}'
由于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
的条件,因此包含它。
您可以通过在commnad下面运行来列出所有启用和禁用的模块
$ ./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
并通过运行以下命令更改为active以禁用和禁用
$ ./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.disabled
重命名为modules.d/kafka.yml
,您可以更新modules.d/kafka.yml
下的修改配置
我希望此说明有助于更改metricsbeat配置。