Overview
Nodegrid OS comes with Telegraf which is an agent that can gather server metrics and output to various databases for real-time monitoring and analysis. This article will show you how to enable Telegraf and configure to export the Nodegrid OS metrics to your database of choice.
Enable Telegraf
Login to your Nodegrid as admin user, navigate to Security-->Services and check the box for Telegraf.
Modify Default Telegraf Configuration
Telegraf configuration file is located
/etc/telegraf/telegraf.conf. You must connect to your Nodegrid console as admin and become root user to modify this file, from the console, run these commands:
- shell sudo su -
- cd /etc/telegraf
- vi telegraf.conf
These commands will do the following:
- from your CLI console, elevate your user as root shell user
- change to the telegraf configuration directory
- start 'vi' editor to make changes on telegraf.conf.
Sample Configuration
Here is a sample configuration. In this sample, we use Prometheus output plugin, but there are others available, refer to Telegraf documentation. To use the output, you will need to use your existing Prometheus server and configure a scrape job to gather the metrics exposed by Telegraf.
Explanation for this configuration is below.
[global_tags]
nodegrid =
"true"
[agent]
interval = "10s"
round_interval =
true
metric_batch_size =
1000
metric_buffer_limit =
10000
collection_jitter =
"0s"
flush_interval =
"10s"
flush_jitter =
"0s"
precision = ""
hostname = ""
omit_hostname =
false
debug = true
[[outputs.prometheus_client]]
listen = ":9273"
metric_version = 2
[[inputs.cpu]]
percpu =
true
totalcpu =
true
collect_cpu_time =
false
report_active =
false
[[inputs.disk]]
ignore_fs =
["tmpfs",
"devtmpfs",
"devfs",
"iso9660", "overlay", "aufs", "squashfs"]
[[inputs.diskio]]
[[inputs.kernel]]
[[inputs.mem]]
[[inputs.processes]]
[[inputs.swap]]
[[inputs.system]]
[[inputs.net]]
Configuration Explanation
Breaking down this telegraf configuration.
- [global_tags]
- nodegrid = "true"
- global_tags: These tags are added to all metrics collected by Telegraf. Here, a tag
nodegrid with the value true is added
Agent Configuration
[agent]
interval = "10s"
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 10000
collection_jitter = "0s"
flush_interval = "10s"
flush_jitter = "0s"
precision = ""
hostname = ""
omit_hostname = false
debug = true
- interval: The time interval between metric collections (10 seconds).
- round_interval: If true, rounds collection intervals to the nearest interval.
- metric_batch_size: The number of metrics to send in each batch (1000).
- metric_buffer_limit: The maximum number of metrics that can be buffered (10000).
- collection_jitter: Adds a random jitter to the collection interval to avoid spikes (0 seconds).
- flush_interval: The time interval between metric flushes (10 seconds).
- flush_jitter: Adds a random jitter to the flush interval (0 seconds).
- precision: Sets the precision of the metrics (empty means default).
- hostname: Overrides the hostname (empty means default).
- omit_hostname: If true, omits the hostname from the metrics.
- debug: If true, enables debug logging.
Outputs
[[outputs.prometheus_client]]
listen = ":9273"
metric_version = 2
- outputs.prometheus_client: Configures Telegraf to expose metrics in Prometheus format.
- listen: The address and port to listen on (port 9273).
- metric_version: The Prometheus metric format version (2).
CPU
- [[inputs.cpu]]
percpu = true
totalcpu = true
collect_cpu_time = false
report_active = false
- inputs.cpu: Collects CPU metrics.
- percpu: If true, collects metrics per CPU.
- totalcpu: If true, collects total CPU metrics.
- collect_cpu_time: If false, does not collect CPU time metrics.
- report_active: If false, does not report active CPU metrics.
Disk
[[inputs.disk]]
ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"]
- inputs.disk: Collects disk usage metrics.
- ignore_fs: A list of filesystem types to ignore.
Disk I/O, Kernel, Memory, Processes, Swap, System, Network
The remaining input definitions have no parameters and are self explanatory, these are:
- diskio: Collects disk I/O metrics
- kernel: Collects kernel metrics
- mem: Collects memory usage metrics
- processes: Collects process metrics
- swap: Collects swap usage metrics
- system: Collects system metrics
- net: Collects network metrics
References
Depending on the version of Telegraf installed on Nodegrid, some telegraf capabilities may not be available. As of Nodegrid OS 6.0.20, Telegraf version is 1.19.0