InfluxDB : Install Telegraf2026/06/03 |
|
Install Telegraf which can collect or send various metrics. Telegraf supports many Input /Output plugins, refer to the official site below. ⇒ https://docs.influxdata.com/telegraf/v1.27/plugins/ |
|
| [1] | Install Telegraf. |
|
root@dlp:~# curl -fsSL https://repos.influxdata.com/influxdata-archive.key | gpg --dearmor -o /etc/apt/keyrings/influxdata-keyring.gpg root@dlp:~# echo "deb [signed-by=/etc/apt/keyrings/influxdata-keyring.gpg] https://repos.influxdata.com/ubuntu stable main" | tee /etc/apt/sources.list.d/influxdata.list root@dlp:~# apt update root@dlp:~# apt -y install telegraf
|
| [2] | Configure Telegraf. As an example, configure it to get CPU related metrics on the system and send them to InfluxDB. |
|
root@dlp:~#
mv /etc/telegraf/telegraf.conf /etc/telegraf/telegraf.conf.org root@dlp:~# vi /etc/telegraf/telegraf.conf # create new [global_tags] # set any tag if you need to add it on data dc = "hiroshima-01" [agent] # collection interval for all inputs interval = "10s" # if set [true], then always collect on :00, :10, :20 ... round_interval = true # the size of writes that Telegraf sends to output plugins metric_batch_size = 1000 # cost of higher maximum memory usage metric_buffer_limit = 10000 # it is used to jitter the collection by a random amount collection_jitter = "0s" # flushing interval for all outputs flush_interval = "10s" # jitter the flush interval by a random amount # if flush_interval=10s, flush_jitter=5s, then flushes will happen every 10-15s flush_jitter = "0s" [[outputs.influxdb]] # InfluxDB access URL urls = ["https://dlp.srv.world:8086"] database = "telegraf" # if auth is enabled, set admin username and password username = "admin" password = "adminpassword" # if HTTPS is enabled, set the path to certificate # it needs [telegraf] user can read certificate tls_cert = "/etc/telegraf/server.crt" tls_key = "/etc/telegraf/server.key" # if using self signed certificate, set [true] insecure_skip_verify = true # settings for CPU related metrics [[inputs.cpu]] percpu = true totalcpu = true collect_cpu_time = false report_active = false
root@dlp:~#
systemctl restart telegraf
# change retention policy # follow means 30 days retention (default is infinite) root@dlp:~# influx -username admin -password adminpassword -database telegraf -ssl -unsafeSsl \
-execute 'create retention policy "one_month" on "telegraf" duration 30d replication 1 default' influx -username admin -password adminpassword -database telegraf -ssl -unsafeSsl \ -execute 'show retention policies' name duration shardGroupDuration replicaN default ---- -------- ------------------ -------- ------- autogen 0s 168h0m0s 1 false one_month 720h0m0s 24h0m0s 1 true # verify data root@dlp:~# influx -username admin -password adminpassword -database telegraf -precision rfc3339 \ -execute 'select * from cpu' -ssl -unsafeSsl name: cpu time cpu dc host usage_guest usage_guest_nice usage_idle usage_iowait usage_irq usage_nice usage_softirq usage_steal usage_system usage_user ---- --- -- ---- ----------- ---------------- ---------- ------------ --------- ---------- ------------- ----------- ------------ ---------- 2026-06-03T00:29:00Z cpu-total hiroshima-01 dlp.srv.world 0 0 99.69984992496502 0.1500750375187578 0 0 0 0 0.10005002501250522 0.05002501250626149 2026-06-03T00:29:00Z cpu0 hiroshima-01 dlp.srv.world 0 0 99.79979979979997 0 0 0 0 0 0.10010010010010904 0.10010010010010015 2026-06-03T00:29:00Z cpu1 hiroshima-01 dlp.srv.world 0 0 99.5004995004977 0.2997002997002912 0 0 0 0 0.09990009990009559 0.09990009990009559 2026-06-03T00:29:10Z cpu-total hiroshima-01 dlp.srv.world 0 0 99.699999999998 0.1499999999999968 0 0 0 0 0.09999999999999787 0.049999999999998934 2026-06-03T00:29:10Z cpu0 hiroshima-01 dlp.srv.world 0 0 99.89989989989772 0 0 0 0 0 0.1001001001000956 0 ..... ..... |
| [3] | For other System related metrics, configure like follows. |
|
root@dlp:~#
vi /etc/telegraf/telegraf.conf # add to last line # memory [[inputs.mem]] # swap [[inputs.swap]] # disk [[inputs.disk]] ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"] # disk IO [[inputs.diskio]] # kernel statistics (/proc/stat) [[inputs.kernel]] # processes [[inputs.processes]] # system (Uptime and so on) [[inputs.system]] # networking [[inputs.net]]
root@dlp:~#
root@dlp:~# systemctl restart telegraf
influx -username admin -password adminpassword -database telegraf -precision rfc3339 -execute 'show measurements' -ssl -unsafeSsl name: measurements name ---- cpu disk diskio kernel mem net processes swap systemroot@dlp:~# influx -username admin -password adminpassword -database telegraf -precision rfc3339 \ -execute 'select * from disk' -ssl -unsafeSsl name: disk time dc device free fstype host inodes_free inodes_total inodes_used inodes_used_percent label mode path total used used_percent ---- -- ------ ---- ------ ---- ----------- ------------ ----------- ------------------- ----- ---- ---- ----- ---- ------------ 2026-06-03T00:30:50Z hiroshima-01 dm-0 20314738688 ext4 dlp.srv.world 1725099 1835008 109909 5.989565168108259 ubuntu--vg-ubuntu--lv rw / 29408399360 7573856256 27.15753974414352 2026-06-03T00:30:50Z hiroshima-01 vda2 1813581824 ext4 dlp.srv.world 130733 131072 339 0.258636474609375 rw /boot 2040373248 102641664 5.356455791444719 2026-06-03T00:31:00Z hiroshima-01 dm-0 20314730496 ext4 dlp.srv.world 1725099 1835008 109909 5.989565168108259 ubuntu--vg-ubuntu--lv rw / 29408399360 7573864448 27.1575691181583 2026-06-03T00:31:00Z hiroshima-01 vda2 1813581824 ext4 dlp.srv.world 130733 131072 339 0.258636474609375 rw /boot 2040373248 102641664 5.356455791444719 2026-06-03T00:31:10Z hiroshima-01 dm-0 20314722304 ext4 dlp.srv.world 1725099 1835008 109909 5.989565168108259 ubuntu--vg-ubuntu--lv rw / 29408399360 7573872640 27.157598492173072 ..... .....root@dlp:~# influx -username admin -password adminpassword -database telegraf -precision rfc3339 \ -execute 'select * from diskio' -ssl -unsafeSsl name: diskio time dc host io_await io_svctm io_time io_util iops_in_progress merged_reads merged_writes name read_bytes read_time reads weighted_io_time write_bytes write_time writes ---- -- ---- -------- -------- ------- ------- ---------------- ------------ ------------- ---- ---------- --------- ----- ---------------- ----------- ---------- ------ 2026-06-03T00:30:50Z hiroshima-01 dlp.srv.world 9611 0 0 0 dm-0 493405184 2470 10213 16201 1537798144 13602 12669 2026-06-03T00:30:50Z hiroshima-01 dlp.srv.world 9614 0 2886 6648 vda3 509608960 2378 7454 17752 1537798144 15246 6186 2026-06-03T00:30:50Z hiroshima-01 dlp.srv.world 9414 0 2909 6666 vda 532240384 2411 7934 25159 1537998848 15294 6230 2026-06-03T00:30:50Z hiroshima-01 dlp.srv.world 66 0 23 18 vda2 18621440 18 293 70 200704 48 43 2026-06-03T00:30:50Z hiroshima-01 dlp.srv.world 0 0 0 0 vda1 946176 3 51 3 0 0 0 ..... .....root@dlp:~# influx -username admin -password adminpassword -database telegraf -precision rfc3339 \ -execute 'select * from kernel' -ssl -unsafeSsl name: kernel time boot_time context_switches dc entropy_avail host interrupts processes_forked ---- --------- ---------------- -- ------------- ---- ---------- ---------------- 2026-06-03T00:30:50Z 1780443894 340738 hiroshima-01 256 dlp.srv.world 329290 3899 2026-06-03T00:31:00Z 1780443894 342261 hiroshima-01 256 dlp.srv.world 330576 3899 2026-06-03T00:31:10Z 1780443894 343949 hiroshima-01 256 dlp.srv.world 331876 3899 2026-06-03T00:31:20Z 1780443894 346026 hiroshima-01 256 dlp.srv.world 333457 3913 2026-06-03T00:31:30Z 1780443894 347962 hiroshima-01 256 dlp.srv.world 335014 3929 ..... .....root@dlp:~# influx -username admin -password adminpassword -database telegraf -precision rfc3339 \ -execute 'select * from mem' -ssl -unsafeSsl name: mem time active available available_percent buffered cached commit_limit committed_as dc dirty free high_free high_total host huge_page_size huge_pages_free huge_pages_total inactive low_free low_total mapped page_tables shared slab sreclaimable sunreclaim swap_cached swap_free swap_total total used used_percent vmalloc_chunk vmalloc_total vmalloc_used write_back write_back_tmp ---- ------ --------- ----------------- -------- ------ ------------ ------------ -- ----- ---- --------- ---------- ---- -------------- --------------- ---------------- -------- -------- --------- ------ ----------- ------ ---- ------------ ---------- ----------- --------- ---------- ----- ---- ------------ ------------- ------------- ------------ ---------- -------------- 2026-06-03T00:30:50Z 288919552 3047669760 85.54075446839674 36089856 997683200 5880291328 643469312 hiroshima-01 589824 2255777792 0 0 dlp.srv.world 2097152 0 0 804638720 0 0 230719488 3805184 1073152 95477760 41668608 53809152 0 4098879488 4098879488 3562827776 515158016 14.459245531603266 0 14073748835531776 18903040 0 0 2026-06-03T00:31:00Z 290914304 3044282368 85.4456785283578 36139008 1003712512 5880291328 643469312 hiroshima-01 638976 2249314304 0 0 dlp.srv.world 2097152 0 0 804704256 0 0 232259584 3809280 1073152 102199296 47689728 54509568 0 4098879488 4098879488 3562827776 518545408 14.554321471642192 0 14073748835531776 18903040 0 0 2026-06-03T00:31:10Z 292499456 3043815424 85.43257253420492 36188160 1003720704 5880291328 647663616 hiroshima-01 557056 2248798208 0 0 dlp.srv.world 2097152 0 0 804753408 0 0 232517632 3813376 1073152 102199296 47689728 54509568 0 4098879488 4098879488 3562827776 519012352 14.56742746579508 0 14073748835531776 18903040 0 0 2026-06-03T00:31:20Z 293404672 3041533952 85.36853710663335 36212736 1003737088 5880291328 647663616 hiroshima-01 229376 2246475776 0 0 dlp.srv.world 2097152 0 0 804794368 0 0 232521728 3813376 1073152 102203392 47689728 54513664 0 4098879488 4098879488 3562827776 521293824 14.631462893366642 0 14073748835531776 18919424 0 0 2026-06-03T00:31:30Z 294711296 3038994432 85.29725889281941 36257792 1003749376 5880291328 647663616 hiroshima-01 73728 2243895296 0 0 dlp.srv.world 2097152 0 0 804835328 0 0 232521728 3817472 1073152 102203392 47689728 54513664 0 4098879488 4098879488 3562827776 523833344 14.702741107180591 0 14073748835531776 18903040 0 0 ..... .....root@dlp:~# influx -username admin -password adminpassword -database telegraf -precision rfc3339 \ -execute 'select * from net' -ssl -unsafeSsl name: net time bytes_recv bytes_sent dc drop_in drop_out err_in err_out host interface packets_recv packets_sent speed ---- ---------- ---------- -- ------- -------- ------ ------- ---- --------- ------------ ------------ ----- 2026-06-03T00:30:50Z 94119821 608457 hiroshima-01 1378 0 0 0 dlp.srv.world enp1s0 16039 8040 -1 2026-06-03T00:31:00Z 94120261 608457 hiroshima-01 1383 0 0 0 dlp.srv.world enp1s0 16047 8040 -1 2026-06-03T00:31:10Z 94121267 608457 hiroshima-01 1388 0 0 0 dlp.srv.world enp1s0 16061 8040 -1 2026-06-03T00:31:20Z 94121527 608457 hiroshima-01 1393 0 0 0 dlp.srv.world enp1s0 16066 8040 -1 2026-06-03T00:31:30Z 94121787 608457 hiroshima-01 1398 0 0 0 dlp.srv.world enp1s0 16071 8040 -1 ..... .....root@dlp:~# influx -username admin -password adminpassword -database telegraf -precision rfc3339 \ -execute 'select * from processes' -ssl -unsafeSsl name: processes time blocked dc dead host idle paging running sleeping stopped total total_threads unknown zombies ---- ------- -- ---- ---- ---- ------ ------- -------- ------- ----- ------------- ------- ------- 2026-06-03T00:30:50Z 1 hiroshima-01 0 dlp.srv.world 64 0 0 75 0 140 180 0 0 2026-06-03T00:31:00Z 1 hiroshima-01 0 dlp.srv.world 64 0 0 75 0 140 180 0 0 2026-06-03T00:31:10Z 2 hiroshima-01 0 dlp.srv.world 64 0 0 74 0 140 180 0 0 2026-06-03T00:31:20Z 1 hiroshima-01 0 dlp.srv.world 64 0 0 75 0 140 180 0 0 2026-06-03T00:31:30Z 2 hiroshima-01 0 dlp.srv.world 64 0 0 74 0 140 180 0 0 ..... .....root@dlp:~# influx -username admin -password adminpassword -database telegraf -precision rfc3339 \ -execute 'select * from swap' -ssl -unsafeSsl name: swap time dc free host in out total used used_percent ---- -- ---- ---- -- --- ----- ---- ------------ 2026-06-03T00:30:50Z hiroshima-01 4098879488 dlp.srv.world 0 0 4098879488 0 0 2026-06-03T00:31:00Z hiroshima-01 4098879488 dlp.srv.world 0 0 4098879488 0 0 2026-06-03T00:31:10Z hiroshima-01 4098879488 dlp.srv.world 0 0 4098879488 0 0 2026-06-03T00:31:20Z hiroshima-01 4098879488 dlp.srv.world 0 0 4098879488 0 0 2026-06-03T00:31:30Z hiroshima-01 4098879488 dlp.srv.world 0 0 4098879488 0 0 ..... .....root@dlp:~# influx -username admin -password adminpassword -database telegraf -precision rfc3339 \ -execute 'select * from system' -ssl -unsafeSsl name: system name: system time dc host load1 load15 load5 n_cpus n_physical_cpus uptime uptime_format ---- -- ---- ----- ------ ----- ------ --------------- ------ ------------- 2026-06-03T00:30:50Z hiroshima-01 dlp.srv.world 0.04 0.01 0.04 2 2 2756 0:45 2026-06-03T00:31:00Z hiroshima-01 dlp.srv.world 0.03 0.01 0.04 2 2 2766 0:46 2026-06-03T00:31:10Z hiroshima-01 dlp.srv.world 0.03 0 0.04 2 2 2776 0:46 2026-06-03T00:31:20Z hiroshima-01 dlp.srv.world 0.02 0 0.04 2 2 2786 0:46 2026-06-03T00:31:30Z hiroshima-01 dlp.srv.world 0.02 0 0.03 2 2 2796 0:46 ..... ..... |
| Sponsored Link |
|
|