Calculate stats after mediation storing the results in stordb

This commit is contained in:
DanB
2014-08-01 15:36:37 +02:00
parent 97977e98cf
commit 3e0e30f2cc
3 changed files with 12 additions and 12 deletions

View File

@@ -14,19 +14,19 @@ enabled = true # Enable RaterCDRSExportPath service: <true|false>.
# enabled = false # Starts Scheduler service: <true|false>.
[cdrs]
enabled = true # Start the CDR Server service: <true|false>.
# mediator = # Address where to reach the Mediator. Empty for disabling mediation. <""|internal>
cdrstats = internal # Address where to reach the cdrstats service: <internal|x.y.z.y:1234>
enabled = true # Start the CDR Server service: <true|false>.
mediator = internal # Address where to reach the Mediator. Empty for disabling mediation. <""|internal>
# cdrstats = # Address where to reach the cdrstats service: <internal|x.y.z.y:1234>
[mediator]
# enabled = false # Starts Mediator service: <true|false>.
enabled = true # Starts Mediator service: <true|false>.
# rater = internal # Address where to reach the Rater: <internal|x.y.z.y:1234>
# cdrstats = internal # Address where to reach the cdrstats service: <internal|x.y.z.y:1234>
[cdrstats]
enabled = true # Starts the cdrstats service: <true|false>
# queue_length = 50 # Number of items in the stats buffer
# time_window = 1h # Will only keep the CDRs who's call setup time is not older than time.Now()-TimeWindow
#queue_length = 50 # Number of items in the stats buffer
time_window = 1h # Will only keep the CDRs who's call setup time is not older than time.Now()-TimeWindow
# metrics = ASR, ACD, ACC # Stat metric ids to build
# setup_interval = # Filter on CDR SetupTime
# tors = # Filter on CDR TOR fields

View File

@@ -1,5 +1,5 @@
#Id,QueueLength,TimeWindow,Metrics,SetupInterval,TOR,CdrHost,CdrSource,ReqType,Direction,Tenant,Category,Account,Subject,DestinationPrefix,UsageInterval,MediationRunIds,RatedAccount,RatedSubject,CostInterval,Triggers
CDRST1,5,60m,ASR,2014-07-29T15:00:00Z;2014-07-29T16:00:00Z,*voice,87.139.12.167,FS_JSON,rated,*out,cgrates.org,call,dan,dan,49,5m;10m,default,rif,rif,0;2,CDRST1_WARN_ASR
CDRST1,5,60m,ASR,2014-07-29T15:00:00Z;2014-07-29T16:00:00Z,*voice,87.139.12.167,FS_JSON,rated,*out,cgrates.org,call,dan,dan,+49,5m;10m,default,rif,rif,0;2,CDRST1_WARN_ASR
CDRST1,,,ACD,,,,,,,,,,,,,,,,,CDRST1_WARN_ACD
CDRST1,,,ACC,,,,,,,,,,,,,,,,,CDRST1_WARN_ACC
CDRST2,10,10m,ASR,,,,,,,cgrates.org,call,,,,,,,,,CDRST2_WARN_ASR
1 #Id QueueLength TimeWindow Metrics SetupInterval TOR CdrHost CdrSource ReqType Direction Tenant Category Account Subject DestinationPrefix UsageInterval MediationRunIds RatedAccount RatedSubject CostInterval Triggers
2 CDRST1 5 60m ASR 2014-07-29T15:00:00Z;2014-07-29T16:00:00Z *voice 87.139.12.167 FS_JSON rated *out cgrates.org call dan dan 49 +49 5m;10m default rif rif 0;2 CDRST1_WARN_ASR
3 CDRST1 ACD CDRST1_WARN_ACD
4 CDRST1 ACC CDRST1_WARN_ACC
5 CDRST2 10 10m ASR cgrates.org call CDRST2_WARN_ASR

View File

@@ -168,17 +168,17 @@ func (self *Mediator) RateCdr(storedCdr *utils.StoredCdr, sendToStats bool) erro
if err := self.rateCDR(cdr); err != nil {
extraInfo = err.Error()
}
if sendToStats && self.stats != nil {
if err := self.cdrDb.SetRatedCdr(cdr, extraInfo); err != nil {
Logger.Err(fmt.Sprintf("<Mediator> Could not record cost for cgrid: <%s>, ERROR: <%s>, cost: %f, extraInfo: %s",
cdr.CgrId, err.Error(), cdr.Cost, extraInfo))
}
if sendToStats && self.stats != nil { // We send to stats only after saving to db since there are chances we cannot store and then no way to reproduce stats offline
go func() {
if err := self.stats.AppendCDR(cdr, nil); err != nil {
Logger.Err(fmt.Sprintf("Could not append cdr to stats (mediator): %s", err.Error()))
}
}()
}
if err := self.cdrDb.SetRatedCdr(cdr, extraInfo); err != nil {
Logger.Err(fmt.Sprintf("<Mediator> Could not record cost for cgrid: <%s>, ERROR: <%s>, cost: %f, extraInfo: %s",
cdr.CgrId, err.Error(), cdr.Cost, extraInfo))
}
}
return nil
}