improve CoreSv1.Status API with more detailed metrics

- add new metrics (off by default)
- add Debug boolean option for full metric details
- add Timezone option for 'running_since' field
- update default metrics shown and their constants
- remove utils.GetStartTime(), now use process metrics
This commit is contained in:
ionutboangiu
2024-09-06 23:11:06 +03:00
committed by Dan Christian Bogos
parent 98f770c61b
commit 62c30ab539
13 changed files with 416 additions and 124 deletions

View File

@@ -127,23 +127,28 @@ func (dS *DispatcherService) CoreSv1StartMemoryProfiling(ctx *context.Context, p
utils.CoreSv1StartMemoryProfiling, params, reply,
)
}
func (dS *DispatcherService) CoreSv1Status(ctx *context.Context, args *utils.TenantWithAPIOpts, reply *map[string]any) (err error) {
func (dS *DispatcherService) CoreSv1Status(ctx *context.Context, params *cores.V1StatusParams, reply *map[string]any) error {
tnt := dS.cfg.GeneralCfg().DefaultTenant
if args != nil && len(args.Tenant) != 0 {
tnt = args.Tenant
if params != nil && params.Tenant != utils.EmptyString {
tnt = params.Tenant
}
ev := make(map[string]any)
opts := make(map[string]any)
if args != nil {
opts = args.APIOpts
if params != nil && params.APIOpts != nil {
opts = params.APIOpts
}
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
if err = dS.authorize(utils.CoreSv1Status, tnt,
if err := dS.authorize(utils.CoreSv1Status, tnt,
utils.IfaceAsString(opts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil {
return
return err
}
}
return dS.Dispatch(&utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaCore, utils.CoreSv1Status, args, reply)
return dS.Dispatch(
&utils.CGREvent{
Tenant: tnt,
Event: ev,
APIOpts: opts,
}, utils.MetaCore, utils.CoreSv1Status, params, reply)
}
func (dS *DispatcherService) CoreSv1StopCPUProfiling(ctx *context.Context, args *utils.TenantWithAPIOpts, reply *string) (err error) {
tnt := dS.cfg.GeneralCfg().DefaultTenant

View File

@@ -27,6 +27,7 @@ import (
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/cores"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/guardian"
"github.com/cgrates/cgrates/utils"
@@ -454,7 +455,7 @@ func (dS *DispatcherService) Call(ctx *context.Context, serviceMethod string, //
return err
}
func (dS *DispatcherService) DispatcherSv1RemoteStatus(ctx *context.Context, args *utils.TenantWithAPIOpts,
func (dS *DispatcherService) DispatcherSv1RemoteStatus(ctx *context.Context, args *cores.V1StatusParams,
reply *map[string]any) (err error) {
tnt := dS.cfg.GeneralCfg().DefaultTenant
if args.Tenant != utils.EmptyString {