Running Metricbeat with the system module

Let's make use of Metricbeat and capture system metrics.

Make sure that Kibana 7.0 and Elasticsearch 7.0 are running:

  1. Replace the content of metricbeat.yml with the following configuration and save the file:
############### Metricbeat Configuration Example ################
#============== Modules configuration =========================

metricbeat.config.modules:
# Glob pattern for configuration loading
path: ${path.config}/modules.d/*.yml

# Set to true to enable config reloading
reload.enabled: false

# Period on which files under path should be checked for changes
#reload.period: 10s

#=========== Elasticsearch template setting =================

setup.template.settings:
index.number_of_shards: 1
index.codec: best_compression
#_source.enabled: false

#=================== General Settings===============================
name: metricbeat_inst1

tags: ["system-metrics", "localhost"]

fields:
env: test-env

#============================== Dashboards ===========================
setup.dashboards.enabled: true

#============================== Kibana Settings ===========================
setup.kibana:
host: "localhost:5601"
#username: "elastic"
#password: "changeme"

#-------------------------- Elasticsearch output Settings ---------------------
output.elasticsearch:
# Array of hosts to connect to.
hosts: ["localhost:9200"]
#username: "elastic"
#password: "changeme"
The setup.dashboards.enabled: true setting loads sample dashboards to the Kibana index during startup, which are loaded via the Kibana API. If Elasticsearch and Kibana are secured, make sure that you uncomment the username and password parameters and set the appropriate values.
  1. By default, the system module is enabled. Make sure that it is enabled by executing the following command:
Windows:
E:metricbeat-7.0.0-windows-x86_64>metricbeat.exe modules enable system
Module system is already enabled

Linux:
[locationOfMetricBeat]$./metricbeat modules enable system
Module system is already enabled
  1. You can verify the metricsets that are enabled for the system module by opening the system.yml file, which can be found under the modules.d directory, as follows:
#system.yml
- module: system
period: 10s
metricsets:
- cpu
#- load
- memory
- network
- process
- process_summary
#- socket_summary
#- core
#- diskio
#- socket
processes: ['.*']
process.include_top_n:
by_cpu: 5 # include top 5 processes by CPU
by_memory: 5 # include top 5 processes by memory

- module: system
period: 1m
metricsets:
- filesystem
- fsstat
processors:
- drop_event.when.regexp:
system.filesystem.mount_point: '^/(sys|cgroup|proc|dev|etc|host|lib)($|/)'

As seen in the preceding code, the configuration module is defined twice, with different periods to use for a set of metricsets. The cpu, memory, network, process, process_summary, filesystem, and fsstats metricsets are enabled. 

  1. Start Metricbeat by executing the following command:
Windows:
E:metricbeat-7.0.0-windows-x86_64>metricbeat.exe -e



Linux:
[locationOfMetricBeat]$./metricbeat -e

Once Metricbeat is started, it loads sample Kibana dashboards and starts shipping metrics to Elasticsearch. To validate this, execute the following command:

curl -X GET 'http://localhost:9200/_cat/indices?v=&format=json' 

Sample Response:
[
{
"health": "yellow",
"status": "open",
"index": "metricbeat-7.0.0-2019.04.02",
"uuid": "w2WoP2IhQ9eG7vSU_HmgnA",
"pri": "1",
"rep": "1",
"docs.count": "29",
"docs.deleted": "0",
"store.size": "45.3kb",
"pri.store.size": "45.3kb"
},
{
"health": "yellow",
"status": "open",
"index": ".kibana",
"uuid": "sSzeYu-YTtWR8vr2nzKrbg",
"pri": "1",
"rep": "1",
"docs.count": "108",
"docs.deleted": "59",
"store.size": "289.3kb",
"pri.store.size": "289.3kb"
}
]

curl -X GET 'http://localhost:9200/_cat/indices?v'

health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
yellow open metricbeat-7.0.0-2019.04.02 w2WoP2IhQ9eG7vSU_HmgnA 1 1 29 0 45.3kb 45.3kb
yellow open .kibana sSzeYu-YTtWR8vr2nzKrbg 1 1 108 59 289.3kb 289.3kb
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.146.255.249