Skip to content

Export Citation

        
          
@article{fieni-2024,
TITLE = {{PowerAPI: A Python framework for building software-defined power meters}},
AUTHOR = {Fieni, Guillaume and Acero, Daniel Romero and Rust, Pierre and Rouvoy, Romain},
URL = {https://hal.science/hal-04601379},
JOURNAL = {{Journal of Open Source Software}},
PUBLISHER = {{Open Journals}},
VOLUME = {9},
NUMBER = {98},
PAGES = {6670},
YEAR = {2024},
MONTH = Jun,
DOI = {10.21105/joss.06670},
KEYWORDS = {Power ; Energy ; Toolkit ; Measurement ; Framework},
PDF = {https://hal.science/hal-04601379/file/10.21105.joss.06670-3.pdf},
HAL_ID = {hal-04601379},
HAL_VERSION = {v1},
}
          
          
              
      

Visualizing Power Consumptions on Grafana

Here it is explained how to visualize the power estimation computed by a Formula on a Grafana dashboard to obtain this kind of visualisation:

viz_by_process

This screenshot shows the visualisation of power consumption of a Web browser and tools used for monitoring (Source, Destination, Sensor, Formula)

In this tutorial, we describe how to connect a Formula to a Grafana instance by using InfluxDB 2.X as Destination. Then, we will see how to configure Grafana to visualize the power estimation computed by the Formula.

This tutorial assumes that you know how launch a Formula and a Sensor to compute power estimation and that you have an InfluxDB 2.X and a Grafana instances running on your local machine. The InfluxDB 2.X instance listen on port 8086.

Setup Grafana

docker run -d -p 3000:3000 grafana/grafana

After the launch, Grafana will be available at http://localhost:3000. On the signin page, enter admin for username and password.

Connect Grafana to the InfluxDB 2.X instance

Connect to your Grafana instance and go to the `"Data sources"`` section (in the configuration part of the side bar).

grafana_home

Click on the "Add new data source" button and select "InfluxDB". Enter:

  1. A data source Name (here we choose "InfluxDB-2"),
  2. A Query Language, i.e., InfluxQL
  3. An instance URL (http://localhost:8086)
  4. A Custom HTTP Header called Authorization with Value Token <mytoken>, where <mytoken> is the token provided by InfluxDB 2.X for your organization.
  5. A Database name, (here we choose power_consumption) that is the db value of your destination defined in your formula configuration.

Then click on the "Save & test" button. User and Password are not required as we use a token for authentification.

add_db

Visualize the power consumption on a dashboard in real-time

Go to the "Dashboard" section on the side bar and select on New > New dashboard. Then click on + Add visualisation Then select influxdb-2 as data source.

add_dashboard

Click on the query edition button (the one with a pencil on it) and write the following query on the Query field to request the power estimations from the InfluxDB 2.X measurement:

SELECT power FROM "power_consumption" GROUP BY target

Then write $tag_target on the ALIAS BY field to label each graph with the target name

add_query_by_process

To display the power consumption in real time, you can update the range of the visualisation to last 5 minutes and the refresh dashboard parameter to 5s. This parameter are on the top-right corner of the UI.

refresh