Mah*_*dra 5 influxdb kapacitor telegraf
我正在使用kapacitor使用HTTP POST将警报发送到URL。写入的脚本在给定的URL上命中,但未将相关数据发送到任何给定的URL。
以下是我的TICK脚本。
stream
|from()
.measurement('cpu')
|alert()
.id('kapacitor/{{ index .Tags "host"}}')
.message('{{ .ID }} is {{ .Level }} value:{{ index .Fields "value" }}')
.info(lambda: TRUE)
.post('http://localhost:1440/alert')
.post('http://localhost/test.php')
Run Code Online (Sandbox Code Playgroud)
以下是第一个帖子脚本:
var express = require("express");
var app = express();
var moment = require("moment");
var dateTime = moment();
var bodyParser = require("body-parser");
var urlencodedParser = bodyParser.urlencoded({extended:false});
var jsonParser = bodyParser.json();
var port = 1440;
app.post('/alert', jsonParser ,function(request, response){
console.log(request.body);
response.send();
});
app.listen(port);
console.log('Express App.js listening to port '+port);
Run Code Online (Sandbox Code Playgroud)
以下是第二个帖子脚本:
<?php
$content = json_encode($_REQUEST);
echo file_put_contents("/home/mahendra/Documents/tick/highcputick.log", $content);
?>
Run Code Online (Sandbox Code Playgroud)
这两个网址都获取了空数据。Kapacitor版本为:Kapacitor 1.3.1
以下是Kapacitor [[httppost]]配置
[[httppost]]
endpoint = "NodeJs"
url = "http://localhost:1440/alert"
# headers = { Example = "node" }
# basic-auth = { username = "my-user", password = "my-pass" }
Run Code Online (Sandbox Code Playgroud)