I am using kapacitor to send alert to URL using HTTP POST. Written script is hitting on given url but it is not sending related data to any of given url.
Following is my TICK script.
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')
Following is a first post script:
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);
Following is a second post script:
<?php
$content = json_encode($_REQUEST);
echo file_put_contents("/home/mahendra/Documents/tick/highcputick.log", $content);
?>
both urls are getting emtpy data. Kapacitor version is: Kapacitor 1.3.1
Following is Kapacitor [[httppost]] config
[[httppost]]
endpoint = "NodeJs"
url = "http://localhost:1440/alert"
# headers = { Example = "node" }
# basic-auth = { username = "my-user", password = "my-pass" }