mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* initial attempt * show query types * show query types * with formatting * with formatting * more cleanup * add feature toggle * fix build |
||
---|---|---|
.. | ||
client | ||
queryschema | ||
testdata | ||
client.go | ||
errors_test.go | ||
errors.go | ||
metrics.go | ||
parser_test.go | ||
parser.go | ||
plugins.go | ||
query.go | ||
README.md | ||
register.go |
Query service
This query service aims to replace the existing /api/ds/query.
The key differences are:
- This service has a stronger type system (not simplejson)
- Same workflow regardless if expressions exist
- 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