sentinl是一個免費的kibana預警與報告插件,與付費軟件X-Pack功能相似。javascript
./kibana-plugin install file:./sentinl-v6.0.1.zip
安裝完成後,要重啓kibanahtml
fuser -n tcp 5601 ps -ef | grep node kill -9 pid ./kibana &
使用包括5個步驟java
give our Watcher a name and choose an execution frequencynode
es的搜索與聚合web
validate if the results received back are worth processingexpress
語法與x-pack script condition語法相似vim
至關於過濾條件tcp
"condition": { "script": { "script": "payload.hits.total>=1" //當報警條件爲***出現的次數大於1 } } "condition": { "script": { "script": "payload.hits.hits[0]._source.responsetime > 0.01" // 檢索條件 響應時間大於 0.01秒 } }
Our data might need adjustments or post processing. Process our payload using a javascript expression/scriptide
過後處理post
Let's form a notification using the mustache templating language。
能夠採用多種方式發送通知。
How to Adapt or Post-Process data
Post Process過後的處理。
The transform script is the wild member of the family and can be used to inject simple or complex logic into the pipeline before delivery to actions using pure javascript.
From converting format types, through generating brand new payload keys and interpolating data, transform is the way up. The script expects a boolean condition to trigger actions. A false condition can be forced to stop the execution. BONUS: Transforms can be saved and used across Watchers! "transform": { "script": { "script": "payload.newvar = payload.aggs.some.values['95.0']" } }
kibana.yml
logging.verbose: true sentinl: settings: email: active: true host: smtp.exmail.qq.com ssl: false report: active: true tmp_path: /tmp/ 上面是官網的,下面是實踐已OK sentinl: settings: email: active: true user: tanyk@huawangtech.com password: Dd@2016 host: smtp.exmail.qq.com ssl: true timeout: 10000 report: active: true tmp_path: /tmp/
先測試
mailx -S smtp=<smtp-server-address> -r <from-address> -s <subject> -v <to-address> < body.txt
yum -y install sendmail yum install -y sendmail-cf /etc/init.d/sendmail start chkconfig sendmail on yum install -y mailx
vim /etc/mail.rc(optional)
set from=tanyk@mail.com set smtp=smtp.exmail.qq.com set smtp-auth-user=tanyk@mail.com set smtp-auth-password=****** set smtp-auth=login set nss-config-dir="/etc/pki/nssdb/"
test
echo "This is the message body and contains the message" | mailx -v -r "tanyk@mail.com" -s "This is the subject" -S smtp="smtp.exmail.qq.com" -S smtp-use-starttls -S smtp-auth=login -S smtp-auth-user="tanyk@mail.com" -S smtp-auth-password="******" -S ssl-verify=ignore -S nss-config-dir="/etc/pki/nssdb/" tanyk@163.com