0

Hi I have created a subscription (http) in the InfluxDB using following command :

CREATE SUBSCRIPTION "test-data-update" ON "system_managment"."system_managment2d" DESTINATIONS ALL 'http://localhost:9001/ts/data-update'

And in the ExpressJs app which is running on port 9001 added a route as follows:

app.post("/ts/data-update/write", (req, res) => {
    console.log(">>influx data>>");
    console.log(req.body);
    res.sendStatus(200);
});

I thought I will be getting all the data in the req.body but I am getting nothing in body. How can I get the data through a subscription as mentioned in the influxdb documentation.

I have seen more examples which is using Kapacitor, but as of now we are not planning to us Kapacitor.

Let me know how to get the updated data from InfluxDB subscription endpoint? Or is it supposed to be like this and we have make normal querying to InfluxDB from this endpoint to get data?

Dipak
  • 6,532
  • 8
  • 63
  • 87

1 Answers1

0

Had same issue and the solution is to listen to data event using request object.

app.post("/ts/data-update/write",(req, res) => {
  logger.info('influx data>>');
  logger.info(req.headers);
  logger.info(req.body);
  req.on('data', (chunk) => {
    console.log(chunk.toString());
  });
  req.on('end', () => {
    res.sendStatus(200);
  });
});
  • Saw header with content length with positive non zero value and did not have value in the request body using express.
  • Then I listened using netcat on specified port in subscription which hosts a TCP server and had the content at the end.