Grafana Infinity Datasource
repository·main·Indexed 21 days ago
https://github.com/grafana/grafana-infinity-datasourceA universal Grafana plugin for visualizing data from JSON, CSV, XML, GraphQL, and HTML endpoints via REST APIs. It supports flexible transformation languages, various authentication methods, and the ability to transform API responses into logs. Advanced features like Alerting, Recorded Queries, and Enterprise query caching require the use of backend parsers (JSONata or JQ). Requires Grafana version 11.6 or later.
What's inside grafana-infinity-datasource
- The Infinity data source is a universal Grafana plugin designed to pull data from various systems using existing REST APIs. It serves as a flexible alternative when a native Grafana plugin for a specific data source is unavailable. It supports multiple data formats, flexible transformation languages, and a wide range of authentication methods.
Overview of Grafana Infinity Datasource
mainThe Grafana Infinity Datasource allows you to visualize data from a wide variety of non-standard sources. It is designed to fetch and parse data from JSON, CSV, XML, GraphQL, and HTML endpoints directly within Grafana.Supported data formats in Infinity
mainThe Infinity data source supports querying and visualizing data from several different formats. Depending on your data source (REST APIs, spreadsheets, SOAP, or web scraping), you will choose one of the following formats:
- JSON: For REST APIs and modern web services.
- CSV: For spreadsheet exports and data feeds.
- XML: For SOAP APIs, RSS feeds, and legacy systems.
- GraphQL: For GraphQL endpoints.
- HTML: For web scraping and extracting data from pages without APIs.
- Azure Blob Storage: For querying data stored in Azure cloud storage.
What is Reference data in Infinity
mainReference data allows you to store small, static datasets directly within your Infinity data source configuration. This enables you to define data once (such as lookup tables, mapping codes, or static configurations) and reuse it across multiple dashboards and queries without re-entering the data manually each time.
Supported Formats:
- JSON
- CSV
- TSV
- XML
- HTML
Constraints:
- Reference data names must be unique within a single data source instance. If duplicate names are provided, the first matching entry is returned.
- Datasets should be kept under 10 MB. For larger datasets, use URL-based queries instead to avoid performance degradation.
Overview of the Infinity Query Editor
mainThe Infinity query editor is used to retrieve data from HTTP endpoints and transform it for visualization in Grafana. A query is defined by four primary components:
- Type: The source data format (e.g.,
JSON,CSV,TSV,XML,GraphQL, orHTML). - Parser: The engine used to process the data (e.g.,
JSONata,JQ,UQL, orFrontend). - Source: The origin of the data (
URL,Inline,Azure Blob, orReference). - Format: The output structure for Grafana visualizations (e.g.,
Table,Time series,Data frame,Logs,Trace, orNode graph).
- Type: The source data format (e.g.,
What is UQL (Unstructured Query Language)
mainUQL is a query language designed for transforming and manipulating data from JSON, CSV, XML, and GraphQL sources within the Infinity datasource. It uses a pipeline syntax inspired by Kusto Query Language (KQL), where data flows through a series of commands joined by the pipe operator (
|).Syntax Rules:
- Command Separation: Use the pipe symbol
|to separate commands, typically placing one command per line. - Field Names: Enclose field names in double quotes (e.g.,
"fieldName"). - String Literals: Use single quotes for string values (e.g.,
'value').
- Command Separation: Use the pipe symbol
Understand the four core choices in an Infinity query
mainEvery Infinity query is defined by four fundamental dimensions in the query editor. To build a query, you must specify:
- Type: The data format (e.g.,
JSON,CSV,XML,GraphQL,UQL,GROQ,Google Sheets). - Parser: How the data is processed (e.g.,
Frontend (simple),Backend (JSONata),Backend (JQ),UQL,GROQ). - Source: Where the data originates (e.g.,
URL,Inline,Reference,Azure Blob,Random walk). - Format: The output shape for Grafana (e.g.,
Table,Time series,Logs,Trace,Node graph,Data frame).
- Type: The data format (e.g.,
Configure Authentication Methods
mainInfinity supports multiple authentication methods depending on your API requirements:
- No authentication: For public APIs.
- Basic authentication: Sends a username and password via the
Authorization: Basic <BASE64_ENCODED_USERNAME_AND_PASSWORD>header. - Bearer token: Uses an access key (like a JWT) via the
Authorization: Bearer <API_KEY>header.- Tip: If your API requires a custom prefix instead of
Bearer, use API key authentication and set the key toAuthorization.
- Tip: If your API requires a custom prefix instead of
- API key: Sends a key-value pair via
headerorqueryparameters. - Digest authentication: Uses the RFC7616 HTTP Digest Access Authentication protocol.
- OAuth passthrough: Forwards the existing Grafana user's OAuth tokens to the API.
- OAuth 2.0 client credentials: Uses Client ID, Client Secret, and a Token URL to obtain tokens.
- OAuth 2.0 JWT: Uses an email identifier and an RSA private key/PEM file for a 2-legged JWT flow.
- Cloud-specific auth: Includes Azure authentication, Azure Blob storage (requires Storage account name and key), and AWS authentication.
What are Global Queries in Infinity?
mainGlobal queries allow you to register query definitions directly within the Infinity data source configuration. Once registered, these queries can be reused across multiple dashboards. This centralizes query management: when you update a global query definition in the data source settings, all dashboards referencing that query will reflect the changes upon reloading.
Note: Starting with Infinity plugin version 0.7.8, global queries are deprecated in favor of the Grafana panel library and will be removed in a future release.
GROQ syntax: Filtering and Projection
mainGROQ queries typically start with
*(representing all documents) and use square brackets for filtering and curly braces for projection.Select all data
Return all data without transformation:
*Filter by condition
Use square brackets
[]to filter results based on a condition:*[age >= 20]Project specific fields
Use curly braces
{}to select only specific fields from the documents:*{name, email}Combine filter and projection
You can chain both operations to filter the dataset first and then select specific fields:
*[age >= 20]{name}Understand Infinity limitations and backend requirements
mainTo use certain advanced Grafana features, you must understand the following constraints:
- Backend Parser Requirement: Features such as alerting, shared dashboards, recorded queries, and enterprise query caching are only available when using a backend parser (specifically JSONata or JQ).
- Data Size: Infinity is not intended for massive datasets. If you are inlining data, ensure the snippets are smaller than 1MB.
- Known Issues: For a list of current bugs or limitations, check the GitHub issues page.
Generate data using Random Walk
mainWhen you select Random Walk as the source, the plugin generates a time series that simulates random fluctuations. Each data point randomly increases, decreases, or stays the same compared to the previous point.
The step interval adjusts automatically based on your dashboard's time range:
Time range Step interval Less than 2 days 1 minute 2–40 days 1 hour 40 days–13 months 1 day More than 13 months 1 week