forked from TrueCloudLab/frostfs-node
[#680] metrics: Export log and morph with script
Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>feature/prm_balance_get
parent
aca11d7474
commit
994f48f8bb
|
@ -9,7 +9,6 @@ import (
|
||||||
morphconfig "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config/morph"
|
morphconfig "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config/morph"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/netmap"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/netmap"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/metrics"
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
|
||||||
nmClient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/netmap"
|
nmClient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/netmap"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/event"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/event"
|
||||||
|
@ -42,13 +41,13 @@ func initMorphComponents(ctx context.Context, c *cfg) {
|
||||||
c.key,
|
c.key,
|
||||||
client.WithDialTimeout(morphconfig.DialTimeout(c.appCfg)),
|
client.WithDialTimeout(morphconfig.DialTimeout(c.appCfg)),
|
||||||
client.WithLogger(c.log),
|
client.WithLogger(c.log),
|
||||||
client.WithMetrics(metrics.NewMorphClientMetrics()),
|
client.WithMetrics(c.metricsCollector.MorphClientMetrics()),
|
||||||
client.WithEndpoints(addresses...),
|
client.WithEndpoints(addresses...),
|
||||||
client.WithConnLostCallback(func() {
|
client.WithConnLostCallback(func() {
|
||||||
c.internalErr <- errors.New("morph connection has been lost")
|
c.internalErr <- errors.New("morph connection has been lost")
|
||||||
}),
|
}),
|
||||||
client.WithSwitchInterval(morphconfig.SwitchInterval(c.appCfg)),
|
client.WithSwitchInterval(morphconfig.SwitchInterval(c.appCfg)),
|
||||||
client.WithMorphCacheMetrics(metrics.NewNodeMorphCacheMetrics()),
|
client.WithMorphCacheMetrics(c.metricsCollector.MorphCacheMetrics()),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.log.Info(logs.FrostFSNodeFailedToCreateNeoRPCClient,
|
c.log.Info(logs.FrostFSNodeFailedToCreateNeoRPCClient,
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
morphmetrics "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/metrics"
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-observability/metrics"
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/metrics"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
@ -16,7 +15,7 @@ type morphClientMetrics struct {
|
||||||
invokeDuration *prometheus.HistogramVec
|
invokeDuration *prometheus.HistogramVec
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMorphClientMetrics() morphmetrics.Register {
|
func newMorphClientMetrics() *morphClientMetrics {
|
||||||
return &morphClientMetrics{
|
return &morphClientMetrics{
|
||||||
switchCount: metrics.NewCounter(prometheus.CounterOpts{
|
switchCount: metrics.NewCounter(prometheus.CounterOpts{
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
|
|
|
@ -18,10 +18,6 @@ type morphCacheMetrics struct {
|
||||||
|
|
||||||
var _ MorphCacheMetrics = (*morphCacheMetrics)(nil)
|
var _ MorphCacheMetrics = (*morphCacheMetrics)(nil)
|
||||||
|
|
||||||
func NewNodeMorphCacheMetrics() MorphCacheMetrics {
|
|
||||||
return newMorphCacheMetrics(namespace)
|
|
||||||
}
|
|
||||||
|
|
||||||
func newMorphCacheMetrics(ns string) *morphCacheMetrics {
|
func newMorphCacheMetrics(ns string) *morphCacheMetrics {
|
||||||
return &morphCacheMetrics{
|
return &morphCacheMetrics{
|
||||||
methodDuration: metrics.NewHistogramVec(prometheus.HistogramOpts{
|
methodDuration: metrics.NewHistogramVec(prometheus.HistogramOpts{
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package metrics
|
package metrics
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
morphmetrics "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/metrics"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-observability/metrics"
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/metrics"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
@ -19,6 +20,8 @@ type NodeMetrics struct {
|
||||||
pilorama *piloramaMetrics
|
pilorama *piloramaMetrics
|
||||||
grpc *grpcServerMetrics
|
grpc *grpcServerMetrics
|
||||||
policer *policerMetrics
|
policer *policerMetrics
|
||||||
|
morphClient *morphClientMetrics
|
||||||
|
morphCache *morphCacheMetrics
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewNodeMetrics() *NodeMetrics {
|
func NewNodeMetrics() *NodeMetrics {
|
||||||
|
@ -41,6 +44,8 @@ func NewNodeMetrics() *NodeMetrics {
|
||||||
pilorama: newPiloramaMetrics(),
|
pilorama: newPiloramaMetrics(),
|
||||||
grpc: newGrpcServerMetrics(),
|
grpc: newGrpcServerMetrics(),
|
||||||
policer: newPolicerMetrics(),
|
policer: newPolicerMetrics(),
|
||||||
|
morphClient: newMorphClientMetrics(),
|
||||||
|
morphCache: newMorphCacheMetrics(namespace),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,3 +101,11 @@ func (m *NodeMetrics) GrpcServerMetrics() GrpcServerMetrics {
|
||||||
func (m *NodeMetrics) PolicerMetrics() PolicerMetrics {
|
func (m *NodeMetrics) PolicerMetrics() PolicerMetrics {
|
||||||
return m.policer
|
return m.policer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *NodeMetrics) MorphClientMetrics() morphmetrics.Register {
|
||||||
|
return m.morphClient
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *NodeMetrics) MorphCacheMetrics() MorphCacheMetrics {
|
||||||
|
return m.morphCache
|
||||||
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ func NewLogger(prm *Prm) (*Logger, error) {
|
||||||
|
|
||||||
lvl := zap.NewAtomicLevelAt(prm.level)
|
lvl := zap.NewAtomicLevelAt(prm.level)
|
||||||
|
|
||||||
m := newLogMetrics(prm.MetricsNamespace)
|
m := NewLogMetrics(prm.MetricsNamespace)
|
||||||
|
|
||||||
c := zap.NewProductionConfig()
|
c := zap.NewProductionConfig()
|
||||||
c.Level = lvl
|
c.Level = lvl
|
||||||
|
|
|
@ -14,12 +14,12 @@ const (
|
||||||
logDroppedLabel = "dropped"
|
logDroppedLabel = "dropped"
|
||||||
)
|
)
|
||||||
|
|
||||||
type logMetrics struct {
|
type LogMetrics struct {
|
||||||
logCount *prometheus.CounterVec
|
logCount *prometheus.CounterVec
|
||||||
}
|
}
|
||||||
|
|
||||||
func newLogMetrics(namespace string) *logMetrics {
|
func NewLogMetrics(namespace string) *LogMetrics {
|
||||||
return &logMetrics{
|
return &LogMetrics{
|
||||||
logCount: metrics.NewCounterVec(prometheus.CounterOpts{
|
logCount: metrics.NewCounterVec(prometheus.CounterOpts{
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Subsystem: logSubsystem,
|
Subsystem: logSubsystem,
|
||||||
|
@ -29,7 +29,7 @@ func newLogMetrics(namespace string) *logMetrics {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *logMetrics) Inc(level zapcore.Level, dropped bool) {
|
func (m *LogMetrics) Inc(level zapcore.Level, dropped bool) {
|
||||||
m.logCount.With(prometheus.Labels{
|
m.logCount.With(prometheus.Labels{
|
||||||
logLevelLabel: level.String(),
|
logLevelLabel: level.String(),
|
||||||
logDroppedLabel: strconv.FormatBool(dropped),
|
logDroppedLabel: strconv.FormatBool(dropped),
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
local_metrics "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/metrics"
|
local_metrics "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/metrics"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-observability/metrics"
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/metrics"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -27,9 +28,11 @@ func main() {
|
||||||
switch {
|
switch {
|
||||||
case *node != "":
|
case *node != "":
|
||||||
_ = local_metrics.NewNodeMetrics()
|
_ = local_metrics.NewNodeMetrics()
|
||||||
|
_ = logger.NewLogMetrics("frostfs_node")
|
||||||
filename = *node
|
filename = *node
|
||||||
case *ir != "":
|
case *ir != "":
|
||||||
_ = local_metrics.NewInnerRingMetrics()
|
_ = local_metrics.NewInnerRingMetrics()
|
||||||
|
_ = logger.NewLogMetrics("frostfs_ir")
|
||||||
filename = *ir
|
filename = *ir
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue