Notes et remarques pour une première prise en main de InfluxDB et de Grafana, en suivant le post de blog : http://hrb85-1-88-121-176-85.fbx.proxad.net/blog/201704071550/
Start the service:
$ sudo service influxdb start
Et l'interface avec python influxdb-python:
$ pip install influxdb
In [1]:
from influxdb import InfluxDBClient
In [2]:
db = InfluxDBClient(host='127.0.0.1',
port=8086,
username='root',
password='root',
database='mydb')
db.create_database('mydb')
voir l'interface web: http://127.0.0.1:8083/
Ports (doc):
The admin interface for InfluxDB runs on port 8083 and exposes web UI for the server.
By default the InfluxDB HTTP API listens on port 8086.
In [3]:
import time
import math
In [4]:
i = 0
while i<100:
data = [
{
"measurement": "math",
"tags": {
"type": "trigonemetric",
"fct": "cos"
},
"fields": {
"value": math.cos(math.radians(i))
}
},
{
"measurement": "math",
"tags": {
"type": "trigonemetric",
"fct": "sin"
},
"fields": {
"value": math.sin(math.radians(i))
}
}
]
db.write_points(data)
i = i + 1
time.sleep(0.2)
à lire en premier key concepts:
https://docs.influxdata.com/influxdb/v0.9/concepts/key_concepts/
Tag VS fields ?
"Tags are optional. You don’t need to have tags in your data structure, but it’s generally a good idea to make use of them because, unlike fields, tags are indexed. This means that queries on tags are faster and that tags are ideal for storing commonly-queried metadata."
* Both tag keys and tag values are stored as strings
install & run
le paquet officiel ne fonctionne pas (aucune icones)
Utiliser APT: http://docs.grafana.org/installation/debian/
$ sudo service grafana-server start
and go: http://127.0.0.1:3000/login
with admin/admin
In [7]:
db2 = InfluxDBClient(host='127.0.0.1',
port=8086,
username='root',
password='root',
database='mydb2')
In [10]:
db2.create_database('db2')
In [ ]: