Using metricbeat to send the metrics to PacketAI

Download Metricbeat


Download metricbeat using below bash script:
curl -o metricbeat.tar.gz
tar -xf metricbeat.tar.gz
mv metricbeat-8.4.3-linux-x86_64 metricbeat
rm metricbeat.tar.gz


Download metricbeat using Powershell script:
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri -OutFile
Expand-Archive .\
mv ./mbeat/metricbeat-8.4.3-windows-x86_64/ ./metricbeat
rm -r ./mbeat
rm ./
cd ./metricbeat

Configure Metricbeat

Edit metricbeat.yml, use the below metricbeat configuration, we need to customise this according to your requirements, explained in details about each section below. The complete metricbeat configuration can be found here
# Glob pattern for configuration loading
path: ${path.config}/modules.d/*.yml
# Set to true to enable config reloading
reload.enabled: true
# Period on which files under path should be checked for changes
#reload.period: 10s
setup.template.enabled: false
setup.dashboards.enabled: false
setup.ilm.enabled: false
# ================================== Outputs ===================================
# Configure what output to use when sending the data collected by the beat.
# pretty: true
# ---------------------------- Elasticsearch Output ----------------------------
# Array of hosts to connect to.
allow_older_versions: true
hosts: [""]
protocol: https
path: /elasticsearch/mb
compression_level: 9
index: "es"
# ================================= Processors =================================
# Configure processors to enhance or manipulate events generated by the beat.
- add_host_metadata: ~
- add_cloud_metadata: ~
- add_docker_metadata: ~
- add_kubernetes_metadata: ~
- add_fields:
target: fields
metricbeat modules:
  • To enable the windows module, please run the below command.
    • metricbeat.exe modules enable windows
    • There are multiple modules available on metricbeat, they can be enabled to similar to the above command, the list of available modules are listed here.
    • The list of enabled modules are available in modules.d directory
    • To disable a module we need to run this command: metricbeat.exe modules disable windows
  • hosts: Make sure that your hosts entries are correct. hosts: [""] change URL if your PacketAI URL's are different
  • compression_level is between 0 to 9, 0 being no compression at all, and 9 being best compression, we would suggest to use the value 6. higher compression values means higher cpu usage and lower network usage.
  • headers sub section needs to update according to you PAI_IID and PAI_TOKEN. you can get them on packetai after login, and under the section of Deploy PacketAI / Agent
  • We need to modify the YOUR_CLUSTER_NAME with appropriate cluster name. clusterName can be used to manage the retention period on PacketAI managed. Please note that clusterName cannot contain character "-". Currently this field is mandatory.
  • add_cloud_metadata: ~ is optional, this adds the metadata of the cloud. i.e. region, zone, machine_id etc...
  • add_docker_metadata is optional, this also docker metadata, docker container name, image name, docker labels, etc.... This extra metadata will increase the index size at PacketAI.

Installation of Metricbeat

We could run the metricbeat with the below command to start the metricbeat, we need to install a service, if we want to automatically start the metricbeat service on system startup.
./metricbeat -c metricbeat.yml
systemd service file (metricbeat.service): Here we are assuming that metricbeat is located at /opt/metricbeat, if the metricbeat is located somewhere please update the metricbeat.service file to reflect the same.
# metricbeat.service
ExecStart=/opt/metricbeat/metricbeat -c metricbeat.yml
copy the file to /etc/systemd/system directory, and run the below commands. In
// Some code
systemctl enable metricbeat
systemctl start metricbeat
In order to install the metricbeat on Windows, we need to run the below command, in metricbeat folder.
Start-Service metricbeat