2015-05-14 29 views
0

我正在尝试在InfluxDB 0.9版中使用JSON输入点。我在浏览器上运行localhost:8083。它使我能够创建一个数据库,但是当我尝试使用JSON输入这些点时,它会发生“内部服务器错误”。我试图用Influx DB的Python API来做同样的事情。InfluxDB中使用JSON输入点时发生内部服务器错误

from influxdb import InfluxDBClient 
json_body = [ 
    { 
     "name": "cpu_load_short", 
     "tags": { 
      "host": "server01", 
      "region": "us-west" 
      }, 
     "timestamp": "2009-11-10T23:00:00Z", 
     "fields": { 
      "value":0.64 
      } 
     } 
    ] 
client = InfluxDBClient('localhost', 8086, 'root', 'mydb') 
client.create_database('mydb') 
client.write_points(json_body) 

对于clients.write_points(json_body),显示以下错误:

Traceback (most recent call last): 
    File "<pyshell#17>", line 1, in <module> 
    client.write_points(json_body) 
    File "C:\Python27\lib\site-packages\influxdb\client.py", line 364, in write_points 
    tags=tags) 
    File "C:\Python27\lib\site-packages\influxdb\client.py", line 406, in _write_points 
    expected_response_code=204 
    File "C:\Python27\lib\site-packages\influxdb\client.py", line 277, in write 
    expected_response_code=expected_response_code 
    File "C:\Python27\lib\site-packages\influxdb\client.py", line 257, in request 
    raise InfluxDBClientError(response.content, response.status_code) 
InfluxDBClientError: 500: {"error":"database is required"} 
+1

看起来像使用0.9版本的your'e,请仔细检查您是否使用0.9的文档。例如,http://influxdb.com/docs/v0.9/concepts/reading_and_writing_data.html对于JSON主体具有不同的格式。 –

+0

是的,我正在使用0.9版本 –

回答

1

必须指定数据库,并应书面点的保留策略,作为引用文档页面埃里克:

例如:

{ 
    "database": "mydb", 
    "retentionPolicy": "default", 
    "points": [ 
     { 
      "name": "cpu_load_short", 
      "tags": { 
       "host": "server01", 
       "region": "us-west" 
      }, 
      "time": "2009-11-10T23:00:00Z", 
      "fields": { 
       "value": 0.64 
      } 
     } 
    ] 
} 

如果使用这样其他人的Python API是否确定它与InfluxDB 0.9兼容?许多客户端仅与0.8.x兼容,并且这两个版本之间的API有重大改变。

+0

是的API与InfluxDB 0.9兼容。现在我收到另外一个错误:**提高InfluxDBClientError(response.content,response.status_code) influxdb.client.InfluxDBClientError:500:{“error”:“json:无法将对象解组为[] client类型的Go值。点“} **' –

相关问题