Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions internal/pkg/otel/translate/otelconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,15 @@ func getBeatsAuthExtensionConfig(outputCfg *config.C) (map[string]any, error) {
return nil, err
}

// proxy_url on newConfig is of type url.URL. Beatsauth extension expects it to be of string type instead
// this logic here converts url.URL to string type similar to what a user would set on filebeat config
if defaultTransportSettings.Proxy.URL != nil {
err = newConfig.SetString("proxy_url", -1, defaultTransportSettings.Proxy.URL.String())
if err != nil {
return nil, fmt.Errorf("error settingg proxy url:%w ", err)
}
}

var newMap map[string]any
err = newConfig.Unpack(&newMap)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions internal/pkg/otel/translate/otelconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ func TestGetOtelConfig(t *testing.T) {
"preset": "balanced",
"queue.mem.events": 3200,
"ssl.enabled": true,
"proxy_url": "https://example.com",
}

for _, v := range extra {
Expand All @@ -238,6 +239,7 @@ func TestGetOtelConfig(t *testing.T) {
"continue_on_error": true,
"idle_connection_timeout": "3s",
"proxy_disable": false,
"proxy_url": "https://example.com",
"ssl": map[string]interface{}{
"ca_sha256": []interface{}{},
"ca_trusted_fingerprint": "",
Expand Down
8 changes: 8 additions & 0 deletions internal/pkg/otel/translate/output_elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"encoding/base64"
"errors"
"fmt"
"net/url"
"reflect"
"strings"
"time"
Expand All @@ -20,6 +21,7 @@ import (
"github.com/elastic/beats/v7/libbeat/publisher/queue/memqueue"
"github.com/elastic/elastic-agent-libs/config"
"github.com/elastic/elastic-agent-libs/logp"
"github.com/elastic/elastic-agent-libs/transport/httpcommon"
"github.com/elastic/elastic-agent-libs/transport/tlscommon"
)

Expand Down Expand Up @@ -256,6 +258,12 @@ func cfgDecodeHookFunc() mapstructure.DecodeHookFunc {
return nil, fmt.Errorf("failed parsing TLS verification mode: %w", err)
}
return verificationMode, nil
case t == reflect.TypeOf(httpcommon.ProxyURI(url.URL{})):
proxyURL := httpcommon.ProxyURI(url.URL{})
if err := proxyURL.Unpack(data.(string)); err != nil {
return nil, fmt.Errorf("failed parsing proxy_url: %w", err)
}
return proxyURL, nil
default:
return data, nil
}
Expand Down