grafana/pkg/registry/apis/query
beejeebus c3f34efb41 Revert "Revert: DataSource: Support config CRUD from apiservers (#106996) (#110342)"
This reverts commit 72eeefabd7.
2025-10-07 14:31:07 -04:00
..
client datasources: querier: deduplicate logging code (#111019) 2025-09-23 13:35:53 +02:00
clientapi datasources: querier: deduplicate logging code (#111019) 2025-09-23 13:35:53 +02:00
queryschema Revert "Revert: DataSource: Support config CRUD from apiservers (#106996) (#110342)" 2025-10-07 14:31:07 -04:00
testdata Query Service: Combine SSE handling in single tenant and multi tenant paths (#108041) 2025-07-17 17:22:55 -04:00
README.md Query Service: Combine SSE handling in single tenant and multi tenant paths (#108041) 2025-07-17 17:22:55 -04:00
connections.go Revert "Revert: DataSource: Support config CRUD from apiservers (#106996) (#110342)" 2025-10-07 14:31:07 -04:00
errors.go Query Service: Combine SSE handling in single tenant and multi tenant paths (#108041) 2025-07-17 17:22:55 -04:00
errors_test.go Chore: Move identity and errutil to apimachinery module (#89116) 2024-06-13 07:11:35 +03:00
header_utils.go Loki: Refactor getting of panel/dashboard title headers as part of decoupling (#106829) 2025-06-18 17:41:31 +02:00
plugins.go K8s: Move ResourceInfo from common to utils (#92924) 2024-09-04 14:53:14 +03:00
query.go datasources: querier: deduplicate logging code (#111019) 2025-09-23 13:35:53 +02:00
query_test.go datasources: querier: deduplicate logging code (#111019) 2025-09-23 13:35:53 +02:00
register.go Revert "Revert: DataSource: Support config CRUD from apiservers (#106996) (#110342)" 2025-10-07 14:31:07 -04:00

README.md

Query service

This query service aims to replace the existing /api/ds/query, while preserving the same parsing and expression handling as /api/ds/query

Current /api/ds/query workflow

sequenceDiagram
    autonumber
    actor User as User or Process
    participant api as /api/ds/query
    participant db as Storage<br/>(SQL)
    participant ds as Datasource<br/>Plugin
    participant expr as Expression<br/>Engine

    User->>api: POST Query
    loop Each query
        api->>api: Parse query
        api->>db: Get ds config<br>and secrets
        db->>api: 
    end
    alt No expressions
      alt Single datasource
          api->>ds: QueryData
      else Multiple datasources
        loop Each datasource (concurrently)
          api->>ds: QueryData
        end
        api->>api: Wait for results
      end
    else Expressions exist
        api->>expr: Calculate expressions graph
        loop Each node (eg, refID)
          alt Is query
              expr->>ds: QueryData
          else Is expression
            expr->>expr: Process
          end
        end
    end
    api->>User: return results

/apis/query.grafana.app (in single tenant grafana)

sequenceDiagram
    autonumber
    actor User as User or Process
    participant api as /apis/query.grafana.app
    participant db as Storage<br/>(CloudConfig)
    participant ds as Datasource<br/>Plugin
    participant expr as Expression<br/>Engine

    User->>api: POST Query
    loop Each query
        api->>api: Parse query
        api->>db: Get ds config<br>and secrets
        db->>api: 
    end
    alt Expressions exist
        api->>expr: Calculate expressions graph
        loop Each node (eg, refID)
          alt Is query
              expr->>ds: QueryData
          else Is expression
            expr->>expr: Process
          end
        end
    else No expressions
      alt Single datasource
          api->>ds: QueryData
      else Multiple datasources
        loop Each datasource (concurrently)
          api->>ds: QueryData
        end
        api->>api: Wait for results
      end
    end
    api->>User: return results