Sending data from Google Scripts to Influx "missing tag value"


Shot in the dark but I wonder if anyone can help.

I’m trying to figure out how to send json data from Google Scripts to Influx and am using the following code:

function testPost() {

var response;

var tags = {

var fields = {

var data = {‘measurement’:‘cpu_load_short’,‘tags’:tags,‘time’:0,‘fields’:fields};


var options = {
‘method’ : ‘post’,
‘muteHttpExceptions’ : true,
‘contentType’: ‘application/json’,
‘payload’ : JSON.stringify(data)

options = {
‘method’ : ‘post’,
‘contentType’: ‘text/plain’,
‘payload’ : ‘mymeas,mytag=blob myfield=90 1463683075000000000’

try {

response = UrlFetchApp.fetch('http://w.x.y.z:8086/write?db=mydb&u=***&p=***', options);


catch(err) {




This is what I capture from the google script:

[19-09-05 13:52:39:586 BST] {“measurement”:“cpu_load_short”,“tags”:{“testname”:“j”},“time”:0,“fields”:{“value”:1}}
[19-09-05 13:52:39:698 BST] {“error”:“unable to parse ‘{“measurement”:“cpu_load_short”,“tags”:{“testname”:“j”},“time”:0,“fields”:{“value”:1}}’: missing tag value”}

I suspect the issue is somewhere with the JSON.stringify but not entirely sure why. The error seems to indicate missing tag data despite it being provided.

Generally, it gives an error like that when the line protocol isn’t quite right and it gets confused about the formatting. I too, suspect something is happening with the stringify. I’m trying to recreate it now.