OpenSearch: Use aoss servicename if OpenSearch is configured as serverless (#60344)

* Use `aoss` if opensearch is configured as `serverless`
This commit is contained in:
Sven Grossmann
2022-12-14 20:22:26 +01:00
committed by GitHub
parent 5a7f38053b
commit 386faf5958
2 changed files with 77 additions and 3 deletions
+11 -3
View File
@@ -441,7 +441,7 @@ func (s *Service) httpClientOptions(ctx context.Context, ds *datasources.DataSou
if ds.JsonData != nil && ds.JsonData.Get("sigV4Auth").MustBool(false) && setting.SigV4AuthEnabled {
opts.SigV4 = &sdkhttpclient.SigV4Config{
Service: awsServiceNamespace(ds.Type),
Service: awsServiceNamespace(ds.Type, ds.JsonData),
Region: ds.JsonData.Get("sigV4Region").MustString(),
AssumeRoleARN: ds.JsonData.Get("sigV4AssumeRoleArn").MustString(),
AuthType: ds.JsonData.Get("sigV4AuthType").MustString(),
@@ -572,10 +572,18 @@ func (s *Service) getCustomHeaders(jsonData *simplejson.Json, decryptedValues ma
return headers
}
func awsServiceNamespace(dsType string) string {
func awsServiceNamespace(dsType string, jsonData *simplejson.Json) string {
switch dsType {
case datasources.DS_ES, datasources.DS_ES_OPEN_DISTRO, datasources.DS_ES_OPENSEARCH:
case datasources.DS_ES, datasources.DS_ES_OPEN_DISTRO:
return "es"
case datasources.DS_ES_OPENSEARCH:
serverless := jsonData.Get("serverless").MustBool()
if serverless {
return "aoss"
} else {
return "es"
}
case datasources.DS_PROMETHEUS, datasources.DS_ALERTMANAGER:
return "aps"
default: