flobz / psa_car_controller

Control psa car with connected_car v4 API.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Car data on Grafana

user-e opened this issue · comments

Not an issue, just some tips on how to send the car data to a DB and then plot it on Grafana.
(Only Linux)

  1. Install InfluxDB
sudo apt-get update && sudo apt-get install influxdb
sudo systemctl unmask influxdb.service
sudo systemctl start influxdb
  1. Install telegraf for InfluxDB
sudo apt-get update && sudo apt-get install telegraf
sudo systemctl start telegraf
  1. Install Grafana
sudo apt-get install -y apt-transport-https
sudo apt-get install -y software-properties-common wget
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
sudo apt-get update
sudo apt-get install grafana
sudo systemctl enable grafana-server.service
  • Next step is to configure InfluxDB:

sudo nano /etc/influxdb/influxdb.conf

Under [http] section, edit this line:

# Determines whether HTTP endpoint is enabled.
enabled = true
# The bind address used by the HTTP service.
bind-address = ":8086"
# Determines whether user authentication is enabled over HTTP/HTTPS.
auth-enabled = false
# The default realm sent back when issuing a basic auth challenge.
# realm = "InfluxDB"
# Determines whether HTTP request logging is enabled.
log-enabled = true
  • Then, telegraf:

sudo nano /etc/telegraf/telegraf.conf

Under [agent] section edit this line:

interval = "300s"
flush_interval = "30s"

Under [[outputs.influxdb]] this line:

[[outputs.influxdb]]

urls = ["http://127.0.0.1:8086"]
database = "Corsa-e"
skip_database_creation = false

And last, under [[inputs.http]] this line:

[[inputs.http]]

urls = ["http://127.0.0.1:5000/get_vehicleinfo/YOURVINHERE"]
method = "GET"
insecure_skip_verify = true
timeout = "5s"
data_format = "json"

Reload the service:

sudo systemctl restart influxdb
sudo systemctl restart telegraf

And now log-in on Grafana: http://Your_IP:3000
The default user and password usually are "admin" / "admin"

  • Now add a new data source, InfluxDB in that case:
    g3
    g2
    g1

And then you have just to create a new panel/dashboard with the data that you want!

g5
g6

Have fun!

PS:
Feel free to correct my English

Good job!
Thanks for sharing :)

I add a link to this tutorial in the README. Thanks again.

Thankyou very much for sharing!!!!!