Coder Social home page Coder Social logo

thinkbigeg / influxdb-grafana-gke Goto Github PK

View Code? Open in Web Editor NEW
10.0 5.0 1.0 468 KB

In this tutorial we explain how to get real time analytics of energy produced and consumed from two solar stations simulators using influxDB together with grafana hosted on the kubernetes engine of google

Python 100.00%
kubernetes influxdb grafana grafana-influxdb python iot big-data big-data-analytics google-cloud-platform google-kubernetes-engine

influxdb-grafana-gke's Introduction

InfluxDB with Grafana on Google Kubernetes Engine by N|Solid

In this tutorial we explain how to get real time analytics of energy produced and consumed from two solar stations simulators using influxDB together with grafana hosted on the kubernetes engine of google

Prerequisites

  • Google Cloud Project linked to a billing account
  • Python

1. Create a kubernetes cluster on GCP

  • From the side menu choose Kubernetes Engine --> clusters
  • Click on Create Cluster button

image

  • Choose your first cluster option
  • Modify the number of nodes to 2 and the machine type to 1 vCPU

image

  • Click create
  • Wait few minutes until your cluster is up and running

2. Connect to the cluster using Cloud Shell

  • Click on the connect button

image

  • Choose Run in Cloud shell

image

  • Wait until the cloud shell is connected and execute the already written command

3. Cloning the repository on the cloud shell

  • Run the following commands
git clone "https://github.com/ThinkBigEg/influxDB-grafana-gke"
cd influxDB-grafana-gke/configs/

4. Running the kubernetes config files

  • Now we want to open the pods and services of influxDB and grafana
  • Run the following commands
kubectl create -f pv-claim.yaml
kubectl create -f influxdb.yaml
kubectl create -f grafana.yaml
kubectl create -f influxdb-internal-service.yaml
kubectl create -f influxdb-external-service.yaml
kubectl create -f grafana-service.yaml
  • Open Workloads in the side menu to check that the status of grafana and influxDB in OK

image

  • Open Storage in the side menu to check that the phase of the persistent volume claim is Bound

image

  • Open Services in the side menu refresh until all the services are OK

5. Create a database in influxDB

  • SSH with influxDB container
# Get the name of the influxdb container
kubectl get pods

image

# Replace <NAME OF THE CONTAINER>
kubectl exec -it <NAME OF THE CONTAINER> influx
  • Create solar_db database
create database solar_db
  • Exit the container
exit

6. Running the two sensor simulators

  • Clone the repository on your local machine
git clone "https://github.com/ThinkBigEg/influxDB-grafana-gke"
cd python
  • From the cloud shell run :
kubectl get services influxdb-external-service
  • Copy the External ip and modify the two python files in repository on you local machine by replacing by the External ip that you copied

    INFLUXDB_HOST = '<EXTERNAL IP>'
  • Install influxdb module

    pip install influxdb
  • Executing the two python files open two terminals in python folder

    • In the 1st terminal run
    python producer_sensor.py
    • In the 2nd terminal run
    python consumer_sensor.py

Now the sensors are sending data to influxDB in the solar_db database

NOTE:

At this point you can modify the python code the get the data from Real Sensors and send it to influxDB instead of generating random values

7. Adding a dashboard on Grafana for real-time analytics

  • In Kubernetes Engine side menu click on Services
  • Click on the url in grafana-external-service row under the endpoint column
    • Username: admin
    • Password: admin
  • Click Add Datasource

image

  • Enter the url http://:8086

    • To get cluster ip
      • From the cloud shell run :
    kubectl get services influxdb-external-service
  • Enter a name

  • Enter Database : solar_db

image

  • Click save and test
  • then click back
  • On the side menu Click Dashboards --> Manage
  • Click on import

image

  • Now on the repository on your local machine go to the dashboard folder and copy the content of the json file
  • Paste it on Or paste json field

image

  • Click load

image

  • Select solar and then click import

Congrats You should be finished

image

influxdb-grafana-gke's People

Contributors

husseinkk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

balipeace

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.