C3 AI Documentation Home

Grafana API

The Grafana type provides access to the Grafana HTTP API for managing datasources and accessing Grafana features. The type mixes REST and can be configured with a base URL and authentication.

Getting Started

Create a Grafana instance by specifying a name and configuring the base URL:

JavaScript
var grafana = Grafana.forName('app');

The Grafana instance must be configured with a base URL pointing to your Grafana server. Configuration is typically stored in config/rest/Grafana/<instance-name>.json.

API Methods

Managing Datasources

Listing All Datasources

JavaScript
grafana.datasources()  // get all datasources

Getting a Datasource by ID

JavaScript
grafana.datasourceById(1)  // get datasource by numeric ID (deprecated)

Getting a Datasource by UID

JavaScript
grafana.datasourceByUid('eefqo8pco4veod')  // get datasource by UID (recommended)

See Also

Was this page helpful?