kairosdb - Kairos DB POST Query in Python -


i trying post query in python data kairosdb: meterreading metric created.

import urllib import urllib2  url = 'http://localhost:8080/api/v1/datapoints/query' values = {     "start_absolute": "1430454600",         "end_relative": { "value": "5",     "unit": "days"         },             "metrics": [                         {                         "tags": {                         "phase": [                                   "769"                                   ],                         "uom": [                                 "72"                                 ]                         },                         "name": "materreadings",                         "aggregators": [                                         {                                         "name": "sum",                                         "sampling": {                                         "value": "10",                                         "unit": "minutes"                                         }                                         }                                         ]                         }                         ] }  data = urllib.urlencode(values) req = urllib2.request(url, data) response = urllib2.urlopen(req) // line giving errors the_page = response.read() print(the_page) 

i getting following result while executing script:

python abc.py traceback (most recent call last):   file "abc.py", line 37, in <module>     response = urllib2.urlopen(req)   file "/system/library/frameworks/python.framework/versions/2.7/lib/python2.7/urllib2.py", line 127, in urlopen     return _opener.open(url, data, timeout)   file "/system/library/frameworks/python.framework/versions/2.7/lib/python2.7/urllib2.py", line 404, in open     response = self._open(req, data)   file "/system/library/frameworks/python.framework/versions/2.7/lib/python2.7/urllib2.py", line 422, in _open     '_open', req)   file "/system/library/frameworks/python.framework/versions/2.7/lib/python2.7/urllib2.py", line 382, in _call_chain     result = func(*args)   file "/system/library/frameworks/python.framework/versions/2.7/lib/python2.7/urllib2.py", line 1214, in http_open     return self.do_open(httplib.httpconnection, req)   file "/system/library/frameworks/python.framework/versions/2.7/lib/python2.7/urllib2.py", line 1184, in do_open     raise urlerror(err) urllib2.urlerror: <urlopen error [errno 61] connection refused> 

it seems problem in line 37, when try response sending request. able perform in java in python stuck. missing something.

i have no experience python client (btw there's python kairosdb library - never used exists here: https://github.com/pcn/pykairosdb).

but think know what's wrong: try url = 'http://localhost:8080/api/v1/datapoints/query/' (note trailing slash) using urlencode on query json payload, don't tink need ( urlencode used encode special characters using in urls method).

btw query bit strange absolute start small -i think entered unix seconds rather milliseconds- , relative end 5 days ago... mean - asking data 17th of january 1970 5 days ago?

may ask king of data have? see have tags numbered values, kairosdb format doesn't play tags may have many values (maybe it's id of origin of data, long don't have thousands or millions of them you'll ok).

i hope helps.


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -