grafana/pkg/registry/apis/query
2024-11-07 21:48:29 -05:00
..
client Chore: Bump Go to 1.23.0 (#92105) 2024-08-21 11:40:42 -04:00
queryschema K8s: Move ResourceInfo from common to utils (#92924) 2024-09-04 14:53:14 +03:00
testdata chore: move DatasourceUid parsing to ruler instead (#95972) 2024-11-07 21:48:29 -05:00
client.go QueryService: Forward headers to datasource clients (#92329) 2024-08-29 12:47:38 -04:00
errors_test.go Chore: Move identity and errutil to apimachinery module (#89116) 2024-06-13 07:11:35 +03:00
errors.go ds-querier: return QDR instead of k8s error (#95184) 2024-10-23 09:58:22 -04:00
header_utils.go query: add missing x-rule headers (#95948) 2024-11-07 16:03:54 +01:00
metrics.go Init dualwriter metrics (#89003) 2024-06-14 11:01:49 +02:00
parser_test.go fix(querier): use most specific timerange available (#90540) 2024-07-17 20:22:45 +04:00
parser.go chore: move DatasourceUid parsing to ruler instead (#95972) 2024-11-07 21:48:29 -05:00
plugins.go K8s: Move ResourceInfo from common to utils (#92924) 2024-09-04 14:53:14 +03:00
query_test.go query: add missing x-rule headers (#95948) 2024-11-07 16:03:54 +01:00
query.go Query Service: Add trace ids to logs in expressions (#95203) 2024-10-24 12:01:14 -04:00
README.md QueryService: Add feature toggles to better support testing (#86493) 2024-04-19 12:26:21 +03:00
register.go APIServer: add prometheus.Registerer to every init request (#94684) 2024-10-15 07:46:08 +03:00

Query service

This query service aims to replace the existing /api/ds/query.

The key differences are:

  1. This service has a stronger type system (not simplejson)
  2. Same workflow regardless if expressions exist
  3. Datasource settings+access is managed in each datasource, not at the beginning

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 ds as Datasource<br/>Handler/Plugin
    participant db as Storage<br/>(SQL)
    participant expr as Expression<br/>Engine

    User->>api: POST Query
    api->>api: Parse queries
    api->>api: Calculate dependencies
    loop Each datasource (concurrently)
        api->>ds: QueryData
        ds->>ds: Verify user access
        ds->>db: Get settings <br> and secrets
    end
    loop Each expression
        api->>expr: Execute
    end
    api->>api: Verify ResultExpectations
    api->>User: return results