Hoppa till huvudinnehåll

Grafana Setup

The platform has API-support for two Grafana Data Sources:

  1. The JSON data source. This enables API-users to host their own Grafana and view time-series data from the platform.
  2. The Infinity Data Source. This enables Grafana to use all Yggio Rest API and visualize data and also use the Grafana Alert Manager for rules.

Below you find instructions and help on how to set it up.

API-user

First, you need to make sure that you have created an Yggio-account. This account will be used to create the credentials used by the Grafana-app.

Client App

In order to use the API you need to create a client app. It's recommended to use the interactive API-documentation for this. The endpoint to use is POST /api/client-apps. Make sure to save the secret.

Installing Grafana

Currently we have support for versions 9.0.x or higher.

You can find instructions on how to install Grafana here. When installing there are some custom settings required. Below you see an example of what is required to configure in order to get it up and running. More information on how to use custom configuration in Grafana is found here.

Note that this documentation is generated for this server i.e. staging.yggio.net. If you are integrating Grafana on a different Yggio, please refer to the documentation that Yggio for a proper example.

It is required to change the following:

  • domain - to the public IP or domain name you are hosting your Grafana
  • root_url - probably the same as above with http/https
  • signout_redirect_url - the query param redirect_uri needs to be changed.
  • client_id - the client_id from when creating the client app
  • client_secret - the secret from when creating the client app
#### custom.ini ####

[server]
domain = grafana-test.your-domain.com
root_url = https://grafana-test.your-domain.com

[auth]
signout_redirect_url = https://staging.yggio.net/auth/realms/yggio/protocol/openid-connect/logout?redirect_uri=https%3A%2F%2Fgrafana-test.your-domain.com%2Flogin
token_rotation_interval_minutes = 60

[auth.generic_oauth]
enabled = true
allow_sign_up = true
name = Yggio
client_id = grafana-test-client
client_secret = abcabcabcabc-test-test-test-cbacbacbacba
auth_url = https://staging.yggio.net/auth/realms/yggio/protocol/openid-connect/auth
token_url = https://staging.yggio.net/auth/realms/yggio/protocol/openid-connect/token
api_url = https://staging.yggio.net/auth/realms/yggio/protocol/openid-connect/userinfo
scopes = openid, email, profile, offline_access

The offline_access scope ensures that once you have logged in to Grafana, a refresh token is used to automatically renew your session, so you don’t need to log in again. This makes Grafana feel like an embedded platform application.

Data Sources

Note that it's required to have admin-privileges to add and configure plugins in Grafana.

Here you can find some information on how to install plugins on Grafana.

Installation of JSON Data Source

Currently we have support for simpod-json-datasource plugin versions 0.6.x.

Here is instruction on how to install JSON data source plugin specifically.

Configuration

With the exception of two configurations, all of the options remains as default.

  • URL: <yggio rest-api URl>/api/grafana/iotnodes (e.g. https://staging.yggio.net/api/grafana/iotnodes)
  • Forward OAuth Identity: true

Installation Infinity data source

Currently we have support for yesoreyeram-infinity-datasource. The support is verified with version 3.6

Here is documentation and instruction on how to install the Infinity data source plugin specifically.

Configuration

With the exception of two configurations, all of the options remains as default.

  • Forward OAuth Identity: true
  • Allowed Host: <Platform URL> (e.g. https://staging.yggio.net)

This is how you should configure and use the Infinity Data Source

time-series

Start Graphing!

Once above steps are done it should be possible to create a dashboard and a panel with data from the platform! Go to user guide for Grafana