The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/pkg/registry/apis/query
Sam Jewell 4aa7d67edd
Server-side expressions: Improve error message (#103968)
3 months ago
..
client datasources: querier: st: handle data-source-not-found (#103697) 3 months ago
clientapi datasources: querier: adjust the query-client (#99805) 6 months ago
queryschema K8s: Move ResourceInfo from common to utils (#92924) 11 months ago
testdata chore: move DatasourceUid parsing to ruler instead (#95972) 8 months ago
README.md QueryService: Add feature toggles to better support testing (#86493) 1 year ago
client.go datasources: querier: adjust the query-client (#99805) 6 months ago
errors.go Server-side expressions: Improve error message (#103968) 3 months ago
errors_test.go Chore: Move identity and errutil to apimachinery module (#89116) 1 year ago
header_utils.go query: add missing x-rule headers (#95948) 9 months ago
parser.go SQL Expressions: Query Service Support (#101955) 4 months ago
parser_test.go SQL Expressions: Query Service Support (#101955) 4 months ago
plugins.go K8s: Move ResourceInfo from common to utils (#92924) 11 months ago
query.go SQL Expression: Add instrumentation for sql expressions (#103758) 3 months ago
query_test.go datasources: querier: adjust the query-client (#99805) 6 months ago
register.go SQL Expression: Add instrumentation for sql expressions (#103758) 3 months ago

README.md

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