Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

influxdb python: 404 page not found

I am trying to use the influxdb-python lib which I found here. But I cant even get the tutorial programm to work.

When I run the following example code:

$ python

>>> from influxdb import InfluxDBClient

>>> json_body = [
    {
        "measurement": "cpu_load_short",
        "tags": {
            "host": "server01",
            "region": "us-west"
        },
        "time": "2009-11-10T23:00:00Z",
        "fields": {
            "value": 0.64
        }
    }
]

>>> client = InfluxDBClient('localhost', 8086, 'root', 'root', 'example')

>>> client.create_database('example')

I get this error message with the last line:

>>> client.create_database('example')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/influxdb/client.py", line 318, in create_database
    status_code=201
  File "/usr/lib/python2.7/dist-packages/influxdb/client.py", line 124, in request
    raise InfluxDBClientError(response.content, response.status_code)
influxdb.client.InfluxDBClientError: 404: 404 page not found

My installed version:

pi@raspberrypi:~ $ influx
Visit https://enterprise.influxdata.com to register for updates, InfluxDB server management, and monitoring.
Connected to http://localhost:8086 version 0.9.6.1
InfluxDB shell 0.9.6.1

It would be really nice if somebody can point me to my probleme here.

UPDATE

Maybe this is helpful. I am on a Raspberry Pi 3 with Jessie and installed influxdb with this tuturial link

UPDATE 2

if I run curl http://localhost:8086 I also get 404 page not found. On the Port 8083 i get a response.

like image 825
IIIIIIIIIIIIIIIIIIIIII Avatar asked Apr 25 '16 17:04

IIIIIIIIIIIIIIIIIIIIII


2 Answers

I couldn't post a comment since I don't have the reputation.

I found the same issue with a raspberry PI and v0.12.2. If you go to https://docs.influxdata.com/influxdb/v0.12/guides/writing_data/ there is this command

curl -G http://localhost:8086/query --data-urlencode "q=CREATE DATABASE mydb"

It worked for me.

UPDATE 1

I don't think you've installed the Python InfluxDB driver correctly. Follow the steps on the InfluxDB-Python page. Specifically be sure to run the following commands as sudo.

pip install influxdb

pip install --upgrade influxdb

like image 66
sdbol Avatar answered Oct 16 '22 10:10

sdbol


I have Influxdb running on a Raspberry Pi2.

InfluxDB shell 0.12.1 is the version I have. You are running 0.9.6.1 which could be outdated, but nevertheless still be the latest one available in the repo you use.

Your ports seem correct, a quick netstat shows:

tcp6       0      0 :::8083                 :::*                    LISTEN      17740/influxd   
tcp6       0      0 :::8086                 :::*                    LISTEN      17740/influxd   
tcp6       0      0 :::8088                 :::*                    LISTEN      17740/influxd   

To test it, I used the same example script as you did, with a slight change:

#!/usr/bin/python

import random
from datetime import datetime

from influxdb import InfluxDBClient


query = 'select value from wetter;'
client = InfluxDBClient(host='127.0.0.1', database='wetter')
print(client)

current_time = datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ')
json_body = [
    {
        "measurement": "temperature",
        "tags": {
            "host": "192.168.0.82",
            "location": "room"
        },
        "time": current_time,
        "fields": {
            "value": random.random()
        }
    }
]
print(json_body)

client.write_points(json_body)

I then start the script with while true; do ./influxdb-test.py; sleep 2; done which will insert a new entry every 2 seconds.

> select * from temperature

1462865736000000000 192.168.0.82    room    0.116745414817
1462866059000000000 192.168.0.82    room    0.576278097718
1462866062000000000 192.168.0.82    room    0.731955354635
1462866065000000000 192.168.0.82    room    0.536106447983
1462866068000000000 192.168.0.82    room    0.965246396917
1462866070000000000 192.168.0.82    room    0.785592521739
like image 45
fsp Avatar answered Oct 16 '22 08:10

fsp