2

I am working on a stream process which can takes informations inside my MySQL database and parse them into a NoSQL database (with InfluxDB). At this point, i am able to send a NoSQL query through a HTTP Request, but only if i want to send integer value. The problem is when i want to send a string value, i can't use double quotes inside my "Text" payload, because it will close my attribut. If i use single quote around my string value, InfluxDB returns an error :

    [2018-12-28_11-07-18_302] INFO     {org.wso2.siddhi.core.stream.output.sink.LogSink} - log : Event{timestamp=1545991638301, data=[{"error":"unable to parse 'SEQTIME value=267,x_date_create={1}': invalid boolean"} ], isExpired=false} (Encoded) 

There is my code :

@sink(type='http-request',
publisher.url='http://localhost:8086/write?db=bd_sensor_values',
method='POST',
headers="'Authorization: Basic XXXXX','Content-Type: application/x-www-form-urlencoded','cache-control: no-cache','Host:localhost:8086'",
sink.id="httpRequest_id",
@map(type='text', @payload("SEQTIME value={{id}},x_date_create={{x_date_create}}")))
define stream httpRequest (id int, x_date_create string);

The problem is inside the @payload attribut, with x_date_create. I tried to encode my double quotes, but it didn't work (maybe i did it wrong ?)

Any idea ? Thank you !

Robyn.D
  • 339
  • 2
  • 20

2 Answers2

2

You can use the following way to add double quotes to your results

@payload(""" "SEQTIME value"="{{id}}","x_date_create"="{{x_date_create}}" """)))
  • It works perfectly, thank you ! I just had to modify a little because your syntax add double quote at the beginning of SEQTIME. I put this : `"""SEQTIME value="{{id}}",x_date_create="{{x_date_create}}" """` – Robyn.D Jan 02 '19 at 09:01
0

Use double quotes and escape quotes in the string. See example from InfluxDB tutorial:

weather,location=us-midwest temperature="too\"hot\"" 1465839830100400200
Jan Garaj
  • 25,598
  • 3
  • 38
  • 59
  • I already tried this. WSO2 Stream Processor gives me a syntax error. I think Siddhi doesn't understand the concept of escape.. – Robyn.D Jan 02 '19 at 08:16
  • You need to find correct syntax in used language/app, which will create a correct escaped string for InfluxDB. – Jan Garaj Jan 02 '19 at 08:27
  • Anusha Jayasundara found how to create my payload. Thank you for your time. – Robyn.D Jan 02 '19 at 09:03