6

I've used influxDB for a while now, but never had to continuously stream data from it. A simple GET /query was sufficient. But now I need a way to stream data to the frontend to draw pretty graphs and such.

So far we've been running GET /query periodically from the frontend, but this is highly inefficient. I would much rather get keep the connection open and receive the data when it's written to the DB. Searching the interwebs there doesn't seem to be support neither for websockets, nor for HTTP/2 in influxDB right now.

So, question to others, who possibly hit this issue - how did you solve this?

pinkstone
  • 111
  • 2
  • 10

1 Answers1

2

InfluxDB v1.x supports subscriptions. As data is written to InfluxDB, writes are duplicated to subscriber endpoints via HTTP, HTTPS, or UDP in line protocol.

https://docs.influxdata.com/influxdb/v1.7/administration/subscription-management/

Juliën
  • 9,047
  • 7
  • 49
  • 80
Shashank V
  • 10,007
  • 2
  • 25
  • 41
  • Thanks Shashank for the suggestion. I did look into this, but the issue with this is that it seems to be there for Kapacitor-like services that is basically co-located with the DB. There are no measurement filters there. I don't know how this is useful in monitoring any specific measurement, not the whole DB – pinkstone Jan 17 '20 at 23:38
  • 1
    Yeah you can subscribe only to ""."". Let me know if you find any way to do this per measurement. I think one way is subscribe to all data and filter out the measurement you want. Or install kapacitor and let kapacitor do the same. Looks like kapacitor supports streaming from a measurement. - https://docs.influxdata.com/kapacitor/v1.5/introduction/getting-started/#triggering-alerts-from-stream-data – Shashank V Jan 21 '20 at 16:28
  • Ok, that's useful. I wanted to avoid deploying another service(another bit to maintain), but I think I should stop being lazy and just deploy kapacitor as well. Thanks for the suggestion. – pinkstone Jan 22 '20 at 18:31
  • 1
    Important info is that subscriptions are available only for InfluxDB v1.x.; version 2.x and higher **do not** support it. At least not yet. As written [in the docs](https://docs.influxdata.com/influxdb/v2.1/tools/kapacitor/#disable-influxdb-subscriptions): "InfluxDB Cloud and InfluxDB OSS 2.1 do not have subscription APIs and do not support Kapacitor stream tasks". – Juliën Dec 27 '21 at 13:59