How can I receive data using subscription

Hi Team,

I have created a subscription in influxdb when I am inserting data in influxdb it is inserting successfully and it showing log of inserted data. and that subscription URL also called we confirmed by a log file But we are not able to read inserted data on subscription endpoint either through get or post method or request body. Please help me to get inserted data. The documentation also does not have any example or reference. Thank you.

Hi @taurej,

Can you please provide the GET / POST requests you’re attempting to perform and any response?

Hi @rawkode,

I have added an end point to influxdb subscription as http://ipaddress:4003/users/getdatadevice/write to receive inserted data if any data is inserted While I am inserting data using API or CLI, influxdb reaching the end point I have added but I could not able to get what is the data it is posting. I am using nodejs Please help me to read data. Thank you.

Hi,

So, http://ipaddress:4003/users/getdatadevice/write is a NodeJS application?

Are you able to share the code you have that isn’t working?

Hi @rawkode,
Yes this is the NodeJS application.
Below is the code where I want to read data from subscription.
I created the subscription for this URL
http://ipaddress:4003/users/getdatadevice

The following response we are getting from the test.txt log file. But actual inserted data is not logged.

{}{“host”:“34.73.96.242:4003”,“user-agent”:“InfluxDBClient”,“content-length”:“760”,“content-type”:“”,“accept-encoding”:“gzip”}undefinedundefined

router.post('/getdatadevice/write', function(req, res, next){

var str = JSON.stringify(req.body) + JSON.stringify(req.headers) + JSON.stringify(res.body) + JSON.stringify(res.headers);
    console.log(str);	
fs.writeFile("test.txt", str + '\n', function(err) {

	if(err) {
		return console.log(err);
		res.json(err)
	}
	res.status(200).json({'message':'successfully'})
}); 
});

@taurej have you been able to figure this out yet? We have the exact same problem where kapacitor works but not a direct subscription with an http endpoint.

Any pointers are much much appreciated :slight_smile: Thank you.