I am trying to write from Grafana to Influxdb using Flux language. The part of the code responsible for the writing is shown below, where I am trying to write to existing bucket “qpu1-ops” new “_measurement”, “tag”, two “_field” - Time and PD. First I format “data”, then write it to influxdb. Could anyone let me know if I am mixing up format? Thank you!
Hi and Welcome,
is there a tutorial your following for this? If not what language or library are you using to interact with influxdb , or is this example all in the data explorer web interface ?
Hi, I am using Data Manipulation plugin for Grafana (Data Manipulation plugin for Grafana | Grafana Labs), with JavaScript as the language. I am trying to follow some tutorials from the website of this plugin as well as general information on communication with influxdb. But unfortunately the information is sparse and I have to guess a lot.
Thank you so much @scott . It is writing now to the database. Now the question - how do I pass variable into the _value field? it gives me errors when i put in variable names declared in JavaScript part of the code (outside Flux block). I also tried to pass on current time using now(), and it also gives me an error.
What does your JS code look like? Without seeing it, the guidance I would offer is structuring the Flux query string as a template literal and interpolate your JS variables into the Flux template. For example:
Can you elaborate on why? I just re-read your code and noticed you don’t appear to be using the native time columns, but your own. Do you need to know a time delta between source and the time the observation was written into influxdb or something?
If you just need timestamps displayed in your local time zone, influxdb (or JavaScript) can do that pretty easily. And probably halve the storage footprint and increase the performance of queries too.