Grafana Infinity Datasource

repository·main·Indexed 21 days ago

https://github.com/grafana/grafana-infinity-datasource

A 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.

Tokens
60.8K
Snippets
134
Records
323
Agent score
75%

What's inside grafana-infinity-datasource

  1. Overview of the Infinity data source plugin

    main
    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.
  2. Supported data formats in Infinity

    main

    The 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.
  3. What is Reference data in Infinity

    main

    Reference 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.
  4. Overview of the Infinity Query Editor

    main

    The 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, or HTML).
    • Parser: The engine used to process the data (e.g., JSONata, JQ, UQL, or Frontend).
    • Source: The origin of the data (URL, Inline, Azure Blob, or Reference).
    • Format: The output structure for Grafana visualizations (e.g., Table, Time series, Data frame, Logs, Trace, or Node graph).
  5. What is UQL (Unstructured Query Language)

    main

    UQL 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').
  6. Understand the four core choices in an Infinity query

    main

    Every Infinity query is defined by four fundamental dimensions in the query editor. To build a query, you must specify:

    1. Type: The data format (e.g., JSON, CSV, XML, GraphQL, UQL, GROQ, Google Sheets).
    2. Parser: How the data is processed (e.g., Frontend (simple), Backend (JSONata), Backend (JQ), UQL, GROQ).
    3. Source: Where the data originates (e.g., URL, Inline, Reference, Azure Blob, Random walk).
    4. Format: The output shape for Grafana (e.g., Table, Time series, Logs, Trace, Node graph, Data frame).
  7. Configure Authentication Methods

    main

    Infinity 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 to Authorization.
    • API key: Sends a key-value pair via header or query parameters.
    • 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.
  8. What are Global Queries in Infinity?

    main

    Global 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.

  9. GROQ syntax: Filtering and Projection

    main

    GROQ 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}
  10. Understand Infinity limitations and backend requirements

    main

    To 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.
  11. Generate data using Random Walk

    main

    When 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 rangeStep interval
    Less than 2 days1 minute
    2–40 days1 hour
    40 days–13 months1 day
    More than 13 months1 week