diff --git a/config/config_defaults.go b/config/config_defaults.go index 1bd575fcf..b584a16d6 100755 --- a/config/config_defaults.go +++ b/config/config_defaults.go @@ -317,17 +317,17 @@ const CGRATES_CFG_JSON = ` "filters": [], // limit parsing based on the filters "flags": [], // flags to influence the event processing "fields":[ // import fields template, tag will match internally CDR field, in case of .csv value will be represented by index of the field value - {"tag": "ToR", "path": "ToR", "type": "*variable", "value": "~*req.2", "mandatory": true}, - {"tag": "OriginID", "path": "OriginID", "type": "*variable", "value": "~*req.3", "mandatory": true}, - {"tag": "RequestType", "path": "RequestType", "type": "*variable", "value": "~*req.4", "mandatory": true}, - {"tag": "Tenant", "path": "Tenant", "type": "*variable", "value": "~*req.6", "mandatory": true}, - {"tag": "Category", "path": "Category", "type": "*variable", "value": "~*req.7", "mandatory": true}, - {"tag": "Account", "path": "Account", "type": "*variable", "value": "~*req.8", "mandatory": true}, - {"tag": "Subject", "path": "Subject", "type": "*variable", "value": "~*req.9", "mandatory": true}, - {"tag": "Destination", "path": "Destination", "type": "*variable", "value": "~*req.10", "mandatory": true}, - {"tag": "SetupTime", "path": "SetupTime", "type": "*variable", "value": "~*req.11", "mandatory": true}, - {"tag": "AnswerTime", "path": "AnswerTime", "type": "*variable", "value": "~*req.12", "mandatory": true}, - {"tag": "Usage", "path": "Usage", "type": "*variable", "value": "~*req.13", "mandatory": true}, + {"tag": "ToR", "path": "*cgreq.ToR", "type": "*variable", "value": "~*req.2", "mandatory": true}, + {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*variable", "value": "~*req.3", "mandatory": true}, + {"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*variable", "value": "~*req.4", "mandatory": true}, + {"tag": "Tenant", "path": "*cgreq.Tenant", "type": "*variable", "value": "~*req.6", "mandatory": true}, + {"tag": "Category", "path": "*cgreq.Category", "type": "*variable", "value": "~*req.7", "mandatory": true}, + {"tag": "Account", "path": "*cgreq.Account", "type": "*variable", "value": "~*req.8", "mandatory": true}, + {"tag": "Subject", "path": "*cgreq.Subject", "type": "*variable", "value": "~*req.9", "mandatory": true}, + {"tag": "Destination", "path": "*cgreq.Destination", "type": "*variable", "value": "~*req.10", "mandatory": true}, + {"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable", "value": "~*req.11", "mandatory": true}, + {"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*variable", "value": "~*req.12", "mandatory": true}, + {"tag": "Usage", "path": "*cgreq.Usage", "type": "*variable", "value": "~*req.13", "mandatory": true}, ], "cache_dump_fields": [], }, diff --git a/config/config_it_test.go b/config/config_it_test.go index c842a5d73..2a82d7036 100644 --- a/config/config_it_test.go +++ b/config/config_it_test.go @@ -429,17 +429,17 @@ func testCGRConfigReloadERs(t *testing.T) { flags, _ := utils.FlagsWithParamsFromSlice([]string{"*dryrun"}) flagsDefault, _ := utils.FlagsWithParamsFromSlice([]string{}) content := []*FCTemplate{ - &FCTemplate{Tag: "ToR", Path: utils.ToR, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.2", true, utils.INFIELD_SEP), Mandatory: true}, - &FCTemplate{Tag: utils.OriginID, Path: utils.OriginID, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.3", true, utils.INFIELD_SEP), Mandatory: true}, - &FCTemplate{Tag: utils.RequestType, Path: utils.RequestType, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.4", true, utils.INFIELD_SEP), Mandatory: true}, - &FCTemplate{Tag: utils.Tenant, Path: utils.Tenant, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.6", true, utils.INFIELD_SEP), Mandatory: true}, - &FCTemplate{Tag: utils.Category, Path: utils.Category, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.7", true, utils.INFIELD_SEP), Mandatory: true}, - &FCTemplate{Tag: utils.Account, Path: utils.Account, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.8", true, utils.INFIELD_SEP), Mandatory: true}, - &FCTemplate{Tag: utils.Subject, Path: utils.Subject, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.9", true, utils.INFIELD_SEP), Mandatory: true}, - &FCTemplate{Tag: utils.Destination, Path: utils.Destination, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.10", true, utils.INFIELD_SEP), Mandatory: true}, - &FCTemplate{Tag: utils.SetupTime, Path: utils.SetupTime, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.11", true, utils.INFIELD_SEP), Mandatory: true}, - &FCTemplate{Tag: utils.AnswerTime, Path: utils.AnswerTime, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.12", true, utils.INFIELD_SEP), Mandatory: true}, - &FCTemplate{Tag: utils.Usage, Path: utils.Usage, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.13", true, utils.INFIELD_SEP), Mandatory: true}, + &FCTemplate{Tag: utils.ToR, Path: utils.MetaCgreq + utils.NestingSep + utils.ToR, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.2", true, utils.INFIELD_SEP), Mandatory: true}, + &FCTemplate{Tag: utils.OriginID, Path: utils.MetaCgreq + utils.NestingSep + utils.OriginID, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.3", true, utils.INFIELD_SEP), Mandatory: true}, + &FCTemplate{Tag: utils.RequestType, Path: utils.MetaCgreq + utils.NestingSep + utils.RequestType, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.4", true, utils.INFIELD_SEP), Mandatory: true}, + &FCTemplate{Tag: utils.Tenant, Path: utils.MetaCgreq + utils.NestingSep + utils.Tenant, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.6", true, utils.INFIELD_SEP), Mandatory: true}, + &FCTemplate{Tag: utils.Category, Path: utils.MetaCgreq + utils.NestingSep + utils.Category, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.7", true, utils.INFIELD_SEP), Mandatory: true}, + &FCTemplate{Tag: utils.Account, Path: utils.MetaCgreq + utils.NestingSep + utils.Account, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.8", true, utils.INFIELD_SEP), Mandatory: true}, + &FCTemplate{Tag: utils.Subject, Path: utils.MetaCgreq + utils.NestingSep + utils.Subject, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.9", true, utils.INFIELD_SEP), Mandatory: true}, + &FCTemplate{Tag: utils.Destination, Path: utils.MetaCgreq + utils.NestingSep + utils.Destination, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.10", true, utils.INFIELD_SEP), Mandatory: true}, + &FCTemplate{Tag: utils.SetupTime, Path: utils.MetaCgreq + utils.NestingSep + utils.SetupTime, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.11", true, utils.INFIELD_SEP), Mandatory: true}, + &FCTemplate{Tag: utils.AnswerTime, Path: utils.MetaCgreq + utils.NestingSep + utils.AnswerTime, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.12", true, utils.INFIELD_SEP), Mandatory: true}, + &FCTemplate{Tag: utils.Usage, Path: utils.MetaCgreq + utils.NestingSep + utils.Usage, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.13", true, utils.INFIELD_SEP), Mandatory: true}, } expAttr := &ERsCfg{ Enabled: true, @@ -557,7 +557,7 @@ func testCgrCfgV1ReloadConfigSection(t *testing.T) { "Blocker": false, "BreakOnSuccess": false, "CostShiftDigits": 0, - "Path": "ToR", + "Path": "*cgreq.ToR", "Filters": nil, "Layout": "", "Mandatory": true, @@ -582,7 +582,7 @@ func testCgrCfgV1ReloadConfigSection(t *testing.T) { "Blocker": false, "BreakOnSuccess": false, "CostShiftDigits": 0, - "Path": "OriginID", + "Path": "*cgreq.OriginID", "Filters": nil, "Layout": "", "Mandatory": true, @@ -607,7 +607,7 @@ func testCgrCfgV1ReloadConfigSection(t *testing.T) { "Blocker": false, "BreakOnSuccess": false, "CostShiftDigits": 0, - "Path": "RequestType", + "Path": "*cgreq.RequestType", "Filters": nil, "Layout": "", "Mandatory": true, @@ -632,7 +632,7 @@ func testCgrCfgV1ReloadConfigSection(t *testing.T) { "Blocker": false, "BreakOnSuccess": false, "CostShiftDigits": 0, - "Path": "Tenant", + "Path": "*cgreq.Tenant", "Filters": nil, "Layout": "", "Mandatory": true, @@ -657,7 +657,7 @@ func testCgrCfgV1ReloadConfigSection(t *testing.T) { "Blocker": false, "BreakOnSuccess": false, "CostShiftDigits": 0, - "Path": "Category", + "Path": "*cgreq.Category", "Filters": nil, "Layout": "", "Mandatory": true, @@ -682,7 +682,7 @@ func testCgrCfgV1ReloadConfigSection(t *testing.T) { "Blocker": false, "BreakOnSuccess": false, "CostShiftDigits": 0, - "Path": "Account", + "Path": "*cgreq.Account", "Filters": nil, "Layout": "", "Mandatory": true, @@ -707,7 +707,7 @@ func testCgrCfgV1ReloadConfigSection(t *testing.T) { "Blocker": false, "BreakOnSuccess": false, "CostShiftDigits": 0, - "Path": "Subject", + "Path": "*cgreq.Subject", "Filters": nil, "Layout": "", "Mandatory": true, @@ -732,7 +732,7 @@ func testCgrCfgV1ReloadConfigSection(t *testing.T) { "Blocker": false, "BreakOnSuccess": false, "CostShiftDigits": 0, - "Path": "Destination", + "Path": "*cgreq.Destination", "Filters": nil, "Layout": "", "Mandatory": true, @@ -757,7 +757,7 @@ func testCgrCfgV1ReloadConfigSection(t *testing.T) { "Blocker": false, "BreakOnSuccess": false, "CostShiftDigits": 0, - "Path": "SetupTime", + "Path": "*cgreq.SetupTime", "Filters": nil, "Layout": "", "Mandatory": true, @@ -782,7 +782,7 @@ func testCgrCfgV1ReloadConfigSection(t *testing.T) { "Blocker": false, "BreakOnSuccess": false, "CostShiftDigits": 0, - "Path": "AnswerTime", + "Path": "*cgreq.AnswerTime", "Filters": nil, "Layout": "", "Mandatory": true, @@ -807,7 +807,7 @@ func testCgrCfgV1ReloadConfigSection(t *testing.T) { "Blocker": false, "BreakOnSuccess": false, "CostShiftDigits": 0, - "Path": "Usage", + "Path": "*cgreq.Usage", "Filters": nil, "Layout": "", "Mandatory": true, diff --git a/config/config_json_test.go b/config/config_json_test.go index c1f22e516..1a1aa1bf2 100755 --- a/config/config_json_test.go +++ b/config/config_json_test.go @@ -1642,27 +1642,27 @@ func TestDfApierCfg(t *testing.T) { func TestDfEventReaderCfg(t *testing.T) { cdrFields := []*FcTemplateJsonCfg{ - {Tag: utils.StringPointer("ToR"), Path: utils.StringPointer(utils.ToR), Type: utils.StringPointer(utils.MetaVariable), + {Tag: utils.StringPointer(utils.ToR), Path: utils.StringPointer(utils.MetaCgreq + utils.NestingSep + utils.ToR), Type: utils.StringPointer(utils.MetaVariable), Value: utils.StringPointer("~*req.2"), Mandatory: utils.BoolPointer(true)}, - {Tag: utils.StringPointer("OriginID"), Path: utils.StringPointer(utils.OriginID), Type: utils.StringPointer(utils.MetaVariable), + {Tag: utils.StringPointer(utils.OriginID), Path: utils.StringPointer(utils.MetaCgreq + utils.NestingSep + utils.OriginID), Type: utils.StringPointer(utils.MetaVariable), Value: utils.StringPointer("~*req.3"), Mandatory: utils.BoolPointer(true)}, - {Tag: utils.StringPointer("RequestType"), Path: utils.StringPointer(utils.RequestType), Type: utils.StringPointer(utils.MetaVariable), + {Tag: utils.StringPointer(utils.RequestType), Path: utils.StringPointer(utils.MetaCgreq + utils.NestingSep + utils.RequestType), Type: utils.StringPointer(utils.MetaVariable), Value: utils.StringPointer("~*req.4"), Mandatory: utils.BoolPointer(true)}, - {Tag: utils.StringPointer("Tenant"), Path: utils.StringPointer(utils.Tenant), Type: utils.StringPointer(utils.MetaVariable), + {Tag: utils.StringPointer(utils.Tenant), Path: utils.StringPointer(utils.MetaCgreq + utils.NestingSep + utils.Tenant), Type: utils.StringPointer(utils.MetaVariable), Value: utils.StringPointer("~*req.6"), Mandatory: utils.BoolPointer(true)}, - {Tag: utils.StringPointer("Category"), Path: utils.StringPointer(utils.Category), Type: utils.StringPointer(utils.MetaVariable), + {Tag: utils.StringPointer(utils.Category), Path: utils.StringPointer(utils.MetaCgreq + utils.NestingSep + utils.Category), Type: utils.StringPointer(utils.MetaVariable), Value: utils.StringPointer("~*req.7"), Mandatory: utils.BoolPointer(true)}, - {Tag: utils.StringPointer("Account"), Path: utils.StringPointer(utils.Account), Type: utils.StringPointer(utils.MetaVariable), + {Tag: utils.StringPointer(utils.Account), Path: utils.StringPointer(utils.MetaCgreq + utils.NestingSep + utils.Account), Type: utils.StringPointer(utils.MetaVariable), Value: utils.StringPointer("~*req.8"), Mandatory: utils.BoolPointer(true)}, - {Tag: utils.StringPointer("Subject"), Path: utils.StringPointer(utils.Subject), Type: utils.StringPointer(utils.MetaVariable), + {Tag: utils.StringPointer(utils.Subject), Path: utils.StringPointer(utils.MetaCgreq + utils.NestingSep + utils.Subject), Type: utils.StringPointer(utils.MetaVariable), Value: utils.StringPointer("~*req.9"), Mandatory: utils.BoolPointer(true)}, - {Tag: utils.StringPointer("Destination"), Path: utils.StringPointer(utils.Destination), Type: utils.StringPointer(utils.MetaVariable), + {Tag: utils.StringPointer(utils.Destination), Path: utils.StringPointer(utils.MetaCgreq + utils.NestingSep + utils.Destination), Type: utils.StringPointer(utils.MetaVariable), Value: utils.StringPointer("~*req.10"), Mandatory: utils.BoolPointer(true)}, - {Tag: utils.StringPointer("SetupTime"), Path: utils.StringPointer(utils.SetupTime), Type: utils.StringPointer(utils.MetaVariable), + {Tag: utils.StringPointer(utils.SetupTime), Path: utils.StringPointer(utils.MetaCgreq + utils.NestingSep + utils.SetupTime), Type: utils.StringPointer(utils.MetaVariable), Value: utils.StringPointer("~*req.11"), Mandatory: utils.BoolPointer(true)}, - {Tag: utils.StringPointer("AnswerTime"), Path: utils.StringPointer(utils.AnswerTime), Type: utils.StringPointer(utils.MetaVariable), + {Tag: utils.StringPointer(utils.AnswerTime), Path: utils.StringPointer(utils.MetaCgreq + utils.NestingSep + utils.AnswerTime), Type: utils.StringPointer(utils.MetaVariable), Value: utils.StringPointer("~*req.12"), Mandatory: utils.BoolPointer(true)}, - {Tag: utils.StringPointer("Usage"), Path: utils.StringPointer(utils.Usage), Type: utils.StringPointer(utils.MetaVariable), + {Tag: utils.StringPointer(utils.Usage), Path: utils.StringPointer(utils.MetaCgreq + utils.NestingSep + utils.Usage), Type: utils.StringPointer(utils.MetaVariable), Value: utils.StringPointer("~*req.13"), Mandatory: utils.BoolPointer(true)}, } eCfg := &ERsJsonCfg{ diff --git a/config/config_test.go b/config/config_test.go index 2f5df9709..a7241d1f9 100755 --- a/config/config_test.go +++ b/config/config_test.go @@ -1681,27 +1681,27 @@ func TestCgrCdfEventReader(t *testing.T) { Filters: []string{}, Flags: utils.FlagsWithParams{}, Fields: []*FCTemplate{ - {Tag: "ToR", Path: "ToR", Type: utils.MetaVariable, + {Tag: utils.ToR, Path: utils.MetaCgreq + utils.NestingSep + utils.ToR, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.2", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "OriginID", Path: "OriginID", Type: utils.MetaVariable, + {Tag: utils.OriginID, Path: utils.MetaCgreq + utils.NestingSep + utils.OriginID, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.3", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "RequestType", Path: "RequestType", Type: utils.MetaVariable, + {Tag: utils.RequestType, Path: utils.MetaCgreq + utils.NestingSep + utils.RequestType, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.4", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "Tenant", Path: "Tenant", Type: utils.MetaVariable, + {Tag: utils.Tenant, Path: utils.MetaCgreq + utils.NestingSep + utils.Tenant, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.6", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "Category", Path: "Category", Type: utils.MetaVariable, + {Tag: utils.Category, Path: utils.MetaCgreq + utils.NestingSep + utils.Category, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.7", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "Account", Path: "Account", Type: utils.MetaVariable, + {Tag: utils.Account, Path: utils.MetaCgreq + utils.NestingSep + utils.Account, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.8", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "Subject", Path: "Subject", Type: utils.MetaVariable, + {Tag: utils.Subject, Path: utils.MetaCgreq + utils.NestingSep + utils.Subject, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.9", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "Destination", Path: "Destination", Type: utils.MetaVariable, + {Tag: utils.Destination, Path: utils.MetaCgreq + utils.NestingSep + utils.Destination, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.10", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "SetupTime", Path: "SetupTime", Type: utils.MetaVariable, + {Tag: utils.SetupTime, Path: utils.MetaCgreq + utils.NestingSep + utils.SetupTime, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.11", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "AnswerTime", Path: "AnswerTime", Type: utils.MetaVariable, + {Tag: utils.AnswerTime, Path: utils.MetaCgreq + utils.NestingSep + utils.AnswerTime, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.12", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "Usage", Path: "Usage", Type: utils.MetaVariable, + {Tag: utils.Usage, Path: utils.MetaCgreq + utils.NestingSep + utils.Usage, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.13", true, utils.INFIELD_SEP), Mandatory: true}, }, CacheDumpFields: []*FCTemplate{}, @@ -1728,27 +1728,27 @@ func TestCgrCfgEventReaderDefault(t *testing.T) { Filters: nil, Flags: utils.FlagsWithParams{}, Fields: []*FCTemplate{ - {Tag: "ToR", Path: "ToR", Type: utils.MetaVariable, + {Tag: utils.ToR, Path: utils.MetaCgreq + utils.NestingSep + utils.ToR, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.2", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "OriginID", Path: "OriginID", Type: utils.MetaVariable, + {Tag: utils.OriginID, Path: utils.MetaCgreq + utils.NestingSep + utils.OriginID, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.3", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "RequestType", Path: "RequestType", Type: utils.MetaVariable, + {Tag: utils.RequestType, Path: utils.MetaCgreq + utils.NestingSep + utils.RequestType, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.4", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "Tenant", Path: "Tenant", Type: utils.MetaVariable, + {Tag: utils.Tenant, Path: utils.MetaCgreq + utils.NestingSep + utils.Tenant, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.6", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "Category", Path: "Category", Type: utils.MetaVariable, + {Tag: utils.Category, Path: utils.MetaCgreq + utils.NestingSep + utils.Category, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.7", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "Account", Path: "Account", Type: utils.MetaVariable, + {Tag: utils.Account, Path: utils.MetaCgreq + utils.NestingSep + utils.Account, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.8", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "Subject", Path: "Subject", Type: utils.MetaVariable, + {Tag: utils.Subject, Path: utils.MetaCgreq + utils.NestingSep + utils.Subject, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.9", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "Destination", Path: "Destination", Type: utils.MetaVariable, + {Tag: utils.Destination, Path: utils.MetaCgreq + utils.NestingSep + utils.Destination, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.10", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "SetupTime", Path: "SetupTime", Type: utils.MetaVariable, + {Tag: utils.SetupTime, Path: utils.MetaCgreq + utils.NestingSep + utils.SetupTime, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.11", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "AnswerTime", Path: "AnswerTime", Type: utils.MetaVariable, + {Tag: utils.AnswerTime, Path: utils.MetaCgreq + utils.NestingSep + utils.AnswerTime, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.12", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "Usage", Path: "Usage", Type: utils.MetaVariable, + {Tag: utils.Usage, Path: utils.MetaCgreq + utils.NestingSep + utils.Usage, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.13", true, utils.INFIELD_SEP), Mandatory: true}, }, CacheDumpFields: make([]*FCTemplate, 0), diff --git a/config/erscfg_test.go b/config/erscfg_test.go index 1032e2f37..46c23cfd1 100644 --- a/config/erscfg_test.go +++ b/config/erscfg_test.go @@ -112,27 +112,27 @@ func TestEventReaderLoadFromJSON(t *testing.T) { Filters: []string{}, Flags: utils.FlagsWithParams{}, Fields: []*FCTemplate{ - {Tag: "ToR", Path: "ToR", Type: utils.MetaVariable, + {Tag: utils.ToR, Path: utils.MetaCgreq + utils.NestingSep + utils.ToR, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.2", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "OriginID", Path: "OriginID", Type: utils.MetaVariable, + {Tag: utils.OriginID, Path: utils.MetaCgreq + utils.NestingSep + utils.OriginID, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.3", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "RequestType", Path: "RequestType", Type: utils.MetaVariable, + {Tag: utils.RequestType, Path: utils.MetaCgreq + utils.NestingSep + utils.RequestType, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.4", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "Tenant", Path: "Tenant", Type: utils.MetaVariable, + {Tag: utils.Tenant, Path: utils.MetaCgreq + utils.NestingSep + utils.Tenant, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.6", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "Category", Path: "Category", Type: utils.MetaVariable, + {Tag: utils.Category, Path: utils.MetaCgreq + utils.NestingSep + utils.Category, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.7", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "Account", Path: "Account", Type: utils.MetaVariable, + {Tag: utils.Account, Path: utils.MetaCgreq + utils.NestingSep + utils.Account, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.8", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "Subject", Path: "Subject", Type: utils.MetaVariable, + {Tag: utils.Subject, Path: utils.MetaCgreq + utils.NestingSep + utils.Subject, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.9", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "Destination", Path: "Destination", Type: utils.MetaVariable, + {Tag: utils.Destination, Path: utils.MetaCgreq + utils.NestingSep + utils.Destination, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.10", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "SetupTime", Path: "SetupTime", Type: utils.MetaVariable, + {Tag: utils.SetupTime, Path: utils.MetaCgreq + utils.NestingSep + utils.SetupTime, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.11", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "AnswerTime", Path: "AnswerTime", Type: utils.MetaVariable, + {Tag: utils.AnswerTime, Path: utils.MetaCgreq + utils.NestingSep + utils.AnswerTime, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.12", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "Usage", Path: "Usage", Type: utils.MetaVariable, + {Tag: utils.Usage, Path: utils.MetaCgreq + utils.NestingSep + utils.Usage, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.13", true, utils.INFIELD_SEP), Mandatory: true}, }, CacheDumpFields: make([]*FCTemplate, 0), @@ -151,27 +151,27 @@ func TestEventReaderLoadFromJSON(t *testing.T) { Filters: nil, Flags: utils.FlagsWithParams{}, Fields: []*FCTemplate{ - {Tag: "ToR", Path: "ToR", Type: utils.MetaVariable, + {Tag: utils.ToR, Path: utils.MetaCgreq + utils.NestingSep + utils.ToR, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.2", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "OriginID", Path: "OriginID", Type: utils.MetaVariable, + {Tag: utils.OriginID, Path: utils.MetaCgreq + utils.NestingSep + utils.OriginID, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.3", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "RequestType", Path: "RequestType", Type: utils.MetaVariable, + {Tag: utils.RequestType, Path: utils.MetaCgreq + utils.NestingSep + utils.RequestType, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.4", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "Tenant", Path: "Tenant", Type: utils.MetaVariable, + {Tag: utils.Tenant, Path: utils.MetaCgreq + utils.NestingSep + utils.Tenant, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.6", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "Category", Path: "Category", Type: utils.MetaVariable, + {Tag: utils.Category, Path: utils.MetaCgreq + utils.NestingSep + utils.Category, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.7", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "Account", Path: "Account", Type: utils.MetaVariable, + {Tag: utils.Account, Path: utils.MetaCgreq + utils.NestingSep + utils.Account, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.8", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "Subject", Path: "Subject", Type: utils.MetaVariable, + {Tag: utils.Subject, Path: utils.MetaCgreq + utils.NestingSep + utils.Subject, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.9", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "Destination", Path: "Destination", Type: utils.MetaVariable, + {Tag: utils.Destination, Path: utils.MetaCgreq + utils.NestingSep + utils.Destination, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.10", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "SetupTime", Path: "SetupTime", Type: utils.MetaVariable, + {Tag: utils.SetupTime, Path: utils.MetaCgreq + utils.NestingSep + utils.SetupTime, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.11", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "AnswerTime", Path: "AnswerTime", Type: utils.MetaVariable, + {Tag: utils.AnswerTime, Path: utils.MetaCgreq + utils.NestingSep + utils.AnswerTime, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.12", true, utils.INFIELD_SEP), Mandatory: true}, - {Tag: "Usage", Path: "Usage", Type: utils.MetaVariable, + {Tag: utils.Usage, Path: utils.MetaCgreq + utils.NestingSep + utils.Usage, Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.13", true, utils.INFIELD_SEP), Mandatory: true}, }, CacheDumpFields: make([]*FCTemplate, 0), diff --git a/data/conf/cgrates/cgrates.json b/data/conf/cgrates/cgrates.json index f2522a5a3..5865151c8 100755 --- a/data/conf/cgrates/cgrates.json +++ b/data/conf/cgrates/cgrates.json @@ -286,7 +286,7 @@ // "id": "*default", // identifier of the EventReader profile // "type": "*file_csv", // reader type <*file_csv> // "field_separator": ",", // separator used in case of csv files -// "run_delay": 0, // sleep interval in seconds between consecutive runs, -1 to use automation via inotify or 0 to disable running all together +// "run_delay": "0", // sleep interval in seconds between consecutive runs, -1 to use automation via inotify or 0 to disable running all together // "concurrent_requests": 1024, // maximum simultaneous requests/files to process, 0 for unlimited // "source_path": "/var/spool/cgrates/cdrc/in", // read data from this path // "processed_path": "/var/spool/cgrates/cdrc/out", // move processed data here @@ -295,18 +295,18 @@ // "timezone": "", // timezone for timestamps where not specified <""|UTC|Local|$IANA_TZ_DB> // "filters": [], // limit parsing based on the filters // "flags": [], // flags to influence the event processing -// "fields":[ // import content_fields template, tag will match internally CDR field, in case of .csv value will be represented by index of the field value -// {"tag": "ToR", "path": "ToR", "type": "*variable", "value": "~*req.2", "mandatory": true}, -// {"tag": "OriginID", "path": "OriginID", "type": "*variable", "value": "~*req.3", "mandatory": true}, -// {"tag": "RequestType", "path": "RequestType", "type": "*variable", "value": "~*req.4", "mandatory": true}, -// {"tag": "Tenant", "path": "Tenant", "type": "*variable", "value": "~*req.6", "mandatory": true}, -// {"tag": "Category", "path": "Category", "type": "*variable", "value": "~*req.7", "mandatory": true}, -// {"tag": "Account", "path": "Account", "type": "*variable", "value": "~*req.8", "mandatory": true}, -// {"tag": "Subject", "path": "Subject", "type": "*variable", "value": "~*req.9", "mandatory": true}, -// {"tag": "Destination", "path": "Destination", "type": "*variable", "value": "~*req.10", "mandatory": true}, -// {"tag": "SetupTime", "path": "SetupTime", "type": "*variable", "value": "~*req.11", "mandatory": true}, -// {"tag": "AnswerTime", "path": "AnswerTime", "type": "*variable", "value": "~*req.12", "mandatory": true}, -// {"tag": "Usage", "path": "Usage", "type": "*variable", "value": "~*req.13", "mandatory": true}, +// "fields":[ // import fields template, tag will match internally CDR field, in case of .csv value will be represented by index of the field value +// {"tag": "ToR", "path": "*cgreq.ToR", "type": "*variable", "value": "~*req.2", "mandatory": true}, +// {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*variable", "value": "~*req.3", "mandatory": true}, +// {"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*variable", "value": "~*req.4", "mandatory": true}, +// {"tag": "Tenant", "path": "*cgreq.Tenant", "type": "*variable", "value": "~*req.6", "mandatory": true}, +// {"tag": "Category", "path": "*cgreq.Category", "type": "*variable", "value": "~*req.7", "mandatory": true}, +// {"tag": "Account", "path": "*cgreq.Account", "type": "*variable", "value": "~*req.8", "mandatory": true}, +// {"tag": "Subject", "path": "*cgreq.Subject", "type": "*variable", "value": "~*req.9", "mandatory": true}, +// {"tag": "Destination", "path": "*cgreq.Destination", "type": "*variable", "value": "~*req.10", "mandatory": true}, +// {"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable", "value": "~*req.11", "mandatory": true}, +// {"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*variable", "value": "~*req.12", "mandatory": true}, +// {"tag": "Usage", "path": "*cgreq.Usage", "type": "*variable", "value": "~*req.13", "mandatory": true}, // ], // "cache_dump_fields": [], // }, @@ -395,45 +395,45 @@ // "asr_template": "", // enable AbortSession message being sent to client on DisconnectSession // "templates":{ // default message templates // "*err": [ -// {"tag": "SessionId", "path": "Session-Id", "type": "*variable", +// {"tag": "SessionId", "path": "*rep.Session-Id", "type": "*variable", // "value": "~*req.Session-Id", "mandatory": true}, -// {"tag": "OriginHost", "path": "Origin-Host", "type": "*variable", +// {"tag": "OriginHost", "path": "*rep.Origin-Host", "type": "*variable", // "value": "~*vars.OriginHost", "mandatory": true}, -// {"tag": "OriginRealm", "path": "Origin-Realm", "type": "*variable", +// {"tag": "OriginRealm", "path": "*rep.Origin-Realm", "type": "*variable", // "value": "~*vars.OriginRealm", "mandatory": true}, // ], // "*cca": [ -// {"tag": "SessionId", "path": "Session-Id", "type": "*variable", +// {"tag": "SessionId", "path": "*rep.Session-Id", "type": "*variable", // "value": "~*req.Session-Id", "mandatory": true}, -// {"tag": "ResultCode", "path": "Result-Code", "type": "*constant", +// {"tag": "ResultCode", "path": "*rep.Result-Code", "type": "*constant", // "value": "2001"}, -// {"tag": "OriginHost", "path": "Origin-Host", "type": "*variable", +// {"tag": "OriginHost", "path": "*rep.Origin-Host", "type": "*variable", // "value": "~*vars.OriginHost", "mandatory": true}, -// {"tag": "OriginRealm", "path": "Origin-Realm", "type": "*variable", +// {"tag": "OriginRealm", "path": "*rep.Origin-Realm", "type": "*variable", // "value": "~*vars.OriginRealm", "mandatory": true}, -// {"tag": "AuthApplicationId", "path": "Auth-Application-Id", "type": "*variable", +// {"tag": "AuthApplicationId", "path": "*rep.Auth-Application-Id", "type": "*variable", // "value": "~*vars.*appid", "mandatory": true}, -// {"tag": "CCRequestType", "path": "CC-Request-Type", "type": "*variable", +// {"tag": "CCRequestType", "path": "*rep.CC-Request-Type", "type": "*variable", // "value": "~*req.CC-Request-Type", "mandatory": true}, -// {"tag": "CCRequestNumber", "path": "CC-Request-Number", "type": "*variable", +// {"tag": "CCRequestNumber", "path": "*rep.CC-Request-Number", "type": "*variable", // "value": "~*req.CC-Request-Number", "mandatory": true}, // ], // "*asr": [ -// {"tag": "SessionId", "path": "Session-Id", "type": "*variable", +// {"tag": "SessionId", "path": "*diamreq.Session-Id", "type": "*variable", // "value": "~*req.Session-Id", "mandatory": true}, -// {"tag": "OriginHost", "path": "Origin-Host", "type": "*variable", +// {"tag": "OriginHost", "path": "*diamreq.Origin-Host", "type": "*variable", // "value": "~*req.Destination-Host", "mandatory": true}, -// {"tag": "OriginRealm", "path": "Origin-Realm", "type": "*variable", +// {"tag": "OriginRealm", "path": "*diamreq.Origin-Realm", "type": "*variable", // "value": "~*req.Destination-Realm", "mandatory": true}, -// {"tag": "DestinationRealm", "path": "Destination-Realm", "type": "*variable", +// {"tag": "DestinationRealm", "path": "*diamreq.Destination-Realm", "type": "*variable", // "value": "~*req.Origin-Realm", "mandatory": true}, -// {"tag": "DestinationHost", "path": "Destination-Host", "type": "*variable", +// {"tag": "DestinationHost", "path": "*diamreq.Destination-Host", "type": "*variable", // "value": "~*req.Origin-Host", "mandatory": true}, -// {"tag": "AuthApplicationId", "path": "Auth-Application-Id", "type": "*variable", +// {"tag": "AuthApplicationId", "path": "*diamreq.Auth-Application-Id", "type": "*variable", // "value": "~*vars.*appid", "mandatory": true}, -// {"tag": "UserName", "path": "User-Name", "type": "*variable", +// {"tag": "UserName", "path": "*diamreq.User-Name", "type": "*variable", // "value": "~*req.User-Name", "mandatory": true}, -// {"tag": "OriginStateID", "path": "Origin-State-Id", "type": "*constant", +// {"tag": "OriginStateID", "path": "*diamreq.Origin-State-Id", "type": "*constant", // "value": "1"}, // ] // }, diff --git a/data/conf/samples/ers_example/cgrates.json b/data/conf/samples/ers_example/cgrates.json index 0f5ccb76d..51a504886 100644 --- a/data/conf/samples/ers_example/cgrates.json +++ b/data/conf/samples/ers_example/cgrates.json @@ -76,17 +76,17 @@ "source_path": "/tmp/ers/in", "processed_path": "/tmp/ers/out", "fields":[ // import content_fields template, tag will match internally CDR field, in case of .csv value will be represented by index of the field value - {"tag": "ToR", "path": "ToR", "type": "*variable", "value": "~*req.2", "mandatory": true}, - {"tag": "OriginID", "path": "OriginID", "type": "*variable", "value": "~*req.3", "mandatory": true}, - {"tag": "RequestType", "path": "RequestType", "type": "*variable", "value": "~*req.4", "mandatory": true}, - {"tag": "Tenant", "path": "Tenant", "type": "*variable", "value": "~*req.6", "mandatory": true}, - {"tag": "Category", "path": "Category", "type": "*variable", "value": "~*req.7", "mandatory": true}, - {"tag": "Account", "path": "Account", "type": "*variable", "value": "~*req.8", "mandatory": true}, - {"tag": "Subject", "path": "Subject", "type": "*variable", "value": "~*req.9", "mandatory": true}, - {"tag": "Destination", "path": "Destination", "type": "*variable", "value": "~*req.10", "mandatory": true}, - {"tag": "SetupTime", "path": "SetupTime", "type": "*variable", "value": "~*req.11", "mandatory": true}, - {"tag": "AnswerTime", "path": "AnswerTime", "type": "*variable", "value": "~*req.12", "mandatory": true}, - {"tag": "Usage", "path": "Usage", "type": "*variable", "value": "~*req.13", "mandatory": true}, + {"tag": "ToR", "path": "*cgreq.ToR", "type": "*variable", "value": "~*req.2", "mandatory": true}, + {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*variable", "value": "~*req.3", "mandatory": true}, + {"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*variable", "value": "~*req.4", "mandatory": true}, + {"tag": "Tenant", "path": "*cgreq.Tenant", "type": "*variable", "value": "~*req.6", "mandatory": true}, + {"tag": "Category", "path": "*cgreq.Category", "type": "*variable", "value": "~*req.7", "mandatory": true}, + {"tag": "Account", "path": "*cgreq.Account", "type": "*variable", "value": "~*req.8", "mandatory": true}, + {"tag": "Subject", "path": "*cgreq.Subject", "type": "*variable", "value": "~*req.9", "mandatory": true}, + {"tag": "Destination", "path": "*cgreq.Destination", "type": "*variable", "value": "~*req.10", "mandatory": true}, + {"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable", "value": "~*req.11", "mandatory": true}, + {"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*variable", "value": "~*req.12", "mandatory": true}, + {"tag": "Usage", "path": "*cgreq.Usage", "type": "*variable", "value": "~*req.13", "mandatory": true}, ], }, ],