mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 10:06:24 +05:00
Add config sanity checks for elasticsearch ee
This commit is contained in:
committed by
Dan Christian Bogos
parent
2511c00db7
commit
6270885405
@@ -927,6 +927,28 @@ func (cfg *CGRConfig) checkConfigSanity() error {
|
||||
if len(exp.ContentFields()) == 0 {
|
||||
return fmt.Errorf("<%s> empty content fields for exporter with ID: %s", utils.EEs, exp.ID)
|
||||
}
|
||||
case utils.MetaElastic:
|
||||
elsOpts := exp.Opts.Els
|
||||
if elsOpts.Logger != nil {
|
||||
if !slices.Contains([]string{utils.ElsJson, utils.ElsText, utils.ElsColor}, *elsOpts.Logger) {
|
||||
return fmt.Errorf("<%s> invalid elsLogger value for exporter with ID: %s", utils.EEs, exp.ID)
|
||||
}
|
||||
}
|
||||
if elsOpts.Refresh != nil {
|
||||
if !slices.Contains([]string{"true", "false", "wait_for"}, *elsOpts.Refresh) {
|
||||
return fmt.Errorf("<%s> invalid elsRefresh value for exporter with ID: %s", utils.EEs, exp.ID)
|
||||
}
|
||||
}
|
||||
if elsOpts.OpType != nil {
|
||||
if !slices.Contains([]string{"index", "create"}, *elsOpts.OpType) {
|
||||
return fmt.Errorf("<%s> invalid elsOpType value for exporter with ID: %s", utils.EEs, exp.ID)
|
||||
}
|
||||
}
|
||||
if elsOpts.CAPath != nil {
|
||||
if _, err := os.Stat(*elsOpts.CAPath); os.IsNotExist(err) {
|
||||
return fmt.Errorf("<%s> CA certificate file not found at path: %s for exporter with ID: %s", utils.EEs, *elsOpts.CAPath, exp.ID)
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, field := range exp.Fields {
|
||||
if field.Type != utils.MetaNone && field.Path == utils.EmptyString {
|
||||
|
||||
@@ -67,10 +67,10 @@
|
||||
"export_path": "https://192.168.56.29:9200",
|
||||
"synchronous": true,
|
||||
"opts": {
|
||||
// "elsCAPath": "/path/to/http_ca.crt"
|
||||
"elsIndex": "cdrs",
|
||||
"elsUsername": "elastic",
|
||||
// "elsPassword":"",
|
||||
"elsCAPath": "/path/to/http_ca.crt"
|
||||
// "elsCloud":true,
|
||||
// "elsApiKey": "",
|
||||
// "elsServiceToken": "",
|
||||
|
||||
@@ -117,8 +117,6 @@ func (e *ElasticEE) parseClientOpts() error {
|
||||
EnableRequestBody: true,
|
||||
EnableResponseBody: true,
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("invalid logger type: %q", *loggerType)
|
||||
}
|
||||
e.clientCfg.Logger = logger
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user