@@ -14,6 +14,7 @@ import (
1414 "github.com/go-viper/mapstructure/v2"
1515 koanfmaps "github.com/knadh/koanf/maps"
1616
17+ "github.com/elastic/elastic-agent-client/v7/pkg/client"
1718 "github.com/elastic/elastic-agent/internal/pkg/agent/application/monitoring/monitoringhelpers"
1819
1920 "github.com/elastic/elastic-agent-libs/logp"
@@ -25,7 +26,7 @@ import (
2526
2627 "github.com/elastic/beats/v7/libbeat/outputs/elasticsearch"
2728 "github.com/elastic/beats/v7/x-pack/libbeat/management"
28- "github.com/elastic/elastic-agent-client /v7/pkg/client "
29+ "github.com/elastic/beats /v7/x-pack/otel/extension/beatsauthextension "
2930 "github.com/elastic/elastic-agent-libs/config"
3031 "github.com/elastic/elastic-agent/internal/pkg/agent/application/info"
3132 "github.com/elastic/elastic-agent/internal/pkg/agent/application/paths"
@@ -649,15 +650,18 @@ func BeatDataPath(componentId string) string {
649650// getBeatsAuthExtensionConfig sets http transport settings on beatsauth
650651// currently this is only supported for elasticsearch output
651652func getBeatsAuthExtensionConfig (outputCfg * config.C ) (map [string ]any , error ) {
652- defaultTransportSettings := elasticsearch .ESDefaultTransportSettings ()
653+
654+ authSettings := beatsauthextension.BeatsAuthConfig {
655+ Transport : elasticsearch .ESDefaultTransportSettings (),
656+ }
653657
654658 var resultMap map [string ]any
655659 if err := outputCfg .Unpack (& resultMap ); err != nil {
656660 return nil , err
657661 }
658662
659663 decoder , err := mapstructure .NewDecoder (& mapstructure.DecoderConfig {
660- Result : & defaultTransportSettings ,
664+ Result : & authSettings ,
661665 TagName : "config" ,
662666 SquashTagOption : "inline" ,
663667 DecodeHook : cfgDecodeHookFunc (),
@@ -670,20 +674,27 @@ func getBeatsAuthExtensionConfig(outputCfg *config.C) (map[string]any, error) {
670674 return nil , err
671675 }
672676
673- newConfig , err := config .NewConfigFrom (defaultTransportSettings )
677+ newConfig , err := config .NewConfigFrom (authSettings )
674678 if err != nil {
675679 return nil , err
676680 }
677681
678682 // proxy_url on newConfig is of type url.URL. Beatsauth extension expects it to be of string type instead
679683 // this logic here converts url.URL to string type similar to what a user would set on filebeat config
680- if defaultTransportSettings .Proxy .URL != nil {
681- err = newConfig .SetString ("proxy_url" , - 1 , defaultTransportSettings .Proxy .URL .String ())
684+ if authSettings . Transport .Proxy .URL != nil {
685+ err = newConfig .SetString ("proxy_url" , - 1 , authSettings . Transport .Proxy .URL .String ())
682686 if err != nil {
683687 return nil , fmt .Errorf ("error settingg proxy url:%w " , err )
684688 }
685689 }
686690
691+ if authSettings .Kerberos != nil {
692+ err = newConfig .SetString ("kerberos.auth_type" , - 1 , authSettings .Kerberos .AuthType .String ())
693+ if err != nil {
694+ return nil , fmt .Errorf ("error setting kerberos auth type url:%w " , err )
695+ }
696+ }
697+
687698 var newMap map [string ]any
688699 err = newConfig .Unpack (& newMap )
689700 if err != nil {
0 commit comments