From 92658d854ea0016308b2a43a2ada29aa1f7395da Mon Sep 17 00:00:00 2001 From: ionutboangiu Date: Mon, 27 Jan 2025 20:14:54 +0200 Subject: [PATCH] Add elsCAPath opt and improve opt comments --- config/config_defaults.go | 33 +++++++++++++++++---------------- config/eescfg.go | 5 +++++ ees/elastic.go | 4 ++-- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/config/config_defaults.go b/config/config_defaults.go index 97ebab2ac..b398b98a3 100644 --- a/config/config_defaults.go +++ b/config/config_defaults.go @@ -540,21 +540,23 @@ const CGRATES_CFG_JSON = ` // Elasticsearch options - // "elsCloud":true, // whether ExportPath represents a cloud ID deployment - // "elsApiKey": "", // Base64-encoded token for authorization; if set, overrides username/password and service token. - // "elsUsername":"", // Username for HTTP Basic Authentication. - // "elsPassword":"", // Password for HTTP Basic Authentication. - // "elsServiceToken":"" // Service token for authorization; if set, overrides username/password. - // "elsCertificateFingerPrint":"" // SHA256 hex fingerprint given by Elasticsearch on first launch. - // "elsDiscoverNodesOnStart":false, // Discover nodes when initializing the client. Default: false. - // "elsDiscoverNodesInterval":"10s", // Discover nodes periodically. Default: disabled. - // "elsEnableDebugLogger":"false", // Enable the debug logging. - // "elsLogger":"", // The logger type can either be elsJson,elsColor and elsText - // "elsCompressRequestBody":false, // Enable compression on requests - // "elsCompressRequestBodyLevel":0, // Default: gzip.DefaultCompression, 9:BestCompression,-2:HuffmanOnly,1:BestSpeed - // "elsRetryOnStatus":[], // List of status codes for retry. Default: 502, 503, 504. - // "elsMaxRetries": 0, // Default: 3. - // "elsDisableRetry": false, // Default: false. + // "elsCloud": true, // if true, use cloud ID deployment + // "elsApiKey": "", // base64-encoded token for auth; overrides username/password and service token + // "elsUsername": "", // username for HTTP Basic Authentication + // "elsPassword": "", // password for HTTP Basic Authentication + // "elsServiceToken": "", // service token for auth; if set, overrides username/password + // "elsCertificateFingerPrint": "", // SHA256 hex fingerprint given by Elasticsearch on first launch + // "elsCAPath": "", // path to CA certificate + // "elsDiscoverNodesOnStart": false, // discover nodes when initializing the client + // "elsDiscoverNodesInterval": "10s", // discover nodes periodically + // "elsEnableDebugLogger": "false", // enable the debug logging + // "elsLogger": "", // logger type + // "elsCompressRequestBody": false, // enable compression on requests + // "elsCompressRequestBodyLevel": 0, // compression level <0(gzip)|9(best compression)|-2(HuffmanOnly)|1(best speed)> + // "elsRetryOnStatus": [502,503,504], // status codes for retry + // "elsMaxRetries": 3, // maximum number of retries + // "elsDisableRetry": false, // disable retry mechanism + // "elsIndex": "", // target elasticsearch index // "elsRefresh": "false", // controls when changes become searchable // "elsOpType": "index", // operation type @@ -564,7 +566,6 @@ const CGRATES_CFG_JSON = ` // "elsWaitForActiveShards": "1", // number of shard copies required before indexing (default: 1) - // SQL // "sqlMaxIdleConns": 0, // SQLMaxIdleConns // "sqlMaxOpenConns": 0, // SQLMaxOpenConns diff --git a/config/eescfg.go b/config/eescfg.go index e2216bdb2..0411884a3 100644 --- a/config/eescfg.go +++ b/config/eescfg.go @@ -169,6 +169,7 @@ type EventExporterOpts struct { ElsWaitForActiveShards *string // elasticsearch client opts + ElsCAPath *string ElsDiscoverNodesOnStart *bool ElsDiscoverNodeInterval *time.Duration ElsCloud *bool @@ -306,6 +307,9 @@ func (eeOpts *EventExporterOpts) loadFromJSONCfg(jsnCfg *EventExporterOptsJson) if jsnCfg.ElsPassword != nil { eeOpts.ElsPassword = jsnCfg.ElsPassword } + if jsnCfg.ElsCAPath != nil { + eeOpts.ElsCAPath = jsnCfg.ElsCAPath + } if jsnCfg.ElsDiscoverNodesOnStart != nil { eeOpts.ElsDiscoverNodesOnStart = jsnCfg.ElsDiscoverNodesOnStart } @@ -1052,6 +1056,7 @@ type EventExporterOptsJson struct { ElsCertificateFingerprint *string `json:"elsCertificateFingerPrint"` ElsUsername *string `json:"elsUsername"` ElsPassword *string `json:"elsPassword"` + ElsCAPath *string `json:"elsCAPath"` ElsDiscoverNodesOnStart *bool `json:"elsDiscoverNodesOnStart"` ElsDiscoverNodesInterval *string `json:"elsDiscoverNodesInterval"` ElsEnableDebugLogger *bool `json:"elsEnableDebugLogger"` diff --git a/ees/elastic.go b/ees/elastic.go index fdb12a701..a16de2fdb 100644 --- a/ees/elastic.go +++ b/ees/elastic.go @@ -74,8 +74,8 @@ func (e *ElasticEE) parseClientOpts() error { if opts.ElsAPIKey != nil { e.clientCfg.APIKey = *opts.ElsAPIKey } - if opts.CAPath != nil { - cacert, err := os.ReadFile(*opts.CAPath) + if opts.ElsCAPath != nil { + cacert, err := os.ReadFile(*opts.ElsCAPath) if err != nil { return err }