mirror of
https://github.com/grafana/grafana.git
synced 2025-08-03 06:22:13 +08:00

* ds-querier: handle execute errors better * fix: change how GetResponseCode works to return 418 if rsp is nil 418 is a bit of an easter egg which in this case works since we don't have an rsp but we do know something went wrong, so a 200 won't work. Also changed this to return the code in the frame, not sure why we weren't. * tests: fix GetResponseCode tests * log no rsp case * bring back og error log
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