[英]How do I get metricbeat to report normalized CPU percentages to Kibana
[英]Not able to retrieve normalized CPU utilization percentage using elasticsearch and metricbeat
我正在嘗試通過使用以下查詢來檢索標准化的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:[“百分比”,“ normalized_percentages”,“滴答聲”] ”更新了“ 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下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
的條件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配置。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.