0

I am trying to collect Bitbucket API data as a json file and push the data to InfluxDB. I am doing this via Jenkins scripted pipeline. I am not sure how to convert my json data to points as the data will be dynamic. The script executes without any error but I am unable to see my data in InfluxDB How can I specify which measurement to use.

Code is as below

import groovy.json.*
def result

influxSRV='x.x.x.x:8086'
influxDb='dbname'
measurement = 'ms'

node('master'){
    stage('collect'){
            sh "curl -XGET -u 'xx:yy' https://x.y.z > output.json"
             result = readJSON file: 'output.json'
        sh "curl -iX POST \'http://${influxSRV}/write?db=${influxDb}&precision=ms\' --data-binary \'${measurement},${result}\'"
    }
}

But the data is not uploaded. Can anyone let me know what I am missing?

Articher
  • 29
  • 1
  • 9

1 Answers1

0

Try this:

result = readJSON file: 'output.json'

sh "curl -iX POST http://${influxSRV}/write?db=${influxDb}&precision=ms --data-binary '${measurement},${result}'"

You can then see the output of curl in the output.

MaratC
  • 6,418
  • 2
  • 20
  • 27
  • I could see the output in console but the data is not getting uploaded the measurement name specified for influxdb. Is there any other way to specify measurement name for json data. – Articher May 21 '20 at 06:11
  • Try running the full curl command manually and see if something is uploaded. If not your curl needs fixing. From what I remember, Influx does not take JSON. – MaratC May 21 '20 at 07:17