Influxdb: Cannot write data to influxdb via UDP 8089 port

Created on 20 May 2016  路  9Comments  路  Source: influxdata/influxdb

Hi there,
Im using InfluxDB-Client to write data to InfluxDB via UDP but can not do it successfully (HTTP is working well)
Here is my UDP configuration:
[[udp]]
enabled = true
bind-address = "localhost:8089" # the bind address
database = "example" # Name of the database that will be written to
batch-size = 1000 # will flush if this many points get buffered
batch-timeout = "1s" # will flush at least this often even if the batch-size is not reached
batch-pending = 5 # number of batches that may be pending in memory
read-buffer = 0 # UDP Read buffer size, 0 means OS default. UDP listener will fail if set above OS max.

And i netstat to check the port is listening or not, i tried many ways but the port 8089 via UDP still not listening, i think it is the problem.
I also opened the 8089 via IPtables FW:
-A INPUT -p udp -m state --state NEW -m udp --dport 8089 -j ACCEPT
[user@grafana ~]$ sudo netstat -nlp | grep infl
tcp6 0 0 :::2003 :::* LISTEN 17496/influxd
tcp6 0 0 :::8083 :::* LISTEN 17496/influxd
tcp6 0 0 :::2004 :::* LISTEN 17496/influxd
tcp6 0 0 :::8086 :::* LISTEN 17496/influxd
tcp6 0 0 :::8088 :::* LISTEN 17496/influxd
udp 0 0 127.0.0.1:8089 0.0.0.0:* 17496/influxd

All 9 comments

Any help plz?

@StevePham88 have you tried using a bind-address of :8089? I'm not sure but binding to localhost could be a problem here?

@e-dard: Yes i tried by default and here is the result
udp6 0 0 :::8089 :::* 19302/influxd

But i still can not write data to Influx via UDP. I use python from another host to write data to Influx:

--> Type python:
>>from influxdb import InfluxDBClient
>>query = 'cpu,host=server01,region=us-west value=0.64 1434055562000000000'
>>json_body = [
        {
            "measurement": "cpu_load_short_2",
            "tags": {
                "host": "server03",
                "region": "us-west2"
            },

            "fields": {
                "value": 0.88888
            }
        }
    ]
>>client = InfluxDBClient('210.245.0.159', 8089, 'root', 'root', 'example',use_udp=True)
>>client.write_points(json_body)

After enter, it returns TRUE but i think it's always TRUE because of the UDP protocol.
I check by Select query but data is not written. Plz help because i really want to use UDP, HTTP is not the right choice for my case. Thanks

@StevePham88 Seems like this might be an issue to put on the Python Client repo. I can't reproduce your issue locally with the Go client.

I notice in the Python client there is a udp_port=4444 option. Maybe you need to set that?

Same issue, i had to change udp_port parameter in my influxdb.client.InfluxDBClient#__init__ Python client code to match with /etc/influxdb/influxdb.conf [[udp]] bind-address value and it's working.

I have the same problem, but the "udp_port" config isn't my solution.
Looking into the source code of InfluxDBClient, I found "InfluxDB only supports seconds precision for udp writes". So when using the write_points() method , the param time_precision must be 's'.
That is my case ,just FYI.

@gaohaoning You saved my day! this should be mentioned in every client docs

I have to adjust the config file to 's' to make it work

Why is this still an issue 4 years later?
Had to set [[udp]] in influxdb.conf to have a precision of "s" as @yifeikong described.
Influx db version: 1.7.9
Go client: https://github.com/influxdata/influxdb1-client/

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cheribral picture cheribral  路  59Comments

mvadu picture mvadu  路  60Comments

corylanou picture corylanou  路  42Comments

phemmer picture phemmer  路  60Comments

beckettsean picture beckettsean  路  43Comments