日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Kapacitor安装及使用

發布時間:2024/7/5 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Kapacitor安装及使用 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1 安裝

1.1 Tar包安裝

??(1)下載

wget https://dl.influxdata.com/kapacitor/releases/kapacitor-1.5.5_linux_amd64.tar.gz

??(2)安裝

$ tar xvfz /opt/package/kapacitor-1.5.5-static_linux_amd64.tar.gz -C /home/tigk/.local/ $ mv /home/tigk/.local/kapacitor-1.5.5-1/ /home/tigk/.local/kapacitor

??(3)可執行文件路徑為:{influxdb目錄}/kapacitor

??默認配置文件所在路徑:{influxdb目錄}/kapacitor.conf

$ mkdir /data/tigk/kapacitor/conf $ cp /home/tigk/.local/kapacitor/kapacitor.conf /data/tigk/kapacitor/conf/ $ cd /data/tigk/kapacitor/ $ mkdir data $ mkdir logs

??然后進行修改配置文件

??(4)編輯配置文件

??/data/tigk/kapacitor/conf/kapacitor.conf,定位到[[influxdb]]

$ vim /data/tigk/kapacitor/conf/kapacitor.conf data_dir = "/data/tigk/kapacitor/data" # https-certificate = "/etc/ssl/kapacitor.pem" [logging]file = "/data/tigk/kapacitor/logs/kapacitor.log" [load]dir = "/data/tigk/kapacitor/load" [replay]dir = "/data/tigk/kapacitor/replay" [task]# Where to store the tasks database# DEPRECATED: This option is not needed for new installations.# It is only used to determine the location of the task.db file# for migrating to the new `storage` service.dir = "/data/tigk/kapacitor/tasks" [storage]# Where to store the Kapacitor boltdb databaseboltdb = "/data/tigk/kapacitor/boltdb/kapacitor.db" [[influxdb]]name = "fbi-local-02"urls = ["http://localhost:8085"]

??(4)啟動服務

$ cd /home/tigk/.local/kapacitor/ $ ./kapacitord -config /data/tigk/kapacitor/conf/kapacitor.conf

??或者后臺啟動

$ nohup ./kapacitord -config /data/tigk/kapacitor/conf/kapacitor.conf &

1.2 RPM包安裝

??(1)下載

wget https://dl.influxdata.com/kapacitor/releases/kapacitor-1.5.5-1.x86_64.rpm

??(2)安裝

sudo yum localinstall kapacitor-1.5.5-1.x86_64.rpm

??(3)修改配置文件

/etc/kapacitor/kapacitor.conf

??(4)啟動服務

sudo systemctl start kapacitor

2 使用

2.1 Kapacitor 常用命令

??Kapacitor 是數據處理引擎,主要用來作為報警使用。使用TICKscript來定義任務,腳本定義了kapacitor處理的數據來源及處理過程。
??kapacitor常用命令

kapacitor list tasks –顯示所有當前kapacitor加載的腳本 kapacitor define -tick -dbrp -type –安裝腳本到kapacitor kapacitor enable –腳本監控開啟 kapacitor disable –腳本監控關閉 kapacitor show –顯示某一個腳本的執行狀態 kapacitor record -task -duration –記錄某一時間段內某腳本運行狀態(測試用) kapacitor replay kapacitor replay -recording -task –重復執行測試結果

??如果Kapacitor啟動并運行,您將看到一個空的任務列表,如下所示:

$ ./kapacitor list tasks ID Type Status Executing Databases and Retention Policies

2.2 CPU告警案例

??(1)編寫tick文件,當cpu閑置率小于70%則告警
??vi cpu_alert.tick

stream|from().measurement('cpu')|alert().crit(lambda:"usage_idle" < 70).log('/data/tigk/kapacitor/alerts/cpu_alert.log')

??(2)Kapacitor任務定義,到Kapacitor的安裝目錄下

./kapacitor define cpu_alert -type stream -tick /data/tigk/kapacitor/tick/cpu_alert.tick -dbrp telegraf.autogen

??define:定義任務名,-tpye:指定任務類型,-tick:指定腳本名,-dprp:指定數據保留策略
??(3)查詢已定義任務

$ ./kapacitor list tasks ID Type Status Executing Databases and Retention Policies cpu_alert stream disabled false ["telegraf"."autogen"]

??(4)查詢任務詳細信息

$ ./kapacitor show cpu_alert ID: cpu_alert Error: Template: Type: stream Status: disabled Executing: false Created: 05 Jul 20 20:33 CST Modified: 05 Jul 20 20:33 CST LastEnabled: 01 Jan 01 00:00 UTC Databases Retention Policies: ["telegraf"."autogen"] TICKscript: stream|from().measurement('cpu')|alert().crit(lambda: "usage_idle" < 70).log('/data/tigk/kapacitor/alerts/cpu_alert.log')DOT: digraph cpu_alert { stream0 -> from1; from1 -> alert2; }

??(5)腳本監控生效

$ ./kapacitor enable cpu_alert

??(6)腳本監控關閉

$ ./kapacitor disable cpu_alert

總結

以上是生活随笔為你收集整理的Kapacitor安装及使用的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。