Access Grafana features via REST API

Accessing Grafana features via REST API

You can use Basic Authentication to connect to the Logit.io Proxy and access Grafana without having to go through the Logit.io Dashboard. This can improve your user experience and allow proper integration between your company, your applications and the Logit.io service.

You have the option to connect your application directly to the Logit.io API to do a range of things such as saving dashboards, creating users, updating data sources or access Grafana straight from your computer.

This article explains how to call REST API Endpoints to access Grafana using our Logit.io proxy and connect to it using Basic Authentication.

Basic Authentication is a simple authentication method in HTTP(S) where the client includes a username and password with each request. The username and password is combined with a colon in-between as a string. You don't need to worry about how to create a basic authentication header as we have done it for you.

Each request to a REST API Endpoint must include all of the necessary information for Grafana to fulfill the request. If all the necessary information is provided the API requests return JSON output.

Use the following operations to interact with Grafana via the Logit.io Proxy.

  • GET - Fetches the data.
  • POST - Adds new data.
  • PUT - Updates the existing data.
  • PATCH - Applies partial modifications to the existing data.
  • DELETE - Removes the data.

All the details that you require in order to connect to the Logit.io proxy are found on the Profile Settings page of the Logit.io Dashboard. The Profile Settings page has a section called Proxy Settings where you will find everything that you need.

There are two ways that you can call the REST API using the Logit.io proxy. The call to our proxy needs to be in either of the following formats:

Basic Authentication header:

curl -XGET -H "Content-Type: application/json" 
-H "Authorization: Basic {basic auth header}" {endpoint to call}

Proxy Username and Password:

curl -XGET -H "Content-Type: application/json" 
-u "{proxy username}:{proxy password}" {endpoint to call}

Below are two curl request examples that show how to connect to the Logit.io Proxy. The examples use the Stack Id of a Stack that you have access to. If you need to access another of your stacks then you can simply find the Stack that you require, retrieve the stack Id from that stack and then replace it.

⚠️
You will need to update any placeholder variables with your Stack and Proxy Auth details.

Example of a curl request to access your Logit.io Grafana instance

This first method uses the Basic Auth Header:

curl -XGET -H "Content-Type: application/json" ^
-H "Authorization: ^
Basic @proxyAuthSetting.basicAuthHeader" ^
https://grafana.logit.io/s/@metrics_id/api/health

This second method uses the proxy username and password:

curl -XGET -H "Content-Type: application/json" ^
-u "@proxyAuthSetting.username:@proxyAuthSetting.password" ^
https://grafana.logit.io/s/@metrics_id/api/health

Both curl requests call the same API Endpoint. This request returns detailed information about your Grafana instance’s health.

There are many other Grafana features that can be accessed via REST API through the Logit.io Proxy. These features are explained in the Grafana docs here (opens in a new tab)