Ubuntu 22.04
Sponsored Link

InfluxDB : Telegraf इंस्टॉल करें2023/09/14

 
Telegraf इंस्टॉल करें जो विभिन्न मेट्रिक्स एकत्र या भेज सकता है।
Telegraf कई इनपुट/आउटपुट प्लगइन्स का समर्थन करता है, नीचे दी गई आधिकारिक साइट देखें।
⇒ https://docs.influxdata.com/telegraf/v1.24/plugins/
[1] Telegraf इंस्टॉल करें।
root@dlp:~#
apt -y install telegraf
[2] Telegraf कॉन्फ़िगर करें।
उदाहरण के तौर पर, सिस्टम पर CPU संबंधित मेट्रिक्स प्राप्त करने के लिए इसे कॉन्फ़िगर करें और उन्हें InfluxDB पर भेजें।
root@dlp:~#
mv /etc/telegraf/telegraf.conf /etc/telegraf/telegraf.conf.org

root@dlp:~#
vi /etc/telegraf/telegraf.conf
# नया निर्माण

[global_tags]
  # यदि आपको इसे डेटा पर जोड़ने की आवश्यकता है तो कोई भी टैग सेट करें
  dc = "hiroshima-01"

[agent]
  # सभी इनपुट के लिए संग्रह अंतराल
  interval = "10s"
  # यदि सेट है [true], तो हमेशा :00, :10, :20... पर एकत्रित करें
  round_interval = true
  # राइट्स का आकार जो Telegraf आउटपुट प्लगइन्स को भेजता है
  metric_batch_size = 1000
  # उच्चतर अधिकतम मेमोरी उपयोग की लागत
  metric_buffer_limit = 10000
  # इसका उपयोग संग्रह को यादृच्छिक मात्रा में कम करने के लिए किया जाता है
  collection_jitter = "0s"
  # सभी आउटपुट के लिए फ्लशिंग अंतराल
  flush_interval = "10s"
  # फ्लश अंतराल को यादृच्छिक मात्रा में हिलाएं
  # यदि flush_interval=10s, flush_jitter=5s, तो हर 10-15 सेकंड में फ्लश होगा
  flush_jitter = "0s"

[[outputs.influxdb]]
  # InfluxDB एक्सेस यूआरएल
  url = "https://dlp.srv.world:8086"
  database = "telegraf"
  # यदि प्रमाणीकरण सक्षम है, तो व्यवस्थापक उपयोगकर्ता नाम और पासवर्ड सेट करें
  username = "admin"
  password = "adminpassword"
  # यदि HTTPS सक्षम है, तो प्रमाणपत्र के लिए पथ सेट करें
  # इसे [_telegraf] उपयोगकर्ता प्रमाणपत्र पढ़ने की आवश्यकता है
  tls_cert = "/etc/telegraf/server.crt"
  tls_key = "/etc/telegraf/server.key"
  # यदि स्वहस्ताक्षरित प्रमाणपत्र का उपयोग कर रहे हैं, तो [@true] सेट करें
  insecure_skip_verify = true

# CPU संबंधित मेट्रिक्स के लिए सेटिंग्स
[[inputs.cpu]]
  percpu = true
  totalcpu = true
  collect_cpu_time = false
  report_active = false

root@dlp:~#
systemctl restart telegraf
# प्रतिधारण नीति बदलें
# अनुसरण का अर्थ है 30 दिन प्रतिधारण (डिफ़ॉल्ट अनंत है)

root@dlp:~#
influx -username admin -password adminpassword -database telegraf -ssl -unsafeSsl \
-execute 'create retention policy "one_month" on "telegraf" duration 30d replication 1 default'
root@dlp:~#
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

# डेटा को सत्यापित करे

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
----                 ---       --           ----          ----------- ---------------- ----------        ------------         --------- ---------- ------------- ----------- ------------        ----------
2022-10-27T08:31:20Z cpu-total hiroshima-01 dlp.srv.world 0           0                99.89989989991591 0.05005005005006808  0         0          0             0           0                   0.050050050050050296
2022-10-27T08:31:20Z cpu0      hiroshima-01 dlp.srv.world 0           0                99.89989989987953 0.1001001001000997   0         0          0             0           0                   0
2022-10-27T08:31:20Z cpu1      hiroshima-01 dlp.srv.world 0           0                99.7999999999957  0                    0         0          0             0           0.0999999999999615  0.0999999999999615
2022-10-27T08:31:30Z cpu-total hiroshima-01 dlp.srv.world 0           0                99.69969969967498 0.15015015015013178  0         0          0             0           0.05005005005004985 0.10010010010008193
2022-10-27T08:31:30Z cpu0      hiroshima-01 dlp.srv.world 0           0                99.50049950050669 0.19980019980022748  0         0          0             0           0.09990009990011374 0.19980019980024524
2022-10-27T08:31:30Z cpu1      hiroshima-01 dlp.srv.world 0           0                99.70000000001153 0.20000000000006848  0         0          0             0           0                   0.10000000000003424
2022-10-27T08:31:40Z cpu-total hiroshima-01 dlp.srv.world 0           0                99.94994994997616 0.050050050050050296 0         0          0             0           0                   0
2022-10-27T08:31:40Z cpu0      hiroshima-01 dlp.srv.world 0           0                100               0                    0         0          0             0           0                   0
2022-10-27T08:31:40Z cpu1      hiroshima-01 dlp.srv.world 0           0                99.89989989987953 0.1001001001000997   0         0          0             0           0                   0
.....
.....
[3] सिस्टम से संबंधित अन्य मेट्रिक्स के लिए, निम्नानुसार कॉन्फ़िगर करें।
root@dlp:~#
vi /etc/telegraf/telegraf.conf
# अंत में जोड़ें

# याद
[[inputs.mem]]

# बदलना
[[inputs.swap]]

# डिस्क
[[inputs.disk]]
  ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"]

# डिस्क IO
[[inputs.diskio]]

# कर्नेल आँकड़े (/proc/stat)
[[inputs.kernel]]

# प्रक्रियाओं
[[inputs.processes]]

# सिस्टम (अपटाइम वगैरह)
[[inputs.system]]

# नेटवर्किंग
[[inputs.net]]

root@dlp:~#
systemctl restart telegraf
root@dlp:~#
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
system

root@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 mode path  total       used       used_percent
----                 --           ------ ----        ------ ----          ----------- ------------ ----------- ---- ----  -----       ----       ------------
2022-10-28T01:08:40Z hiroshima-01 dm-0   20023279616 ext4   dlp.srv.world 1652275     1769472      117197      rw   /     28422893568 7073099776 26.103486645482526
2022-10-28T01:08:40Z hiroshima-01 vda2   1658224640  ext4   dlp.srv.world 130752      131072       320         rw   /boot 2040373248  257998848  13.463922638234566
2022-10-28T01:08:50Z hiroshima-01 dm-0   20023267328 ext4   dlp.srv.world 1652275     1769472      117197      rw   /     28422893568 7073112064 26.103531994714697
2022-10-28T01:08:50Z hiroshima-01 vda2   1658224640  ext4   dlp.srv.world 130752      131072       320         rw   /boot 2040373248  257998848  13.463922638234566
.....
.....

root@dlp:~#
influx -username admin -password adminpassword -database telegraf -precision rfc3339 \
-execute 'select * from diskio' -ssl -unsafeSsl

name: diskio
time                 dc           host          io_time iops_in_progress merged_reads merged_writes name  read_bytes read_time reads weighted_io_time write_bytes write_time writes
----                 --           ----          ------- ---------------- ------------ ------------- ----  ---------- --------- ----- ---------------- ----------- ---------- ------
2022-10-28T01:08:40Z hiroshima-01 dlp.srv.world 8796    0                0            0             dm-0  379225088  432       9068  4908             47300608    4476       10454
2022-10-28T01:08:40Z hiroshima-01 dlp.srv.world 8812    0                2362         3126          vda3  380339200  400       6730  5125             47300608    4725       7328
2022-10-28T01:08:40Z hiroshima-01 dlp.srv.world 12      0                0            0             loop0 1106944    3         51    3                0           0          0
2022-10-28T01:08:40Z hiroshima-01 dlp.srv.world 12      0                0            0             loop2 354304     1         43    1                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
----                 ---------  ---------------- --           ------------- ----          ---------- ----------------
2022-10-28T01:08:40Z 1666917503 362548           hiroshima-01 256           dlp.srv.world 196453     913
2022-10-28T01:08:50Z 1666917503 364254           hiroshima-01 256           dlp.srv.world 197646     920
2022-10-28T01:09:00Z 1666917503 365696           hiroshima-01 256           dlp.srv.world 198548     920
2022-10-28T01:09:10Z 1666917503 367043           hiroshima-01 256           dlp.srv.world 199434     920
.....
.....

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
----                 ------    ---------  ----------------- -------- ------    ------------ ------------ --           -----  ----       --------- ---------- ----          -------------- --------------- ---------------- --------  -------- --------- ------    ----------- ------  ----     ------------ ---------- ----------- ---------  ---------- -----      ----      ------------       ------------- -------------     ------------ ---------- --------------
2022-10-28T01:08:40Z 76500992  3654725632 88.8464372485761  23785472 398647296 5063028736   650018816    hiroshima-01 450560 3398119424 0         0          dlp.srv.world 2097152        0               0                492388352 0        0         158912512 2494464     1048576 56885248 27918336     28966912   0           3006263296 3006263296 4113530880 292978688 7.122316485442307  0             14073748835531776 14225408     0          0
2022-10-28T01:08:50Z 77434880  3651424256 88.76618074640538 23830528 403968000 5063028736   650018816    hiroshima-01 577536 3391909888 0         0          dlp.srv.world 2097152        0               0                492716032 0        0         159346688 2494464     1048576 62238720 33009664     29229056   0           3006263296 3006263296 4113530880 293822464 7.142828693193134  0             14073748835531776 14274560     0          0
2022-10-28T01:09:00Z 77451264  3651457024 88.76697733699766 23855104 404025344 5063028736   650280960    hiroshima-01 94208  3391909888 0         0          dlp.srv.world 2097152        0               0                494219264 0        0         159444992 2498560     1048576 62242816 33013760     29229056   0           3006263296 3006263296 4113530880 293740544 7.1408372167124705 0             14073748835531776 14274560     0          0
2022-10-28T01:09:10Z 77475840  3650756608 88.74995021308798 23879680 404037632 5063028736   654475264    hiroshima-01 208896 3391135744 0         0          dlp.srv.world 2097152        0               0                496001024 0        0         159514624 2502656     1048576 62242816 33013760     29229056   0           3006263296 3006263296 4113530880 294477824 7.158760505038435  0             14073748835531776 14274560     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          icmp_inaddrmaskreps icmp_inaddrmasks icmp_incsumerrors icmp_indestunreachs icmp_inechoreps icmp_inechos icmp_inerrors icmp_inmsgs icmp_inparmprobs icmp_inredirects icmp_insrcquenchs icmp_intimeexcds icmp_intimestampreps icmp_intimestamps icmp_outaddrmaskreps icmp_outaddrmasks icmp_outdestunreachs icmp_outechoreps icmp_outechos icmp_outerrors icmp_outmsgs icmp_outparmprobs icmp_outredirects icmp_outsrcquenchs icmp_outtimeexcds icmp_outtimestampreps icmp_outtimestamps icmpmsg_intype3 icmpmsg_outtype3 interface ip_defaultttl ip_forwarding ip_forwdatagrams ip_fragcreates ip_fragfails ip_fragoks ip_inaddrerrors ip_indelivers ip_indiscards ip_inhdrerrors ip_inreceives ip_inunknownprotos ip_outdiscards ip_outnoroutes ip_outrequests ip_reasmfails ip_reasmoks ip_reasmreqds ip_reasmtimeout packets_recv packets_sent tcp_activeopens tcp_attemptfails tcp_currestab tcp_estabresets tcp_incsumerrors tcp_inerrs tcp_insegs tcp_maxconn tcp_outrsts tcp_outsegs tcp_passiveopens tcp_retranssegs tcp_rtoalgorithm tcp_rtomax tcp_rtomin udp_ignoredmulti udp_incsumerrors udp_indatagrams udp_inerrors udp_memerrors udp_noports udp_outdatagrams udp_rcvbuferrors udp_sndbuferrors udplite_ignoredmulti udplite_incsumerrors udplite_indatagrams udplite_inerrors udplite_memerrors udplite_noports udplite_outdatagrams udplite_rcvbuferrors udplite_sndbuferrors
----                 ---------- ---------- --           ------- -------- ------ ------- ----          ------------------- ---------------- ----------------- ------------------- --------------- ------------ ------------- ----------- ---------------- ---------------- ----------------- ---------------- -------------------- ----------------- -------------------- ----------------- -------------------- ---------------- ------------- -------------- ------------ ----------------- ----------------- ------------------ ----------------- --------------------- ------------------ --------------- ---------------- --------- ------------- ------------- ---------------- -------------- ------------ ---------- --------------- ------------- ------------- -------------- ------------- ------------------ -------------- -------------- -------------- ------------- ----------- ------------- --------------- ------------ ------------ --------------- ---------------- ------------- --------------- ---------------- ---------- ---------- ----------- ----------- ----------- ---------------- --------------- ---------------- ---------- ---------- ---------------- ---------------- --------------- ------------ ------------- ----------- ---------------- ---------------- ---------------- -------------------- -------------------- ------------------- ---------------- ----------------- --------------- -------------------- -------------------- --------------------
2022-10-28T02:06:10Z                       hiroshima-01                                 dlp.srv.world 0                   0                0                 15                  0               0            2             15          0                0                0                 0                0                    0                 0                    0                 15                   0                0             0              15           0                 0                 0                  0                 0                     0                  15              15               all       64            2             0                0              0            0          0               64367         0             0              65056         0                  0              0              48800          0             0           0             0                                         62              3                6             28              0                0          64096      -1          213         54109       38               5               1                120000     200        43               0                213             0            0             0           223              0                0                0                    0                    0                   0                0                 0               0                    0                    0
2022-10-28T02:06:10Z 335485795  11545329   hiroshima-01 2634    0        0      0       dlp.srv.world                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         enp1s0                                                                                                                                                                                                                                                                                         59697        40624                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
2022-10-28T02:06:20Z                       hiroshima-01                                 dlp.srv.world 0                   0                0                 15                  0               0            2             15          0                0                0                 0                0                    0                 0                    0                 15                   0                0             0              15           0                 0                 0                  0                 0                     0                  15              15               all       64            2             0                0              0            0          0               64388         0             0              65079         0                  0              0              48824          0             0           0             0                                         62              3                4             28              0                0          64117      -1          216         54133       38               5               1                120000     200        43               0                213             0            0             0           223              0                0                0                    0                    0                   0                0                 0               0                    0                    0
2022-10-28T02:06:20Z 335487074  11546103   hiroshima-01 2639    0        0      0       dlp.srv.world                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         enp1s0                                                                                                                                                                                                                                                                                         59715        40637                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
.....
.....

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
----                 ------- --           ---- ----          ---- ------ ------- -------- ------- ----- ------------- ------- -------
2022-10-28T01:08:40Z 0       hiroshima-01 0    dlp.srv.world 54   0      0       61       0       115   148           0       0
2022-10-28T01:08:50Z 0       hiroshima-01 0    dlp.srv.world 54   0      0       61       0       115   147           0       0
2022-10-28T01:09:00Z 0       hiroshima-01 0    dlp.srv.world 54   0      0       61       0       115   147           0       0
2022-10-28T01:09:10Z 0       hiroshima-01 0    dlp.srv.world 54   0      0       61       0       115   147           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
----                 --           ----       ----          -- --- -----      ---- ------------
2022-10-28T01:08:40Z hiroshima-01 3006263296 dlp.srv.world 0  0   3006263296 0    0
2022-10-28T01:08:50Z hiroshima-01 3006263296 dlp.srv.world 0  0   3006263296 0    0
2022-10-28T01:09:00Z hiroshima-01 3006263296 dlp.srv.world 0  0   3006263296 0    0
2022-10-28T01:09:10Z hiroshima-01 3006263296 dlp.srv.world 0  0   3006263296 0    0
.....
.....

root@dlp:~#
influx -username admin -password adminpassword -database telegraf -precision rfc3339 \
-execute 'select * from system' -ssl -unsafeSsl

name: system
time                 dc           host          load1 load15 load5 n_cpus n_users uptime uptime_format
----                 --           ----          ----- ------ ----- ------ ------- ------ -------------
2022-10-28T01:08:40Z hiroshima-01 dlp.srv.world 0.24  0.02   0.05  2      1       1817    0:30
2022-10-28T01:08:50Z hiroshima-01 dlp.srv.world 0.36  0.03   0.08  2      1       1827    0:30
2022-10-28T01:09:00Z hiroshima-01 dlp.srv.world 0.31  0.03   0.08  2      1       1837    0:30
2022-10-28T01:09:10Z hiroshima-01 dlp.srv.world 0.26  0.02   0.08  2      1       1847    0:30
.....
.....
मिलान सामग्री