Query Caching: Add per-panel query caching TTL (#61968)
* *Create Caching Config interface and OSS impl
*Create front-end facing DS Cache config
*Populate Caching Config on Datasource DTO
*Update OSS wire deps
* fix unit test
* handle query caching TTL override on the frontend
* Make sure the override works with pubdash
* move caching config to the right place in the ds info
* move caching config logic to enterprise index hook
* move queryCachingTTL to pubdash query payload
* Remove from metadata (not needed)
* rename struct and add comment
* remove invalid wire dependency
* manual revert of 395c74b
* fix frontend test
* fix backend test
* fix tests for real this time
* truly fix frontend test
* fix back end unit test for real
This commit is contained in:
@@ -259,8 +259,7 @@ func ProvideHTTPServer(opts ServerOptions, cfg *setting.Cfg, routeRegister routi
|
||||
accesscontrolService accesscontrol.Service, dashboardThumbsService thumbs.DashboardThumbService, navTreeService navtree.Service,
|
||||
annotationRepo annotations.Repository, tagService tag.Service, searchv2HTTPService searchV2.SearchHTTPService,
|
||||
queryLibraryHTTPService querylibrary.HTTPService, queryLibraryService querylibrary.Service, oauthTokenService oauthtoken.OAuthTokenService,
|
||||
statsService stats.Service, authnService authn.Service,
|
||||
pluginsCDNService *pluginscdn.Service,
|
||||
statsService stats.Service, authnService authn.Service, pluginsCDNService *pluginscdn.Service,
|
||||
k8saccess k8saccess.K8SAccess, // required so that the router is registered
|
||||
starApi *starApi.API,
|
||||
) (*HTTPServer, error) {
|
||||
|
||||
@@ -226,6 +226,9 @@ type DataSourceDTO struct {
|
||||
BasicAuth string `json:"basicAuth,omitempty"`
|
||||
WithCredentials bool `json:"withCredentials,omitempty"`
|
||||
|
||||
// This is populated by an Enterprise hook
|
||||
CachingConfig QueryCachingConfig `json:"cachingConfig,omitempty"`
|
||||
|
||||
// InfluxDB
|
||||
Username string `json:"username,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
@@ -288,3 +291,8 @@ type Permission struct {
|
||||
Action string `json:"action"`
|
||||
Scope string `json:"scope"`
|
||||
}
|
||||
|
||||
type QueryCachingConfig struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
TTLMS int64 `json:"TTLMs"`
|
||||
}
|
||||
|
||||
@@ -123,9 +123,10 @@ type SavePublicDashboardDTO struct {
|
||||
}
|
||||
|
||||
type PublicDashboardQueryDTO struct {
|
||||
IntervalMs int64
|
||||
MaxDataPoints int64
|
||||
TimeRange TimeSettings
|
||||
IntervalMs int64
|
||||
MaxDataPoints int64
|
||||
QueryCachingTTL int64
|
||||
TimeRange TimeSettings
|
||||
}
|
||||
|
||||
type AnnotationsQueryDTO struct {
|
||||
|
||||
@@ -164,6 +164,7 @@ func (pd *PublicDashboardServiceImpl) buildMetricRequest(ctx context.Context, da
|
||||
for i := range queries {
|
||||
queries[i].Set("intervalMs", safeInterval)
|
||||
queries[i].Set("maxDataPoints", safeResolution)
|
||||
queries[i].Set("queryCachingTTL", reqDTO.QueryCachingTTL)
|
||||
}
|
||||
|
||||
return dtos.MetricRequest{
|
||||
|
||||
@@ -888,9 +888,10 @@ func TestBuildMetricRequest(t *testing.T) {
|
||||
"type": "mysql",
|
||||
"uid": "ds1",
|
||||
},
|
||||
"intervalMs": int64(10000000),
|
||||
"maxDataPoints": int64(200),
|
||||
"refId": "A",
|
||||
"intervalMs": int64(10000000),
|
||||
"maxDataPoints": int64(200),
|
||||
"queryCachingTTL": int64(0),
|
||||
"refId": "A",
|
||||
}),
|
||||
reqDTO.Queries[0],
|
||||
)
|
||||
@@ -902,9 +903,10 @@ func TestBuildMetricRequest(t *testing.T) {
|
||||
"type": "prometheus",
|
||||
"uid": "ds2",
|
||||
},
|
||||
"intervalMs": int64(10000000),
|
||||
"maxDataPoints": int64(200),
|
||||
"refId": "B",
|
||||
"intervalMs": int64(10000000),
|
||||
"maxDataPoints": int64(200),
|
||||
"queryCachingTTL": int64(0),
|
||||
"refId": "B",
|
||||
}),
|
||||
reqDTO.Queries[1],
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user