mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Elasticsearch: Fix setting of default maxConcurrentShardRequests (#87703)
* Elasticsearch: Fix setting of default maxConcurrentShardRequests * Add float test scenario * Add comment
This commit is contained in:
@@ -32,8 +32,10 @@ var eslog = log.New("tsdb.elasticsearch")
|
||||
const (
|
||||
// headerFromExpression is used by data sources to identify expression queries
|
||||
headerFromExpression = "X-Grafana-From-Expr"
|
||||
// headerFromAlert is used by datasources to identify alert queries
|
||||
// headerFromAlert is used by data sources to identify alert queries
|
||||
headerFromAlert = "FromAlert"
|
||||
// this is the default value for the maxConcurrentShardRequests setting - it should be in sync with the default value in the datasource config settings
|
||||
defaultMaxConcurrentShardRequests = int64(5)
|
||||
)
|
||||
|
||||
type Service struct {
|
||||
@@ -138,18 +140,23 @@ func newInstanceSettings(httpClientProvider httpclient.Provider) datasource.Inst
|
||||
index = settings.Database
|
||||
}
|
||||
|
||||
var maxConcurrentShardRequests float64
|
||||
var maxConcurrentShardRequests int64
|
||||
|
||||
switch v := jsonData["maxConcurrentShardRequests"].(type) {
|
||||
// unmarshalling from JSON will return float64 for numbers, so we need to handle that and convert to int64
|
||||
case float64:
|
||||
maxConcurrentShardRequests = v
|
||||
maxConcurrentShardRequests = int64(v)
|
||||
case string:
|
||||
maxConcurrentShardRequests, err = strconv.ParseFloat(v, 64)
|
||||
maxConcurrentShardRequests, err = strconv.ParseInt(v, 10, 64)
|
||||
if err != nil {
|
||||
maxConcurrentShardRequests = 256
|
||||
maxConcurrentShardRequests = defaultMaxConcurrentShardRequests
|
||||
}
|
||||
default:
|
||||
maxConcurrentShardRequests = 256
|
||||
maxConcurrentShardRequests = defaultMaxConcurrentShardRequests
|
||||
}
|
||||
|
||||
if maxConcurrentShardRequests <= 0 {
|
||||
maxConcurrentShardRequests = defaultMaxConcurrentShardRequests
|
||||
}
|
||||
|
||||
includeFrozen, ok := jsonData["includeFrozen"].(bool)
|
||||
@@ -168,7 +175,7 @@ func newInstanceSettings(httpClientProvider httpclient.Provider) datasource.Inst
|
||||
URL: settings.URL,
|
||||
HTTPClient: httpCli,
|
||||
Database: index,
|
||||
MaxConcurrentShardRequests: int64(maxConcurrentShardRequests),
|
||||
MaxConcurrentShardRequests: maxConcurrentShardRequests,
|
||||
ConfiguredFields: configuredFields,
|
||||
Interval: interval,
|
||||
IncludeFrozen: includeFrozen,
|
||||
|
||||
Reference in New Issue
Block a user