Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InfluxDB-Python client not working for Telegraf v1.3.2 #2948

Closed
ghost opened this issue Jun 21, 2017 · 4 comments · Fixed by #2949
Closed

InfluxDB-Python client not working for Telegraf v1.3.2 #2948

ghost opened this issue Jun 21, 2017 · 4 comments · Fixed by #2949
Labels
bug unexpected problem or unintended behavior
Milestone

Comments

@ghost
Copy link

ghost commented Jun 21, 2017

OS: RedHat 7.2
Python: 2.7.5
InfluxDB-Python: v4.1.1 (https://github.com/influxdata/influxdb-python)
Telegraf: 1.3.2

Basically this is script that send a datapoint using the influxdb-python client to Telegraf port 8186 (HTTP)

[root@ip-***** ~]# ./test.py
InfluxDBClientError = 400: {"error":"http: bad request"}

When testing using the same script sending to Telegraf v1.2.1, it works fine without any error.

@danielnelson
Copy link
Contributor

What is in test.py? Can you also add the relevant part of your Telegraf config?

@ghost
Copy link
Author

ghost commented Jun 21, 2017

Here is the content of that script.

#!/usr/bin/python
from influxdb import InfluxDBClient, exceptions

json_body = [
  {
     "measurement": "router",
     "tags": {
         "dc": "router-private",
         "app": "testapp1",
         "bu": "example.com",
         "datacenter": "us-east-1"
     },
     "fields": {
         "router_live_percentage": 0.13
     }
  }
]

client = InfluxDBClient('telegraf.example.com', 8186, 'test')
try:
    client.write_points(json_body, time_precision = 's')
except exceptions.InfluxDBClientError as e:
    print 'InfluxDBClientError = ' + str(e)

@sebito91
Copy link
Contributor

The format of the data is different...you'll need to change your json_body to the following:

    json_body = {
        "tags": {
            "empty_tag": "",
            "none_tag": None,
            "integer_tag": 2,
            "string_tag": "hello"
            },
        "points": [
            {
                "measurement": "test",
                "fields": {
                    "string_val": "hello!",
                    "int_val": 1,
                    "float_val": 1.1,
                    "none_field": None,
                    "bool_val": True,
                    },
                "time": 1497678083000000000,
                }
            ]
        }

@danielnelson
Copy link
Contributor

I think this is actually a bug in http_listener when no timestamp is specified.

@danielnelson danielnelson added bug unexpected problem or unintended behavior and removed need more info labels Jun 22, 2017
@danielnelson danielnelson added this to the 1.3.3 milestone Jun 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants