Skip to content

guuhuu/api-grafana-datasource-plugin

 
 

Repository files navigation

Enapter API Grafana Datasource Plugin

This repo contains a Grafana datasource plugin that helps to visualize and analyze devices data from Enapter Cloud with the help of Enapter HTTP API.

Example dashboard.

Quick start

  1. Proceed to the token settings page in Enapter Cloud to issue a new API token if you do not have one.
  2. Use your Enapter API token to run the Grafana Docker image with the plugin already installed:
docker run \
	--env ENAPTER_API_TOKEN=<YOUR_ENAPTER_API_TOKEN> \
	--rm \
	--interactive \
	--tty \
	--publish 3000:3000 \
	enapter/grafana-with-enapter-api-datasource-plugin:v7.0.0
  1. Proceed to http://127.0.0.1:3000.
  2. Edit the Enapter Telemetry panel.

Usage

To visualize the device telemetry, you need to declare which data you want using YAML. A basic query looks like this:

telemetry:
  - device: YOUR_DEVICE
    attribute: YOUR_TELEMETRY

To get more info about the query language check out the Enapter Developers docs.

Installation

To use the Enapter API datasource in your existing Grafana installation you need to extract the packaged plugin into the Grafana plugins directory.

The path to the plugin directory is defined in the Grafana configuration file.

Let us assume that the path is /var/lib/grafana/plugins (the default on Linux). Then to install the plugin:

  1. Go to the Releases web page.
  2. Download the plugin distribution (dist.tar.gz).
  3. Unarchive and extract the dist dir from the downloaded file.
  4. Move the extracted dist dir to /var/lib/grafana/plugins/enapter-api/dist.

Configuration

⚠️ The plugin is at the moment unsigned. To be able to run the plugin you need to allow your Grafana installation to load it despite the lack of signature. This can be accomplished in two ways:

  1. Using the config option: allow_loading_unsigned_plugins = enapter-api
  2. Using the env var: GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=enapter-api

Once the plugin is installed and allowed to be loaded, a new datasource should be created:

  1. Use Grafana web UI to create a new datasource of type enapter-api.
  2. Make sure Enapter API URL field value is set to https://api.enapter.com (default).
  3. Set Enapter API token field value to the value of your API token.
  4. Save the changes.

Development

You will need the following tools to develop the plugin:

  • docker
  • gzip
  • jq
  • make
  • tar

To build the plugin distribution from source run:

make dist

To start a local Grafana instance with the plugin installed run:

make grafana-build grafana-run

About

Enapter API Grafana Datasource Plugin.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 87.2%
  • TypeScript 7.4%
  • Dockerfile 2.4%
  • Shell 1.3%
  • Makefile 1.1%
  • JavaScript 0.6%