Skip to main content

Visualize with Grafana Cloud

Introduction

DoiT Cloud Analytics allows you to build advanced cloud expenditure reports and share them with your team.

Grafana is a multi-platform open source analytics and monitoring solution. It supports popular time-series data sources such as Prometheus, InfluxDB, Graphite, Elasticsearch, and more.

If you're using Grafana for monitoring your environments, adding cloud cost analytics will give you a single pane of glass that presents events, cloud costs, and alerts.

This article will walk you through the process to integrate Grafana with DoiT Cloud Analytics using DoiT Reports API.

Prerequisites

This integration uses Infinity plugin for Grafana to visualize data returned by DoiT Reports API.

Make sure to complete the following tasks before starting the integration:

  1. Choose your preferred way to install the Infinity plugin into your grafana instance.

  2. Follow the instructions at DoiT Developer Hub to extract your API key for the CMP.

Set the API key in Grafana

Set the API key in the designated Grafana dashboard by updating the cmp_api_key variable.

Set the value of the variable to "Bearer " (note the trailing space) followed by the API key itself.

Add a new panel

Add a new panel to your Grafana dashboard:

  1. Select Infinity as your data source.

  2. Configure the panel using the following settings:

  • Type: UQL
  • Source: URL
  • Format: Time Series
  • URL: This is your Cloud Analytics Report URL. You'd typically use it with the reports.get().

Example API response

Below is an example response of a reports.get() request (part of the response has been removed for the sake of brevity).

{
"id": "ViSpueEq1iXNMcL1n6Un",
"reportName": "Historical Costs \u0026 Forecast",
"owner": "doit-intl.com",
"type": "preset",
"lastModified": 1650784850000,
"result": {
"schema": [
{
"name": "cloud_provider",
"type": "string"
},
{
"name": "year",
"type": "string"
},
{
"name": "month",
"type": "string"
},
{
"name": "cost",
"type": "float"
},
{
"name": "timestamp",
"type": "timestamp"
}
],
"rows": [
["amazon-web-services", "2021", "09", 55310.393988303855, 1630454400],
["amazon-web-services", "2021", "10", 62679.49002501223, 1633046400],
["amazon-web-services", "2021", "11", 61440.5163618053, 1635724800],
["google-cloud", "2021", "09", 179607.01937488918, 1630454400],
["google-cloud", "2021", "10", 193423.20843557827, 1633046400],
["google-cloud", "2021", "11", 198588.25356521425, 1635724800],
["google-cloud", "2021", "12", 212984.54926410597, 1638316800]
]
}
}

The result part of the JSON consists of two objects:

  • schema: This is the metadata about the data structure.

  • rows: This is the data itself.

The example uses the following UQL to help Grafana parse the schema of the report:

parse-json
| scope "result"
| scope "rows"
| project "cloud"="0", "cost"="3", "ts"=unixtime_seconds_todatetime("4")
see also

The UQL is an opinionated query language designed for in-memory operations. UQL query can be formed with a list of commands joined by | (pipe), each in a separate line. Fields are often referred to within double quotes, and string values are referred to with single quotes. See UQL syntax for details.

Select a visualization type

Select the desired visualization for your report (along with other panel parameters you prefer).

Once you're ready, you should be able to see your Cloud Analytics report in Grafana.

see also

Grafana documentation: About Grafana dashboards.