diff --git a/embedded/graph/crud/common.go b/embedded/graph/crud/common.go index 8526bfcf..34484a58 100644 --- a/embedded/graph/crud/common.go +++ b/embedded/graph/crud/common.go @@ -74,7 +74,7 @@ func RegisterAllFunctionTypes(runtime *statefun.Runtime) { statefun.NewFunctionType(runtime, "functions.graph.api.link.delete", LLAPILinkDelete, *statefun.NewFunctionTypeConfig().SetAllowedRequestProviders(sfPlugins.AutoRequestSelect)) statefun.NewFunctionType(runtime, "functions.graph.api.link.read", LLAPILinkRead, *statefun.NewFunctionTypeConfig().SetAllowedRequestProviders(sfPlugins.AutoRequestSelect)) - if runtime.Domain.Name() == runtime.Domain.HubDomainName() { + if runtime.Domain.Name() == runtime.Domain.LocalHubDomainName() { runtime.RegisterOnAfterStartFunction(cmdbSchemaPrepare, false) } } diff --git a/embedded/graph/crud/hl_crud.go b/embedded/graph/crud/hl_crud.go index 4105e5e6..fe3f3599 100644 --- a/embedded/graph/crud/hl_crud.go +++ b/embedded/graph/crud/hl_crud.go @@ -39,7 +39,7 @@ func replyWithoutOpStack(om *sfMediators.OpMediator, ctx *sfPlugins.StatefunCont */ func CreateType(_ sfPlugins.StatefunExecutor, ctx *sfPlugins.StatefunContextProcessor) { selfID := getOriginalID(ctx.Self.ID) - typesVertexId := ctx.Domain.CreateObjectIDWithHubDomain(BUILT_IN_TYPES, false) + typesVertexId := ctx.Domain.CreateObjectIDWithLocalHubDomain(BUILT_IN_TYPES, false) if typeOperationRedirectedToHub(ctx) { return @@ -182,7 +182,7 @@ func ReadType(_ sfPlugins.StatefunExecutor, ctx *sfPlugins.StatefunContextProces om.AggregateOpMsg(m) vertexIsType := false - typesVertexId := ctx.Domain.CreateObjectIDWithHubDomain(BUILT_IN_TYPES, false) + typesVertexId := ctx.Domain.CreateObjectIDWithLocalHubDomain(BUILT_IN_TYPES, false) for i := 0; i < m.Data.GetByPath("links.in").ArraySize(); i++ { fromId := m.Data.GetByPath("links.in").ArrayElement(i).GetByPath("from").AsStringDefault("") if fromId == typesVertexId { @@ -235,8 +235,8 @@ func CreateObject(_ sfPlugins.StatefunExecutor, ctx *sfPlugins.StatefunContextPr return } - originType = ctx.Domain.CreateObjectIDWithHubDomain(originType, true) - builtInObjectsVertexId := ctx.Domain.CreateObjectIDWithHubDomain(BUILT_IN_OBJECTS, false) + originType = ctx.Domain.CreateObjectIDWithLocalHubDomain(originType, true) + builtInObjectsVertexId := ctx.Domain.CreateObjectIDWithLocalHubDomain(BUILT_IN_OBJECTS, false) opTime := ctx.Payload.GetByPath("op_time").AsNumericDefault(-1) ctx.Payload.SetByPath("op_time", easyjson.NewJSON(opTime)) @@ -412,7 +412,7 @@ func ReadObject(_ sfPlugins.StatefunExecutor, ctx *sfPlugins.StatefunContextProc vertexIsObject := false typeBidirectionalLink := false - objectsVertexId := ctx.Domain.CreateObjectIDWithHubDomain(BUILT_IN_OBJECTS, false) + objectsVertexId := ctx.Domain.CreateObjectIDWithLocalHubDomain(BUILT_IN_OBJECTS, false) for i := 0; i < m.Data.GetByPath("links.in").ArraySize(); i++ { fromId := m.Data.GetByPath("links.in").ArrayElement(i).GetByPath("from").AsStringDefault("") if fromId == objectsVertexId { @@ -481,7 +481,7 @@ func CreateTypesLink(_ sfPlugins.StatefunExecutor, ctx *sfPlugins.StatefunContex om.AggregateOpMsg(sfMediators.OpMsgFailed("'to' undefined")).Reply() return } - toType = ctx.Domain.CreateObjectIDWithHubDomain(toType, true) + toType = ctx.Domain.CreateObjectIDWithLocalHubDomain(toType, true) link := easyjson.NewJSONObject() link.SetByPath("to", easyjson.NewJSON(toType)) @@ -524,7 +524,7 @@ func UpdateTypesLink(_ sfPlugins.StatefunExecutor, ctx *sfPlugins.StatefunContex om.AggregateOpMsg(sfMediators.OpMsgFailed("'to' undefined")).Reply() return } - toType = ctx.Domain.CreateObjectIDWithHubDomain(toType, true) + toType = ctx.Domain.CreateObjectIDWithLocalHubDomain(toType, true) link := ctx.Payload.Clone() link.SetByPath("to", easyjson.NewJSON(toType)) @@ -574,7 +574,7 @@ func DeleteTypesLink(_ sfPlugins.StatefunExecutor, ctx *sfPlugins.StatefunContex om.AggregateOpMsg(sfMediators.OpMsgFailed("'to' undefined")).Reply() return } - toType = ctx.Domain.CreateObjectIDWithHubDomain(toType, true) + toType = ctx.Domain.CreateObjectIDWithLocalHubDomain(toType, true) operationKeysMutexLock(ctx, []string{selfID, toType}, true) @@ -640,7 +640,7 @@ func ReadTypesLink(_ sfPlugins.StatefunExecutor, ctx *sfPlugins.StatefunContextP om.AggregateOpMsg(sfMediators.OpMsgFailed("'to' undefined")).Reply() return } - toType = ctx.Domain.CreateObjectIDWithHubDomain(toType, true) + toType = ctx.Domain.CreateObjectIDWithLocalHubDomain(toType, true) payload := easyjson.NewJSONObject() payload.SetByPath("to", easyjson.NewJSON(toType)) diff --git a/embedded/graph/crud/hl_crud_helpers.go b/embedded/graph/crud/hl_crud_helpers.go index 3efd3d67..3e712617 100644 --- a/embedded/graph/crud/hl_crud_helpers.go +++ b/embedded/graph/crud/hl_crud_helpers.go @@ -28,10 +28,10 @@ const ( ) func typeOperationRedirectedToHub(ctx *sfPlugins.StatefunContextProcessor) bool { - if ctx.Domain.Name() != ctx.Domain.HubDomainName() { + if ctx.Domain.Name() != ctx.Domain.LocalHubDomainName() { om := sfMediators.NewOpMediator(ctx) selfID := getOriginalID(ctx.Self.ID) - idOnHub := ctx.Domain.CreateObjectIDWithHubDomain(selfID, true) + idOnHub := ctx.Domain.CreateObjectIDWithLocalHubDomain(selfID, true) om.AggregateOpMsg(sfMediators.OpMsgFromSfReply(ctx.Request(sfPlugins.AutoRequestSelect, ctx.Self.Typename, idOnHub, ctx.Payload, ctx.Options))).Reply() return true } @@ -195,13 +195,13 @@ func cmdbSchemaPrepare(ctx context.Context, runtime *statefun.Runtime) error { v := easyjson.NewJSONObject() v.SetByPath("to", easyjson.NewJSON(BUILT_IN_TYPES)) v.SetByPath("type", easyjson.NewJSON(TYPES_TYPELINK)) - v.SetByPath("name", easyjson.NewJSON(runtime.Domain.CreateObjectIDWithHubDomain(BUILT_IN_TYPES, false))) + v.SetByPath("name", easyjson.NewJSON(runtime.Domain.CreateObjectIDWithLocalHubDomain(BUILT_IN_TYPES, false))) system.MsgOnErrorReturn(runtime.Request(sfPlugins.AutoRequestSelect, "functions.graph.api.link.create", BUILT_IN_ROOT, &v, nil)) v = easyjson.NewJSONObject() v.SetByPath("to", easyjson.NewJSON(BUILT_IN_OBJECTS)) v.SetByPath("type", easyjson.NewJSON(OBJECTS_TYPELINK)) - v.SetByPath("name", easyjson.NewJSON(runtime.Domain.CreateObjectIDWithHubDomain(BUILT_IN_OBJECTS, false))) + v.SetByPath("name", easyjson.NewJSON(runtime.Domain.CreateObjectIDWithLocalHubDomain(BUILT_IN_OBJECTS, false))) system.MsgOnErrorReturn(runtime.Request(sfPlugins.AutoRequestSelect, "functions.graph.api.link.create", BUILT_IN_ROOT, &v, nil)) // ---------------------------------------------------- diff --git a/embedded/graph/crud/hl_polytype_crud.go b/embedded/graph/crud/hl_polytype_crud.go index dd092b78..b174ef16 100644 --- a/embedded/graph/crud/hl_polytype_crud.go +++ b/embedded/graph/crud/hl_polytype_crud.go @@ -47,7 +47,7 @@ func TypeSetSubType(_ sfPlugins.StatefunExecutor, ctx *sfPlugins.StatefunContext om.AggregateOpMsg(sfMediators.OpMsgFailed("'sub_type' undefined")).Reply() return } - childTypeWithDomain := ctx.Domain.CreateObjectIDWithHubDomain(childType, true) + childTypeWithDomain := ctx.Domain.CreateObjectIDWithLocalHubDomain(childType, true) operationKeysMutexLock(ctx, []string{selfID, childTypeWithDomain}, true) defer operationKeysMutexUnlock(ctx) @@ -82,7 +82,7 @@ func TypeRemoveSubType(_ sfPlugins.StatefunExecutor, ctx *sfPlugins.StatefunCont om.AggregateOpMsg(sfMediators.OpMsgFailed("'sub_type' undefined")).Reply() return } - childTypeWithDomain := ctx.Domain.CreateObjectIDWithHubDomain(childType, true) + childTypeWithDomain := ctx.Domain.CreateObjectIDWithLocalHubDomain(childType, true) operationKeysMutexLock(ctx, []string{selfID, childTypeWithDomain}, true) defer operationKeysMutexUnlock(ctx) @@ -133,8 +133,8 @@ func CreateObjectsLinkFromSuperTypes(_ sfPlugins.StatefunExecutor, ctx *sfPlugin fromObjectClaimType := ctx.Payload.GetByPath("from_super_type").AsStringDefault("") toObjectClaimType := ctx.Payload.GetByPath("to_super_type").AsStringDefault("") - fromObjectClaimType = ctx.Domain.CreateObjectIDWithHubDomain(fromObjectClaimType, true) - toObjectClaimType = ctx.Domain.CreateObjectIDWithHubDomain(toObjectClaimType, true) + fromObjectClaimType = ctx.Domain.CreateObjectIDWithLocalHubDomain(fromObjectClaimType, true) + toObjectClaimType = ctx.Domain.CreateObjectIDWithLocalHubDomain(toObjectClaimType, true) objectLinkType := isObjectLinkPermittedForClaimedTypes(ctx, selfID, objectToID, fromObjectClaimType, toObjectClaimType) if len(objectLinkType) == 0 { @@ -185,8 +185,8 @@ func DeleteObjectsLinkFromSuperTypes(_ sfPlugins.StatefunExecutor, ctx *sfPlugin fromObjectClaimType := ctx.Payload.GetByPath("from_super_type").AsStringDefault("") toObjectClaimType := ctx.Payload.GetByPath("to_super_type").AsStringDefault("") - fromObjectClaimType = ctx.Domain.CreateObjectIDWithHubDomain(fromObjectClaimType, true) - toObjectClaimType = ctx.Domain.CreateObjectIDWithHubDomain(toObjectClaimType, true) + fromObjectClaimType = ctx.Domain.CreateObjectIDWithLocalHubDomain(fromObjectClaimType, true) + toObjectClaimType = ctx.Domain.CreateObjectIDWithLocalHubDomain(toObjectClaimType, true) objectLinkType := isObjectLinkPermittedForClaimedTypes(ctx, selfID, objectToID, fromObjectClaimType, toObjectClaimType) if len(objectLinkType) == 0 { diff --git a/embedded/graph/crud/hl_polytype_helpers.go b/embedded/graph/crud/hl_polytype_helpers.go index 570a66f2..3d1711d0 100644 --- a/embedded/graph/crud/hl_polytype_helpers.go +++ b/embedded/graph/crud/hl_polytype_helpers.go @@ -62,7 +62,7 @@ func getObjectAllTypesBaseAndParents(ctx *sfPlugins.StatefunContextProcessor, ob return } - targetObjectType = ctx.Domain.CreateObjectIDWithHubDomain(targetObjectType, true) + targetObjectType = ctx.Domain.CreateObjectIDWithLocalHubDomain(targetObjectType, true) result[targetObjectType] = struct{}{} om := sfMediators.OpMsgFromSfReply(ctx.Request(sfPlugins.AutoRequestSelect, "functions.cmdb.api.type.read", makeSequenceFreeParentBasedID(ctx, targetObjectType), injectParentHoldsLocks(ctx, nil), nil)) @@ -70,7 +70,7 @@ func getObjectAllTypesBaseAndParents(ctx *sfPlugins.StatefunContextProcessor, ob parentTypes := om.Data.GetByPath("body.cache.parent_types") for i := 0; i < parentTypes.ArraySize(); i++ { parentType := parentTypes.ArrayElement(i).AsStringDefault("") - parentType = ctx.Domain.CreateObjectIDWithHubDomain(parentType, true) + parentType = ctx.Domain.CreateObjectIDWithLocalHubDomain(parentType, true) if len(parentType) > 0 { result[parentType] = struct{}{} } @@ -172,7 +172,7 @@ func PolyTypeGoalFinalize(ctx *sfPlugins.StatefunContextProcessor, typesToRefres } func UpdateTypeModelVersion(ctx *sfPlugins.StatefunContextProcessor) { - typesVertexId := ctx.Domain.CreateObjectIDWithHubDomain(BUILT_IN_TYPES, false) + typesVertexId := ctx.Domain.CreateObjectIDWithLocalHubDomain(BUILT_IN_TYPES, false) payload := easyjson.NewJSONObject() payload.SetByPath("body.version", easyjson.NewJSON(system.GetUniqueStrID())) @@ -230,7 +230,7 @@ func getTypeCacheVersionAndGlobalVersion(ctx *sfPlugins.StatefunContextProcessor typeCacheVersion = som1.Data.GetByPath("body.cache.version").AsStringDefault("") } - typesVertexId := ctx.Domain.CreateObjectIDWithHubDomain(BUILT_IN_TYPES, false) + typesVertexId := ctx.Domain.CreateObjectIDWithLocalHubDomain(BUILT_IN_TYPES, false) som2 := sfMediators.OpMsgFromSfReply(ctx.Request(sfPlugins.AutoRequestSelect, "functions.graph.api.vertex.read", makeSequenceFreeParentBasedID(ctx, typesVertexId), injectParentHoldsLocks(ctx, nil), nil)) if som2.Status == sfMediators.SYNC_OP_STATUS_OK { typeModelVersion = som2.Data.GetByPath("body.version").AsStringDefault("") diff --git a/embedded/graph/debug/graph.go b/embedded/graph/debug/graph.go index bb80c8eb..63106342 100644 --- a/embedded/graph/debug/graph.go +++ b/embedded/graph/debug/graph.go @@ -287,7 +287,7 @@ func LLAPIImportGraph(executor sfPlugins.StatefunExecutor, ctx *sfPlugins.Statef defer wg.Done() for i := range vertexIdx { n := graph.Nodes[i] - uuid := ctx.Domain.CreateObjectIDWithHubDomain(n.Id, true) + uuid := ctx.Domain.CreateObjectIDWithLocalHubDomain(n.Id, true) if err := dbc.Graph.VertexDelete(uuid); err != nil { system.MsgOnErrorReturn(err) diff --git a/statefun/domain.go b/statefun/domain.go index 87dbde1b..3168b7d8 100644 --- a/statefun/domain.go +++ b/statefun/domain.go @@ -44,7 +44,8 @@ const ( ) type Domain struct { - hubDomainName string + centralHubDomainName string + localHubDomainName string name string weakClusterDomains map[string]struct{} weakClusterDomainsMutex sync.Mutex @@ -65,43 +66,58 @@ type streamConfig struct { maxAge time.Duration } -func NewDomain(nc *nats.Conn, js nats.JetStreamContext, desiredHubDomainName string, ftSC, sysSC, kvSC streamConfig) (dm *Domain, e error) { +func NewDomain(nc *nats.Conn, js nats.JetStreamContext, desiredCentralHubDomainName, desiredLocalHubDomainName string, ftSC, sysSC, kvSC streamConfig) (dm *Domain, e error) { accInfo, err := js.AccountInfo() if err != nil { return nil, err } - hubDomainName := desiredHubDomainName + centralHubDomainName := desiredCentralHubDomainName + localHubDomainName := desiredLocalHubDomainName thisDomainName := accInfo.Domain if thisDomainName == "" { - if hubDomainName == "" { - thisDomainName = DefaultHubDomainName - hubDomainName = DefaultHubDomainName - } else { - thisDomainName = hubDomainName + if centralHubDomainName == "" { + centralHubDomainName = DefaultCentralHubDomainName + } + if localHubDomainName == "" { + localHubDomainName = centralHubDomainName } + thisDomainName = localHubDomainName } else { - if hubDomainName == "" { - hubDomainName = thisDomainName + if centralHubDomainName == "" { + centralHubDomainName = thisDomainName + } + if localHubDomainName == "" { + localHubDomainName = thisDomainName } } domain := &Domain{ - hubDomainName: hubDomainName, - name: thisDomainName, - weakClusterDomains: map[string]struct{}{thisDomainName: {}}, - nc: nc, - js: js, - ftSC: ftSC, - sysSC: sysSC, - kvSC: kvSC, + centralHubDomainName: centralHubDomainName, + localHubDomainName: localHubDomainName, + name: thisDomainName, + weakClusterDomains: map[string]struct{}{thisDomainName: {}}, + nc: nc, + js: js, + ftSC: ftSC, + sysSC: sysSC, + kvSC: kvSC, } return domain, nil } +// Deprecated func (dm *Domain) HubDomainName() string { - return dm.hubDomainName + return dm.localHubDomainName +} + +func (dm *Domain) CentralHubDomainName() string { + return dm.centralHubDomainName +} + +func (dm *Domain) LocalHubDomainName() string { + return dm.localHubDomainName } func (dm *Domain) Name() string { @@ -117,7 +133,7 @@ func (dm *Domain) GetWeakClusterDomains() []string { dm.weakClusterDomainsMutex.Lock() defer dm.weakClusterDomainsMutex.Unlock() - weakClusterUniqueDomainNamesIncludingThis := []string{} + weakClusterUniqueDomainNamesIncludingThis := make([]string, 0, len(dm.weakClusterDomains)) for k := range dm.weakClusterDomains { weakClusterUniqueDomainNamesIncludingThis = append(weakClusterUniqueDomainNamesIncludingThis, k) } @@ -250,8 +266,13 @@ func (dm *Domain) CreateObjectIDWithThisDomain(objectID string, domainReplace bo return dm.CreateObjectIDWithDomain(dm.name, objectID, domainReplace) } +// Deprecated func (dm *Domain) CreateObjectIDWithHubDomain(objectID string, domainReplace bool) string { - return dm.CreateObjectIDWithDomain(dm.hubDomainName, objectID, domainReplace) + return dm.CreateObjectIDWithDomain(dm.localHubDomainName, objectID, domainReplace) +} + +func (dm *Domain) CreateObjectIDWithLocalHubDomain(objectID string, domainReplace bool) string { + return dm.CreateObjectIDWithDomain(dm.localHubDomainName, objectID, domainReplace) } func (dm *Domain) start(cacheConfig *cache.Config, createDomainRouters bool) error { @@ -276,13 +297,10 @@ func (dm *Domain) start(cacheConfig *cache.Config, createDomainRouters bool) err } kvExists = true } - if !kvExists { - return fmt.Errorf("Nats KV was not inited") - } // -------------------------------------------------------------- if createDomainRouters { - if dm.hubDomainName == dm.name { + if dm.centralHubDomainName == dm.name { if err := dm.createHubSignalStream(); err != nil { return err } @@ -348,14 +366,14 @@ func (dm *Domain) createHubSignalStream() error { func (dm *Domain) createIngresSignalStream() error { var ss *nats.StreamSource - if dm.hubDomainName == dm.name { + if dm.centralHubDomainName == dm.name { ss = &nats.StreamSource{ Name: hubEventStreamName, FilterSubject: fmt.Sprintf(FromGlobalSignalTmpl, dm.name, ">"), } } else { ext := &nats.ExternalStream{ - APIPrefix: fmt.Sprintf(streamPrefix, dm.hubDomainName), + APIPrefix: fmt.Sprintf(streamPrefix, dm.centralHubDomainName), } ss = &nats.StreamSource{ Name: hubEventStreamName, diff --git a/statefun/function_type.go b/statefun/function_type.go index 3916ef83..a6760c17 100644 --- a/statefun/function_type.go +++ b/statefun/function_type.go @@ -436,7 +436,7 @@ func (ft *FunctionType) getObjectImplTypes(id string) ([]string, error) { parentTypes := response.GetByPath("data.body.cache.parent_types") for i := 0; i < parentTypes.ArraySize(); i++ { parentType := parentTypes.ArrayElement(i).AsStringDefault("") - parentType = ft.runtime.Domain.CreateObjectIDWithHubDomain(parentType, true) + parentType = ft.runtime.Domain.CreateObjectIDWithLocalHubDomain(parentType, true) if len(parentType) > 0 { result[parentType] = struct{}{} } diff --git a/statefun/plugins/plugins.go b/statefun/plugins/plugins.go index ee88d957..4bcb33b9 100644 --- a/statefun/plugins/plugins.go +++ b/statefun/plugins/plugins.go @@ -59,14 +59,19 @@ type SyncReply struct { } type Domain interface { + //Deprecated HubDomainName() string + CentralHubDomainName() string + LocalHubDomainName() string Name() string Cache() *cache.Store GetDomainFromObjectID(objectID string) string GetObjectIDWithoutDomain(objectID string) string CreateObjectIDWithDomain(domain string, objectID string, domainReplace bool) string CreateObjectIDWithThisDomain(objectID string, domainReplace bool) string + //Deprecated CreateObjectIDWithHubDomain(objectID string, domainReplace bool) string + CreateObjectIDWithLocalHubDomain(objectID string, domainReplace bool) string // Get all domains in weak cluster including this one GetWeakClusterDomains() []string // Set all domains in weak cluster (this domain name will also be included automatically if not defined) diff --git a/statefun/runtime.go b/statefun/runtime.go index 41d60613..5b0a65c7 100644 --- a/statefun/runtime.go +++ b/statefun/runtime.go @@ -89,11 +89,12 @@ func NewRuntime(config RuntimeConfig) (*Runtime, error) { maxAge: config.kvStreamMaxAge, } - r.Domain, err = NewDomain(r.nc, r.js, config.desiredHUBDomainName, ftStreamConfig, sysStreamConfig, kvStreamConfig) + r.Domain, err = NewDomain(r.nc, r.js, config.desiredCentralHUBDomainName, config.desiredLocalHUBDomainName, ftStreamConfig, sysStreamConfig, kvStreamConfig) if err != nil { return nil, err } - r.config.desiredHUBDomainName = r.Domain.hubDomainName + r.config.desiredCentralHUBDomainName = r.Domain.centralHubDomainName + r.config.desiredLocalHUBDomainName = r.Domain.localHubDomainName return r, nil } diff --git a/statefun/runtime_config.go b/statefun/runtime_config.go index 2a22b61c..a7197358 100644 --- a/statefun/runtime_config.go +++ b/statefun/runtime_config.go @@ -11,6 +11,7 @@ const ( RequestTimeoutSec = 60 GCIntervalSec = 5 DefaultHubDomainName = "hub" + DefaultCentralHubDomainName = "hub" HandlesDomainRouters = true EnableTLS = false EnableNatsClusterMode = false @@ -37,7 +38,8 @@ type RuntimeConfig struct { functionTypeIDLifetimeMs int requestTimeoutSec int gcIntervalSec int - desiredHUBDomainName string + desiredCentralHUBDomainName string + desiredLocalHUBDomainName string handlesDomainRouters bool activePassiveMode bool isActiveInstance bool @@ -82,7 +84,8 @@ func NewRuntimeConfig() *RuntimeConfig { functionTypeIDLifetimeMs: FunctionTypeIDLifetimeMs, requestTimeoutSec: RequestTimeoutSec, gcIntervalSec: GCIntervalSec, - desiredHUBDomainName: DefaultHubDomainName, + desiredCentralHUBDomainName: DefaultCentralHubDomainName, + desiredLocalHUBDomainName: DefaultCentralHubDomainName, handlesDomainRouters: HandlesDomainRouters, enableTLS: EnableTLS, activePassiveMode: activePassiveMode, @@ -95,13 +98,35 @@ func NewRuntimeConfigSimple(natsURL string, runtimeName string) *RuntimeConfig { return ro.SetNatsURL(natsURL) } +// Deprecated func (ro *RuntimeConfig) SetHubDomainName(hubDomainName string) *RuntimeConfig { - ro.desiredHUBDomainName = hubDomainName + ro.desiredLocalHUBDomainName = hubDomainName return ro } +// Deprecated func (ro *RuntimeConfig) UseJSDomainAsHubDomainName() *RuntimeConfig { - ro.desiredHUBDomainName = "" // empty string means auto fill with current domain name from nats + ro.desiredCentralHUBDomainName = "" // empty string means auto fill with current domain name from nats + return ro +} + +func (ro *RuntimeConfig) SetCentralHubDomainName(centralHubDomainName string) *RuntimeConfig { + ro.desiredCentralHUBDomainName = centralHubDomainName + return ro +} + +func (ro *RuntimeConfig) SetLocalHubDomainName(localHubDomainName string) *RuntimeConfig { + ro.desiredLocalHUBDomainName = localHubDomainName + return ro +} + +func (ro *RuntimeConfig) UseJSDomainAsCentralHubDomainName() *RuntimeConfig { + ro.desiredCentralHUBDomainName = "" // empty string means auto fill with current domain name from nats + return ro +} + +func (ro *RuntimeConfig) UseJSDomainAsLocalHubDomainName() *RuntimeConfig { + ro.desiredLocalHUBDomainName = "" // empty string means auto fill with current domain name from nats return ro } diff --git a/tests/backup-barrier/backup_barrier.go b/tests/backup-barrier/backup_barrier.go index b2205808..7275c40f 100644 --- a/tests/backup-barrier/backup_barrier.go +++ b/tests/backup-barrier/backup_barrier.go @@ -5,6 +5,9 @@ package main import ( "context" "fmt" + "strings" + "time" + "github.com/foliagecp/easyjson" "github.com/foliagecp/sdk/clients/go/db" graphCRUD "github.com/foliagecp/sdk/embedded/graph/crud" @@ -13,8 +16,6 @@ import ( lg "github.com/foliagecp/sdk/statefun/logger" sfPlugins "github.com/foliagecp/sdk/statefun/plugins" "github.com/nats-io/nats.go" - "strings" - "time" graphDebug "github.com/foliagecp/sdk/embedded/graph/debug" "github.com/foliagecp/sdk/embedded/graph/jpgql" diff --git a/tests/object/object.go b/tests/object/object.go index 4c700ab4..29f2a7d7 100644 --- a/tests/object/object.go +++ b/tests/object/object.go @@ -5,6 +5,7 @@ package main import ( "context" "fmt" + "github.com/foliagecp/sdk/clients/go/db" "github.com/foliagecp/sdk/embedded/graph/graphql" sfPlugins "github.com/foliagecp/sdk/statefun/plugins" diff --git a/tests/shadow/Dockerfile b/tests/shadow/Dockerfile new file mode 100644 index 00000000..3626e070 --- /dev/null +++ b/tests/shadow/Dockerfile @@ -0,0 +1,25 @@ +FROM golang:1.21 as builder + +WORKDIR /usr/src/app + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && apt-get upgrade -y && apt-get install -y \ + build-essential gcc + +COPY . . + +RUN go mod tidy + +RUN cd ./tests/shadow && go build -o /usr/bin/foliage + +FROM ubuntu:22.04 + +WORKDIR /foliage + +RUN apt update && \ + apt install ca-certificates curl -y && \ + rm -rf /var/lib/apt/lists/* + +COPY --from=builder /usr/bin/foliage /usr/bin/ + diff --git a/tests/shadow/configs/grafana/dashboards.yaml b/tests/shadow/configs/grafana/dashboards.yaml new file mode 100644 index 00000000..fd66a479 --- /dev/null +++ b/tests/shadow/configs/grafana/dashboards.yaml @@ -0,0 +1,12 @@ +apiVersion: 1 + +providers: + - name: "Dashboard provider" + orgId: 1 + type: file + disableDeletion: false + updateIntervalSeconds: 10 + allowUiUpdates: false + options: + path: /var/lib/grafana/dashboards + foldersFromFilesStructure: true diff --git a/tests/shadow/configs/grafana/dashboards/foliage-graph-api.json b/tests/shadow/configs/grafana/dashboards/foliage-graph-api.json new file mode 100644 index 00000000..e6e9c6a6 --- /dev/null +++ b/tests/shadow/configs/grafana/dashboards/foliage-graph-api.json @@ -0,0 +1,666 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": { + "type": "grafana", + "uid": "-- Grafana --" + }, + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 0, + "id": 4, + "links": [], + "liveNow": false, + "panels": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 1, + "pointSize": 4, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "µs" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 8, + "x": 0, + "y": 0 + }, + "id": 1, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "topk(10, functionsgraphapivertexcreate_execution_time)", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{id}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Vertex Create", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 1, + "pointSize": 4, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "µs" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 8, + "x": 8, + "y": 0 + }, + "id": 2, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "topk(10, functionsgraphapivertexupdate_execution_time)", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{id}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Vertex Update", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 1, + "pointSize": 4, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "µs" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 8, + "x": 16, + "y": 0 + }, + "id": 3, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "topk(10, functionsgraphapivertexdelete_execution_time)", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{id}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Vertex Delete", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 1, + "pointSize": 4, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "µs" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 8, + "x": 0, + "y": 10 + }, + "id": 4, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "topk(10, functionsgraphapilinkcreate_execution_time)", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{id}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Link Create", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 1, + "pointSize": 4, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "µs" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 8, + "x": 8, + "y": 10 + }, + "id": 5, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "topk(10, functionsgraphapilinkupdate_execution_time)", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{id}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Link Create", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 1, + "pointSize": 4, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "µs" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 8, + "x": 16, + "y": 10 + }, + "id": 6, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "topk(10, functionsgraphapilinkdelete_execution_time)", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{id}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Link Delete", + "type": "timeseries" + } + ], + "refresh": "5s", + "schemaVersion": 38, + "tags": [], + "templating": { + "list": [] + }, + "time": { + "from": "now-5m", + "to": "now" + }, + "timepicker": {}, + "timezone": "", + "title": "Foliage Graph API", + "uid": "f20e8a66-516a-44db-8461-f96dc9489325", + "version": 3, + "weekStart": "" +} \ No newline at end of file diff --git a/tests/shadow/configs/grafana/dashboards/foliage-runtimes.json b/tests/shadow/configs/grafana/dashboards/foliage-runtimes.json new file mode 100644 index 00000000..4781f529 --- /dev/null +++ b/tests/shadow/configs/grafana/dashboards/foliage-runtimes.json @@ -0,0 +1,670 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": { + "type": "grafana", + "uid": "-- Grafana --" + }, + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 0, + "links": [], + "liveNow": false, + "panels": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 0, + "y": 0 + }, + "id": 1, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "cache_values{instance=\"$instance\"}", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{id}}, {{instance}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Cache Store Values", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "µs" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 8, + "y": 0 + }, + "id": 3, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "cache_get_keys_by_pattern{instance=\"$instance\"}", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{id}}, {{instance}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Cache Get Keys by Value Duration", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 4, + "x": 16, + "y": 0 + }, + "id": 4, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "fg_runtime_routines_counter{instance=\"$instance\"}", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{instance}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Total Go Runtime Routines", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 4, + "x": 20, + "y": 0 + }, + "id": 5, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "fg_runtime_mem_alloc_bytes{instance=\"$instance\"}", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{instance}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Allocated Memory", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 8, + "x": 0, + "y": 8 + }, + "id": 2, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "stetefun_instances{instance=\"$instance\"}", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{typename}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Statefun Instances", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 8, + "x": 16, + "y": 8 + }, + "id": 6, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "fg_runtime_routines", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{routine_type_name}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Foliage Routines By Type", + "type": "timeseries" + } + ], + "refresh": "5s", + "schemaVersion": 38, + "tags": [], + "templating": { + "list": [ + { + "current": { + "selected": true, + "text": [ + "runtime:9901" + ], + "value": [ + "runtime:9901" + ] + }, + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "definition": "label_values({job=\"foliage-runtimes\"},instance)", + "hide": 0, + "includeAll": false, + "label": "Instance", + "multi": true, + "name": "instance", + "options": [], + "query": { + "qryType": 1, + "query": "label_values({job=\"foliage-runtimes\"},instance)", + "refId": "PrometheusVariableQueryEditor-VariableQuery" + }, + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "type": "query" + } + ] + }, + "time": { + "from": "now-5m", + "to": "now" + }, + "timepicker": {}, + "timezone": "", + "title": "Foliage Runtimes", + "uid": "e26cc7cc-fbb9-455a-a738-d5750fc11e1a", + "version": 1, + "weekStart": "" +} \ No newline at end of file diff --git a/tests/shadow/configs/grafana/dashboards/foliage-transactions.json b/tests/shadow/configs/grafana/dashboards/foliage-transactions.json new file mode 100644 index 00000000..0f182222 --- /dev/null +++ b/tests/shadow/configs/grafana/dashboards/foliage-transactions.json @@ -0,0 +1,1690 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": { + "type": "grafana", + "uid": "-- Grafana --" + }, + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 0, + "id": 3, + "links": [], + "liveNow": false, + "panels": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 1, + "pointSize": 4, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "µs" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 6, + "x": 0, + "y": 0 + }, + "id": 1, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "functionscmdbtxbegin_execution_time", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{id}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Begin", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "continuous-GrYlRd" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 1, + "pointSize": 4, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "µs" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 6, + "x": 6, + "y": 0 + }, + "id": 7, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "functionscmdbtxbegin_clone_execution_time", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{type}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Clone", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 1, + "pointSize": 4, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "µs" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 6, + "x": 12, + "y": 0 + }, + "id": 4, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "functionscmdbtxcommit_execution_time", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{id}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Commit", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 1, + "pointSize": 4, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "µs" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 6, + "x": 18, + "y": 0 + }, + "id": 5, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "functionscmdbtxpush_execution_time", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{id}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Push", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 1, + "pointSize": 4, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "µs" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 4, + "x": 0, + "y": 8 + }, + "id": 3, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "functionscmdbtxobjectcreate_execution_time", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{id}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Object Create", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 1, + "pointSize": 4, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "µs" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 4, + "x": 4, + "y": 8 + }, + "id": 13, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "functionscmdbtxobjectcreate_execution_time", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{id}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Object Create", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 1, + "pointSize": 4, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "µs" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 4, + "x": 8, + "y": 8 + }, + "id": 9, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "functionscmdbtxobjectdelete_execution_time", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{id}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Object Delete", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 1, + "pointSize": 4, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "µs" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 4, + "x": 12, + "y": 8 + }, + "id": 10, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "functionscmdbtxtypecreate_execution_time", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{id}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Type Create", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 1, + "pointSize": 4, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "µs" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 4, + "x": 16, + "y": 8 + }, + "id": 11, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "functionscmdbtxtypeupdate_execution_time", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{id}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Type Update", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 1, + "pointSize": 4, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "µs" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 4, + "x": 20, + "y": 8 + }, + "id": 12, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "functionscmdbtxtypedelete_execution_time", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{id}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Object Create", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 1, + "pointSize": 4, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "µs" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 4, + "x": 0, + "y": 14 + }, + "id": 8, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "functionscmdbtxobjectslinkcreate_execution_time", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{id}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Objects Links Create", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 1, + "pointSize": 4, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "µs" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 4, + "x": 4, + "y": 14 + }, + "id": 14, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "functionscmdbtxobjectslinkupdate_execution_time", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{id}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Objects Links Update", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 1, + "pointSize": 4, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "µs" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 4, + "x": 8, + "y": 14 + }, + "id": 15, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "functionscmdbtxobjectslinkdelete_execution_time", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{id}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Objects Links Delete", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 1, + "pointSize": 4, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "µs" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 4, + "x": 12, + "y": 14 + }, + "id": 16, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "functionscmdbtxtypeslinkcreate_execution_time", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{id}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Types Links Create", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 1, + "pointSize": 4, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "µs" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 4, + "x": 16, + "y": 14 + }, + "id": 17, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "functionscmdbtxtypeslinkupdate_execution_time", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{id}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Types Links Update", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 1, + "pointSize": 4, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "µs" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 4, + "x": 20, + "y": 14 + }, + "id": 18, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "functionscmdbtxtypeslinkdelete_execution_time", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{id}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Types Links Delete", + "type": "timeseries" + } + ], + "refresh": "5s", + "schemaVersion": 38, + "tags": [], + "templating": { + "list": [] + }, + "time": { + "from": "now-5m", + "to": "now" + }, + "timepicker": {}, + "timezone": "", + "title": "Foliage Transactions", + "uid": "f20e8a66-516a-44db-8461-f96dc9489324", + "version": 3, + "weekStart": "" +} \ No newline at end of file diff --git a/tests/shadow/configs/grafana/dashboards/grafana-jetstream-dash.json b/tests/shadow/configs/grafana/dashboards/grafana-jetstream-dash.json new file mode 100644 index 00000000..10ef1017 --- /dev/null +++ b/tests/shadow/configs/grafana/dashboards/grafana-jetstream-dash.json @@ -0,0 +1,1429 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": { + "type": "datasource", + "uid": "grafana" + }, + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "target": { + "limit": 100, + "matchAny": false, + "tags": [], + "type": "dashboard" + }, + "type": "dashboard" + } + ] + }, + "description": "NATS JetStream Dashboard", + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 1, + "links": [], + "liveNow": false, + "panels": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "decimals": 3, + "mappings": [], + "max": 1, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "#EAB839", + "value": 0.75 + }, + { + "color": "red", + "value": 0.9 + } + ] + }, + "unit": "percentunit" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 4, + "x": 0, + "y": 0 + }, + "id": 28, + "options": { + "minVizHeight": 75, + "minVizWidth": 75, + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true + }, + "pluginVersion": "10.2.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "expr": "sum(gnatsd_varz_jetstream_stats_storage{server_id=~\"$server\"})/sum(gnatsd_varz_jetstream_config_max_storage{server_id=~\"$server\"})", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "title": "Storage Used", + "type": "gauge" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "mappings": [], + "min": 0, + "thresholds": { + "mode": "percentage", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 5, + "x": 4, + "y": 0 + }, + "id": 15, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "10.2.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "expr": "sum(gnatsd_varz_jetstream_stats_storage{server_id=~\"$server\"})", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "title": "Total Storage Used", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "decimals": 3, + "mappings": [], + "max": 1, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "#EAB839", + "value": 0.75 + }, + { + "color": "red", + "value": 0.9 + } + ] + }, + "unit": "percentunit" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 4, + "x": 9, + "y": 0 + }, + "id": 31, + "options": { + "minVizHeight": 75, + "minVizWidth": 75, + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true + }, + "pluginVersion": "10.2.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "expr": "sum(gnatsd_varz_jetstream_stats_memory{server_id=~\"$server\"})/sum(gnatsd_varz_jetstream_config_max_memory{server_id=~\"$server\"})", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "title": "Memory Used", + "type": "gauge" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "mappings": [], + "min": 0, + "thresholds": { + "mode": "percentage", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 5, + "x": 13, + "y": 0 + }, + "id": 32, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "10.2.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "expr": "sum(gnatsd_varz_jetstream_stats_memory{server_id=~\"$server\"})", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "title": "Memory Used", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "mappings": [], + "min": 0, + "noValue": "0", + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 6, + "x": 18, + "y": 0 + }, + "id": 14, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "10.2.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "expr": "sum(gnatsd_varz_connections{server_id=~\"$server\"})", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "title": "Connections", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "mappings": [], + "min": 0, + "thresholds": { + "mode": "percentage", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 5, + "x": 4, + "y": 3 + }, + "id": 30, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "10.2.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "expr": "sum(gnatsd_varz_jetstream_config_max_storage{server_id=~\"$server\"})", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "title": "Max Storage", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "mappings": [], + "min": 0, + "thresholds": { + "mode": "percentage", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 5, + "x": 13, + "y": 3 + }, + "id": 33, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "10.2.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "expr": "sum(gnatsd_varz_jetstream_config_max_memory{server_id=~\"$server\"})", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "title": "Total Memory", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 6, + "x": 18, + "y": 3 + }, + "id": 29, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "10.2.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "expr": "sum(jetstream_server_total_consumers{server_id=~\"$server\"})", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "title": "Total Consumers", + "type": "stat" + }, + { + "collapsed": false, + "datasource": { + "type": "datasource", + "uid": "grafana" + }, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 6 + }, + "id": 19, + "panels": [], + "targets": [ + { + "datasource": { + "type": "datasource", + "uid": "grafana" + }, + "refId": "A" + } + ], + "title": "Stream metrics", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": true, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 8, + "x": 0, + "y": 7 + }, + "id": 17, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "8.3.4", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "sum(jetstream_stream_total_bytes) by (stream_name)", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "__auto", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Stream data size", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": true, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 8, + "x": 8, + "y": 7 + }, + "id": 24, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "8.3.4", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "editorMode": "code", + "expr": "sum(jetstream_stream_total_messages) by (stream_name)", + "interval": "", + "legendFormat": "{{stream_name}}", + "range": true, + "refId": "A" + } + ], + "title": "Stream message count", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": true, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "mps" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 8, + "x": 16, + "y": 7 + }, + "id": 20, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "8.3.4", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "expr": "sum(rate(jetstream_stream_total_messages{server_id=~\"$server\",stream_name=~\"$stream\"}[$__rate_interval])) by (stream_name)", + "hide": false, + "interval": "", + "legendFormat": "{{stream_name}}", + "refId": "A" + } + ], + "title": "Message Rate (per second)", + "type": "timeseries" + }, + { + "collapsed": false, + "datasource": { + "type": "datasource", + "uid": "grafana" + }, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 13 + }, + "id": 23, + "panels": [], + "targets": [ + { + "datasource": { + "type": "datasource", + "uid": "grafana" + }, + "refId": "A" + } + ], + "title": "Consumer Metrics", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "description": "Messages added & processed per minute per consumer", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": true, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "mps" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 24, + "x": 0, + "y": 14 + }, + "id": 25, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "right", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "8.3.4", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "editorMode": "code", + "expr": "sum(rate(jetstream_consumer_num_pending{server_id=~\"$server\",stream_name=~\"$stream\",consumer_name=~\"$consumer\"}[$__rate_interval])+rate(jetstream_consumer_delivered_consumer_seq{server_id=~\"$server\",stream_name=~\"$stream\",consumer_name=~\"$consumer\"}[$__rate_interval])) by (consumer_name)", + "hide": false, + "instant": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "{{consumer_name}} +", + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "editorMode": "code", + "expr": "- sum(rate(jetstream_consumer_delivered_consumer_seq{server_id=~\"$server\",stream_name=~\"$stream\",consumer_name=~\"$consumer\",consumer_name=~\"$consumer\"}[$__rate_interval])) by (consumer_name)", + "hide": false, + "interval": "", + "legendFormat": "{{consumer_name}} -", + "range": true, + "refId": "B" + } + ], + "title": "Messages per second (++/--)", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": true, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 8, + "x": 0, + "y": 20 + }, + "id": 21, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "8.3.4", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "expr": "sum(jetstream_consumer_delivered_consumer_seq{server_id=~\"$server\",stream_name=~\"$stream\",consumer_name=~\"$consumer\"}) by (consumer_name)", + "hide": false, + "interval": "", + "legendFormat": "{{consumer_name}}", + "refId": "A" + } + ], + "title": "Total delivered messages", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": true, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 8, + "x": 8, + "y": 20 + }, + "id": 26, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "8.3.4", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "expr": "sum(jetstream_consumer_num_pending{server_id=~\"$server\",stream_name=~\"$stream\",consumer_name=~\"$consumer\"}) by (consumer_name)", + "hide": false, + "interval": "", + "legendFormat": "{{consumer_name}}", + "refId": "A" + } + ], + "title": "Pending messages", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": true, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 8, + "x": 16, + "y": 20 + }, + "id": 27, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "8.3.4", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "expr": "sum(jetstream_consumer_num_ack_pending{server_id=~\"$server\",stream_name=~\"$stream\",consumer_name=~\"$consumer\"}) by (consumer_name)", + "hide": false, + "interval": "", + "legendFormat": "{{consumer_name}}", + "refId": "A" + } + ], + "title": "Message Acks Pending", + "type": "timeseries" + } + ], + "refresh": "10s", + "schemaVersion": 38, + "tags": [], + "templating": { + "list": [ + { + "current": { + "selected": true, + "text": [ + "All" + ], + "value": [ + "$__all" + ] + }, + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "definition": "label_values(jetstream_server_total_streams, server_id)", + "hide": 0, + "includeAll": true, + "label": "Server", + "multi": true, + "name": "server", + "options": [], + "query": { + "query": "label_values(jetstream_server_total_streams, server_id)", + "refId": "StandardVariableQuery" + }, + "refresh": 2, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "current": { + "selected": true, + "text": [ + "All" + ], + "value": [ + "$__all" + ] + }, + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "definition": "label_values(jetstream_stream_last_seq, stream_name)", + "hide": 0, + "includeAll": true, + "label": "Stream", + "multi": true, + "name": "stream", + "options": [], + "query": { + "query": "label_values(jetstream_stream_last_seq, stream_name)", + "refId": "StandardVariableQuery" + }, + "refresh": 2, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "current": { + "selected": true, + "text": [ + "All" + ], + "value": [ + "$__all" + ] + }, + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "definition": "label_values(jetstream_consumer_num_pending, consumer_name)", + "hide": 0, + "includeAll": true, + "label": "Consumer", + "multi": true, + "name": "consumer", + "options": [], + "query": { + "query": "label_values(jetstream_consumer_num_pending, consumer_name)", + "refId": "StandardVariableQuery" + }, + "refresh": 2, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tagsQuery": "", + "type": "query", + "useTags": false + } + ] + }, + "time": { + "from": "now-5m", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "browser", + "title": "NATS JetStream", + "uid": "yQUo5l17k", + "version": 2, + "weekStart": "" +} diff --git a/tests/shadow/configs/grafana/dashboards/grafana-nats-dash.json b/tests/shadow/configs/grafana/dashboards/grafana-nats-dash.json new file mode 100644 index 00000000..ecbc8801 --- /dev/null +++ b/tests/shadow/configs/grafana/dashboards/grafana-nats-dash.json @@ -0,0 +1,1152 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": { + "type": "datasource", + "uid": "grafana" + }, + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "target": { + "limit": 100, + "matchAny": false, + "tags": [], + "type": "dashboard" + }, + "type": "dashboard" + } + ] + }, + "description": "NATS Server Dashboard", + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 0, + "id": 2, + "links": [], + "liveNow": false, + "panels": [ + { + "collapsed": false, + "datasource": { + "type": "datasource", + "uid": "grafana" + }, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 10, + "panels": [], + "targets": [ + { + "datasource": { + "type": "datasource", + "uid": "grafana" + }, + "refId": "A" + } + ], + "title": "OS Metrics", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "percent" + }, + "overrides": [] + }, + "gridPos": { + "h": 7, + "w": 12, + "x": 0, + "y": 1 + }, + "id": 1, + "links": [], + "options": { + "legend": { + "calcs": [ + "mean", + "lastNotNull", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "8.3.4", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "gnatsd_varz_cpu{server_id=\"$server\"}", + "fullMetaSearch": false, + "includeNullMetadata": true, + "intervalFactor": 2, + "legendFormat": "{{server_id}}", + "metric": "gnatsd_varz_cpu", + "range": true, + "refId": "A", + "step": 4, + "useBackend": false + } + ], + "title": "Server CPU", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 7, + "w": 12, + "x": 12, + "y": 1 + }, + "id": 3, + "links": [], + "options": { + "legend": { + "calcs": [ + "mean", + "lastNotNull", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "8.3.4", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "gnatsd_varz_mem{server_id=\"$server\"}", + "fullMetaSearch": false, + "includeNullMetadata": true, + "intervalFactor": 2, + "legendFormat": "{{server_id}}", + "metric": "gnatsd_varz_mem", + "range": true, + "refId": "A", + "step": 4, + "useBackend": false + } + ], + "title": "Server Memory", + "type": "timeseries" + }, + { + "collapsed": false, + "datasource": { + "type": "datasource", + "uid": "grafana" + }, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 8 + }, + "id": 11, + "panels": [], + "targets": [ + { + "datasource": { + "type": "datasource", + "uid": "grafana" + }, + "refId": "A" + } + ], + "title": "Throughput", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 7, + "w": 6, + "x": 0, + "y": 9 + }, + "id": 7, + "links": [], + "options": { + "legend": { + "calcs": [ + "lastNotNull" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "8.3.4", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "gnatsd_varz_in_bytes{server_id=\"$server\"}", + "fullMetaSearch": false, + "includeNullMetadata": true, + "intervalFactor": 2, + "legendFormat": "{{server_id}}", + "metric": "gnatsd_varz_in_bytes", + "range": true, + "refId": "A", + "step": 10, + "useBackend": false + } + ], + "title": "Bytes In", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 7, + "w": 6, + "x": 6, + "y": 9 + }, + "id": 8, + "links": [], + "options": { + "legend": { + "calcs": [ + "lastNotNull" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "8.3.4", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "gnatsd_varz_in_msgs{server_id=\"$server\"}", + "fullMetaSearch": false, + "includeNullMetadata": true, + "intervalFactor": 2, + "legendFormat": "{{server_id}}", + "metric": "gnatsd_varz_in_msgs", + "range": true, + "refId": "A", + "step": 10, + "useBackend": false + } + ], + "title": "NATS Msgs In", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 7, + "w": 6, + "x": 12, + "y": 9 + }, + "id": 5, + "links": [], + "options": { + "legend": { + "calcs": [ + "lastNotNull" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "8.3.4", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "gnatsd_varz_out_bytes{server_id=\"$server\"}", + "fullMetaSearch": false, + "includeNullMetadata": true, + "intervalFactor": 2, + "legendFormat": "{{server_id}}", + "metric": "gnatsd_varz_out_bytes", + "range": true, + "refId": "A", + "step": 10, + "useBackend": false + } + ], + "title": "Bytes Out", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 7, + "w": 6, + "x": 18, + "y": 9 + }, + "id": 6, + "links": [], + "options": { + "legend": { + "calcs": [ + "lastNotNull" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "8.3.4", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "gnatsd_varz_out_msgs{server_id=\"$server\"}", + "fullMetaSearch": false, + "includeNullMetadata": true, + "intervalFactor": 2, + "legendFormat": "{{server_id}}", + "metric": "gnatsd_varz_out_msgs", + "range": true, + "refId": "A", + "step": 10, + "useBackend": false + } + ], + "title": "NATS Msgs Out", + "type": "timeseries" + }, + { + "collapsed": false, + "datasource": { + "type": "datasource", + "uid": "grafana" + }, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 16 + }, + "id": 12, + "panels": [], + "targets": [ + { + "datasource": { + "type": "datasource", + "uid": "grafana" + }, + "refId": "A" + } + ], + "title": "Client Metrics", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "points", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 2, + "pointSize": 6, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "always", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 7, + "w": 8, + "x": 0, + "y": 17 + }, + "id": 2, + "links": [], + "options": { + "legend": { + "calcs": [ + "mean", + "lastNotNull", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "8.3.4", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "gnatsd_varz_connections{server_id=\"$server\"}", + "fullMetaSearch": false, + "includeNullMetadata": true, + "intervalFactor": 1, + "legendFormat": "{{server_id}}", + "metric": "gnatsd_varz_connections", + "range": true, + "refId": "A", + "step": 2, + "useBackend": false + } + ], + "title": "Connections", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "points", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 2, + "pointSize": 6, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "always", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 7, + "w": 8, + "x": 8, + "y": 17 + }, + "id": 4, + "links": [], + "options": { + "legend": { + "calcs": [ + "mean", + "lastNotNull", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "8.3.4", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "gnatsd_varz_subscriptions{server_id=\"$server\"}", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "intervalFactor": 2, + "legendFormat": "{{server_id}}", + "metric": "gnatsd_varz_subscriptions", + "range": true, + "refId": "A", + "step": 4, + "useBackend": false + } + ], + "title": "Subscriptions", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "points", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 2, + "pointSize": 6, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "always", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 7, + "w": 8, + "x": 16, + "y": 17 + }, + "id": 9, + "links": [], + "options": { + "legend": { + "calcs": [ + "mean", + "lastNotNull", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "8.3.4", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "gnatsd_varz_slow_consumers{server_id=\"$server\"}", + "fullMetaSearch": false, + "includeNullMetadata": true, + "intervalFactor": 1, + "legendFormat": "{{server_id}}", + "metric": "gnatsd_varz_slow_consumers", + "range": true, + "refId": "A", + "step": 2, + "useBackend": false + } + ], + "title": "Slow Consumers", + "type": "timeseries" + } + ], + "refresh": "", + "schemaVersion": 38, + "tags": [], + "templating": { + "list": [ + { + "current": { + "selected": true, + "text": [ + "http://nats:8222" + ], + "value": [ + "http://nats:8222" + ] + }, + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "definition": "label_values(server_id)", + "hide": 0, + "includeAll": false, + "label": "Server", + "multi": true, + "name": "server", + "options": [], + "query": { + "qryType": 1, + "query": "label_values(server_id)", + "refId": "PrometheusVariableQueryEditor-VariableQuery" + }, + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "type": "query" + } + ] + }, + "time": { + "from": "now-5m", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "browser", + "title": "NATS Servers", + "uid": "Usc6F_1nk", + "version": 4, + "weekStart": "" +} \ No newline at end of file diff --git a/tests/shadow/configs/grafana/datasources.yaml b/tests/shadow/configs/grafana/datasources.yaml new file mode 100644 index 00000000..fb9febbb --- /dev/null +++ b/tests/shadow/configs/grafana/datasources.yaml @@ -0,0 +1,12 @@ +apiVersion: 1 + +datasources: + - access: 'proxy' # make grafana perform the requests + editable: true # whether it should be editable + is_default: true # whether this should be the default DS + name: 'Prometheus' # name of the datasource + org_id: 1 # id of the organization to tie this datasource to + type: 'prometheus' # type of the data source + url: 'http://prometheus:9090' # url of the prom instance + database: 'prometheus' + version: 1 # well, versioning \ No newline at end of file diff --git a/tests/shadow/configs/hub.env b/tests/shadow/configs/hub.env new file mode 100644 index 00000000..04d1f688 --- /dev/null +++ b/tests/shadow/configs/hub.env @@ -0,0 +1,8 @@ +NATS_URL=nats://nats:foliage@nats-hub:4222 +MASTER_FUNC_CONTEXT_INCREMENT=true +MASTER_FUNC_CONTEXT_INCREMENT_OPTION=1 +MASTER_FUNC_LOGS=true +PROMETRICS_PORT=9901 + +CREATE_SIMPLE_GRAPH_TEST=true +TRIGGERS_TEST=true \ No newline at end of file diff --git a/tests/shadow/configs/leaf1.env b/tests/shadow/configs/leaf1.env new file mode 100644 index 00000000..d33df093 --- /dev/null +++ b/tests/shadow/configs/leaf1.env @@ -0,0 +1,7 @@ +NATS_URL=nats://nats:foliage@nats-leaf1:4223 +MASTER_FUNC_CONTEXT_INCREMENT=true +MASTER_FUNC_CONTEXT_INCREMENT_OPTION=1 +MASTER_FUNC_LOGS=true +PROMETRICS_PORT=9902 + +TRIGGERS_TEST=true \ No newline at end of file diff --git a/tests/shadow/configs/leaf2.env b/tests/shadow/configs/leaf2.env new file mode 100644 index 00000000..86d47bed --- /dev/null +++ b/tests/shadow/configs/leaf2.env @@ -0,0 +1,7 @@ +NATS_URL=nats://nats:foliage@nats-leaf2:4223 +MASTER_FUNC_CONTEXT_INCREMENT=true +MASTER_FUNC_CONTEXT_INCREMENT_OPTION=1 +MASTER_FUNC_LOGS=true +PROMETRICS_PORT=9902 + +TRIGGERS_TEST=true \ No newline at end of file diff --git a/tests/shadow/configs/leaf3.env b/tests/shadow/configs/leaf3.env new file mode 100644 index 00000000..7fe77d02 --- /dev/null +++ b/tests/shadow/configs/leaf3.env @@ -0,0 +1,7 @@ +NATS_URL=nats://nats:foliage@nats-leaf3:4223 +MASTER_FUNC_CONTEXT_INCREMENT=true +MASTER_FUNC_CONTEXT_INCREMENT_OPTION=1 +MASTER_FUNC_LOGS=true +PROMETRICS_PORT=9902 + +TRIGGERS_TEST=true \ No newline at end of file diff --git a/tests/shadow/configs/nats/auth.conf b/tests/shadow/configs/nats/auth.conf new file mode 100644 index 00000000..223f687b --- /dev/null +++ b/tests/shadow/configs/nats/auth.conf @@ -0,0 +1,8 @@ +authorization { + users = [ + { + user: "nats" + password: "foliage" + } + ] +} \ No newline at end of file diff --git a/tests/shadow/configs/nats/hub.conf b/tests/shadow/configs/nats/hub.conf new file mode 100644 index 00000000..9af96fbc --- /dev/null +++ b/tests/shadow/configs/nats/hub.conf @@ -0,0 +1,15 @@ +port: 4222 +http_port: 8222 +websocket: { + port: 443 + no_tls: true +} +jetstream { + store_dir: /data/jetstream + domain: "hub" + max_file_store: 40G +} +leafnodes { + port: 7422 +} +include ./auth.conf \ No newline at end of file diff --git a/tests/shadow/configs/nats/leaf1.conf b/tests/shadow/configs/nats/leaf1.conf new file mode 100644 index 00000000..cb7dbb00 --- /dev/null +++ b/tests/shadow/configs/nats/leaf1.conf @@ -0,0 +1,15 @@ +port: 4223 +http_port: 8223 +jetstream { + store_dir: /data/jetstream + domain: "leaf1" + max_file_store: 40G +} +leafnodes { + remotes = [ + { + url: "nats://nats:foliage@nats-hub:7422" + } + ] +} +include ./auth.conf \ No newline at end of file diff --git a/tests/shadow/configs/nats/leaf2.conf b/tests/shadow/configs/nats/leaf2.conf new file mode 100644 index 00000000..811d4dec --- /dev/null +++ b/tests/shadow/configs/nats/leaf2.conf @@ -0,0 +1,15 @@ +port: 4223 +http_port: 8223 +jetstream { + store_dir: /data/jetstream + domain: "leaf2" + max_file_store: 40G +} +leafnodes { + remotes = [ + { + url: "nats://nats:foliage@nats-hub:7422" + } + ] +} +include ./auth.conf \ No newline at end of file diff --git a/tests/shadow/configs/nats/leaf3.conf b/tests/shadow/configs/nats/leaf3.conf new file mode 100644 index 00000000..abfba3a0 --- /dev/null +++ b/tests/shadow/configs/nats/leaf3.conf @@ -0,0 +1,15 @@ +port: 4223 +http_port: 8223 +jetstream { + store_dir: /data/jetstream + domain: "leaf3" + max_file_store: 40G +} +leafnodes { + remotes = [ + { + url: "nats://nats:foliage@nats-hub:7422" + } + ] +} +include ./auth.conf \ No newline at end of file diff --git a/tests/shadow/configs/prometheus/prometheus.yml b/tests/shadow/configs/prometheus/prometheus.yml new file mode 100644 index 00000000..4989b008 --- /dev/null +++ b/tests/shadow/configs/prometheus/prometheus.yml @@ -0,0 +1,18 @@ +global: + scrape_interval: 5s # By default, scrape targets every 5 seconds. + + # Attach these labels to any time series or alerts when communicating with + # external systems (federation, remote storage, Alertmanager). + external_labels: + monitor: 'nats-servers' + +# A scrape configuration containing exactly one endpoint to scrape: +scrape_configs: + # The job name is added as a label `job=` to any timeseries scraped from this config. + - job_name: 'nats-servers' + static_configs: + - targets: ['nats-exporter-hub:7777', 'nats-exporter-leaf:7778'] + + - job_name: 'foliage-runtimes' + static_configs: + - targets: ['runtime-hub:9901', 'runtime-leaf:9902'] diff --git a/tests/shadow/docker-compose.yaml b/tests/shadow/docker-compose.yaml new file mode 100644 index 00000000..f955ed6e --- /dev/null +++ b/tests/shadow/docker-compose.yaml @@ -0,0 +1,140 @@ +services: + nats-hub: + image: nats:latest + command: -c /etc/nats/hub.conf + ports: + - "4222:4222" + - "6222:6222" + - "8222:8222" + - "7422:7422" + volumes: + - ./configs/nats/:/etc/nats/ + + nats-leaf1: + image: nats:latest + command: -c /etc/nats/leaf1.conf + ports: + - "4223:4223" + - "6223:6223" + - "8223:8223" + depends_on: + - nats-hub + volumes: + - ./configs/nats/:/etc/nats/ + + nats-leaf2: + image: nats:latest + command: -c /etc/nats/leaf2.conf + ports: + - "4224:4223" + - "6224:6223" + - "8224:8223" + depends_on: + - nats-hub + volumes: + - ./configs/nats/:/etc/nats/ + + nats-leaf3: + image: nats:latest + command: -c /etc/nats/leaf3.conf + ports: + - "4225:4223" + - "6225:6223" + - "8225:8223" + depends_on: + - nats-hub + volumes: + - ./configs/nats/:/etc/nats/ + + io: + image: natsio/nats-box:latest + entrypoint: + - /bin/sh + tty: true + depends_on: + - nats-hub + + runtime-hub: + image: foliage-sdk-tests-shadow:latest + command: /usr/bin/foliage -ll 5 + ports: + - "9901:9901" + env_file: ./configs/hub.env + depends_on: + - nats-leaf1 + - nats-leaf2 + - nats-leaf3 + build: + context: ../.. + dockerfile: tests/shadow/Dockerfile + + runtime-leaf1: + image: foliage-sdk-tests-shadow:latest + command: /usr/bin/foliage -ll 5 + ports: + - "9902:9902" + env_file: ./configs/leaf1.env + depends_on: + - runtime-hub + - nats-leaf1 + build: + context: ../.. + dockerfile: tests/shadow/Dockerfile + + runtime-leaf2: + image: foliage-sdk-tests-shadow:latest + command: /usr/bin/foliage -ll 5 + ports: + - "9903:9902" + env_file: ./configs/leaf2.env + depends_on: + - runtime-hub + - nats-leaf2 + build: + context: ../.. + dockerfile: tests/shadow/Dockerfile + + runtime-leaf3: + image: foliage-sdk-tests-shadow:latest + command: /usr/bin/foliage -ll 5 + ports: + - "9904:9902" + env_file: ./configs/leaf3.env + depends_on: + - runtime-hub + - nats-leaf3 + build: + context: ../.. + dockerfile: tests/shadow/Dockerfile + +# nats-exporter-hub: +# image: natsio/prometheus-nats-exporter:latest +# depends_on: +# - nats-hub +# ports: +# - '7777:7777' +# command: -varz -jsz=all http://nats-hub:8222 +# +# nats-exporter-leaf: +# image: natsio/prometheus-nats-exporter:latest +# depends_on: +# - nats-leaf +# ports: +# - '7778:7778' +# command: -varz -jsz=all http://nats-leaf:8223 +# +# prometheus: +# image: prom/prometheus +# ports: +# - 9090:9090 +# volumes: +# - ./configs/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml +# +# grafana: +# ports: +# - '3000:3000' +# image: grafana/grafana-enterprise +# volumes: +# - ./configs/grafana/dashboards.yaml:/etc/grafana/provisioning/dashboards/main.yaml +# - ./configs/grafana/datasources.yaml:/etc/grafana/provisioning/datasources/main.yaml +# - ./configs/grafana/dashboards:/var/lib/grafana/dashboards \ No newline at end of file diff --git a/tests/shadow/main.go b/tests/shadow/main.go new file mode 100644 index 00000000..ee0f3a54 --- /dev/null +++ b/tests/shadow/main.go @@ -0,0 +1,61 @@ +// Foliage tests main package. +// Provides configurable running of different test samples that goes along with the SDK. +package main + +import ( + "flag" + "fmt" + "os" + + lg "github.com/foliagecp/sdk/statefun/logger" +) + +func main() { + helpFlag := + flag.Bool( + "h", + false, + "Show help message", + ) + helpFlagAlias := + flag.Bool( + "help", + false, + "Show help message (alias)", + ) + logLevelFlag := + flag.Int( + "ll", + int(lg.InfoLevel), // == 2 + "Log level [0;6]: panic, fatal, error, warn, info, debug, trace", + ) + logReportCallerFlag := + flag.Bool( + "lrp", + false, + "Log report caller shows file name and line number where log originates from", + ) + + flag.Parse() + + if *helpFlag || *helpFlagAlias { + fmt.Println("usage: foliage [option]") + fmt.Println("Options:") + flag.PrintDefaults() + return + } + + if *logLevelFlag < -2 || *logLevelFlag > 6 { + fmt.Println("Please select logging level from [0;6]") + return + } + + lg.SetDefaultOptions( + os.Stdout, + // subtract and multiply, because each level has a factor of 4: -8, -4, 0, 4, 8, 12, 16 + lg.LogLevel((4-*logLevelFlag)*4), + *logReportCallerFlag, + ) + + Start() +} diff --git a/tests/shadow/shadow.go b/tests/shadow/shadow.go new file mode 100644 index 00000000..c00fe4bb --- /dev/null +++ b/tests/shadow/shadow.go @@ -0,0 +1,81 @@ +// Foliage basic test package. +// Provides the basic example of usage of the SDK. +package main + +import ( + "context" + "time" + + "github.com/foliagecp/sdk/clients/go/db" + graphCRUD "github.com/foliagecp/sdk/embedded/graph/crud" + + graphDebug "github.com/foliagecp/sdk/embedded/graph/debug" + "github.com/foliagecp/sdk/embedded/graph/jpgql" + + statefun "github.com/foliagecp/sdk/statefun" + "github.com/foliagecp/sdk/statefun/cache" + "github.com/foliagecp/sdk/statefun/system" + + lg "github.com/foliagecp/sdk/statefun/logger" +) + +var ( + // NatsURL - nats server url + NatsURL string = system.GetEnvMustProceed("NATS_URL", "nats://nats:foliage@nats:4222") + // NatsURL - nats server url + PrometricsServerPort string = system.GetEnvMustProceed("PROMETRICS_PORT", "9901") + // CreateSimpleGraphTest - create a simple graph on runtime start + CreateSimpleGraphTest bool = system.GetEnvMustProceed("CREATE_SIMPLE_GRAPH_TEST", true) + // TriggersTest - test the Foliage cmdb crud triggers + TriggersTest bool = system.GetEnvMustProceed("TRIGGERS_TEST", true) + + dbClient db.DBSyncClient +) + +func RegisterFunctionTypes(runtime *statefun.Runtime) { + graphCRUD.RegisterAllFunctionTypes(runtime) + graphDebug.RegisterAllFunctionTypes(runtime) + jpgql.RegisterAllFunctionTypes(runtime) +} + +func Start() { + system.GlobalPrometrics = system.NewPrometrics("", ":"+PrometricsServerPort) + + afterStart := func(ctx context.Context, runtime *statefun.Runtime) error { + dbc, err := db.NewDBSyncClientFromRequestFunction(runtime.Request) + if err != nil { + return err + } + dbClient = dbc + + CreateTestCMDB(runtime) + + runtime.Domain.SetWeakClusterDomains([]string{"leaf1", "leaf2", "leaf3"}) + + if runtime.Domain.Name() == runtime.Domain.CentralHubDomainName() { + time.Sleep(10 * time.Second) + wcd := runtime.Domain.GetWeakClusterDomains() + lg.Logf(lg.DebugLevel, "=================================Weak cluster domains: %v", wcd) + + for _, domain := range wcd { + dbClient.CMDB.ShadowObjectCanBeRecevier = true + system.MsgOnErrorReturn(dbClient.CMDB.ObjectCreate(runtime.Domain.CreateCustomShadowId(runtime.Domain.CentralHubDomainName(), domain, "rack1"), "rack")) + dbClient.CMDB.ShadowObjectCanBeRecevier = false + } + } + + return nil + } + + if runtime, err := statefun.NewRuntime(*statefun.NewRuntimeConfigSimple(NatsURL, "shadow").UseJSDomainAsLocalHubDomainName()); err == nil { + RegisterFunctionTypes(runtime) + runtime.RegisterOnAfterStartFunction(afterStart, true) + if err := runtime.Start(context.TODO(), cache.NewCacheConfig("main_cache")); err != nil { + lg.Logf(lg.ErrorLevel, "Cannot start due to an error: %s", err) + } + } else { + lg.Logf(lg.ErrorLevel, "Cannot create statefun runtime due to an error: %s", err) + } +} + +// -------------------------------------------------------------------------------------- diff --git a/tests/shadow/simple_cmdb.go b/tests/shadow/simple_cmdb.go new file mode 100644 index 00000000..5317ae23 --- /dev/null +++ b/tests/shadow/simple_cmdb.go @@ -0,0 +1,32 @@ +package main + +import ( + "github.com/foliagecp/easyjson" + "github.com/foliagecp/sdk/statefun" + lg "github.com/foliagecp/sdk/statefun/logger" + "github.com/foliagecp/sdk/statefun/system" +) + +func CreateTestCMDB(runtime *statefun.Runtime) { + lg.Logf(lg.DebugLevel, ">>> Test started: distributed graph with shadow objects in %v", runtime.Domain.Name()) + + rackType := easyjson.NewJSONObject() + system.MsgOnErrorReturn(dbClient.CMDB.TypeCreate("rack", rackType)) + + serverType := easyjson.NewJSONObject() + system.MsgOnErrorReturn(dbClient.CMDB.TypeCreate("server", serverType)) + + vmType := easyjson.NewJSONObject() + system.MsgOnErrorReturn(dbClient.CMDB.TypeCreate("vm", vmType)) + + system.MsgOnErrorReturn(dbClient.CMDB.TypesLinkCreate("rack", "server", "rack-server", nil)) + system.MsgOnErrorReturn(dbClient.CMDB.TypesLinkCreate("server", "vm", "server-vm", nil)) + + system.MsgOnErrorReturn(dbClient.CMDB.ObjectCreate("rack1", "rack")) + system.MsgOnErrorReturn(dbClient.CMDB.ObjectCreate("server1", "server")) + system.MsgOnErrorReturn(dbClient.CMDB.ObjectCreate("vm1", "vm")) + system.MsgOnErrorReturn(dbClient.CMDB.ObjectsLinkCreate("rack1", "server1", "rack-server", nil)) + system.MsgOnErrorReturn(dbClient.CMDB.ObjectsLinkCreate("server1", "vm1", "server-vm", nil)) + + lg.Logln(lg.DebugLevel, "<<< Test ended: distributed graph with shadow objects") +}