Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(maestro): logs filtering to make it more clear the error #2702

Merged
merged 3 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions fleet/api/http/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (l loggingMiddleware) ViewAgentMatchingGroupsByIDInternal(ctx context.Conte
zap.Error(err),
zap.Duration("duration", time.Since(begin)))
} else {
l.logger.Info("method call: view_agent_matching_groups_by_idinternal",
l.logger.Debug("method call: view_agent_matching_groups_by_idinternal",
zap.Duration("duration", time.Since(begin)))
}
}(time.Now())
Expand All @@ -39,7 +39,7 @@ func (l loggingMiddleware) ResetAgent(ct context.Context, token string, agentID
zap.Error(err),
zap.Duration("duration", time.Since(begin)))
} else {
l.logger.Info("method call: reset_agent",
l.logger.Debug("method call: reset_agent",
zap.Duration("duration", time.Since(begin)))
}
}(time.Now())
Expand All @@ -53,7 +53,7 @@ func (l loggingMiddleware) ViewAgentInfoByChannelIDInternal(ctx context.Context,
zap.Error(err),
zap.Duration("duration", time.Since(begin)))
} else {
l.logger.Info("method call: view_owner_by_channel_id",
l.logger.Debug("method call: view_owner_by_channel_id",
zap.Duration("duration", time.Since(begin)))
}
}(time.Now())
Expand All @@ -67,7 +67,7 @@ func (l loggingMiddleware) ViewAgentBackend(ctx context.Context, token string, n
zap.Error(err),
zap.Duration("duration", time.Since(begin)))
} else {
l.logger.Info("method call: view_agent_backend",
l.logger.Debug("method call: view_agent_backend",
zap.Duration("duration", time.Since(begin)))
}
}(time.Now())
Expand All @@ -81,7 +81,7 @@ func (l loggingMiddleware) ListAgentBackends(ctx context.Context, token string)
zap.Error(err),
zap.Duration("duration", time.Since(begin)))
} else {
l.logger.Info("method call: list_agent_backends",
l.logger.Debug("method call: list_agent_backends",
zap.Duration("duration", time.Since(begin)))
}
}(time.Now())
Expand All @@ -95,7 +95,7 @@ func (l loggingMiddleware) ViewAgentByIDInternal(ctx context.Context, ownerID st
zap.Error(err),
zap.Duration("duration", time.Since(begin)))
} else {
l.logger.Info("method call: view_agent_by_id_internal",
l.logger.Debug("method call: view_agent_by_id_internal",
zap.Duration("duration", time.Since(begin)))
}
}(time.Now())
Expand All @@ -109,7 +109,7 @@ func (l loggingMiddleware) ViewAgentByID(ctx context.Context, token string, thin
zap.Error(err),
zap.Duration("duration", time.Since(begin)))
} else {
l.logger.Info("method call: view_agent_by_id",
l.logger.Debug("method call: view_agent_by_id",
zap.Duration("duration", time.Since(begin)))
}
}(time.Now())
Expand All @@ -123,7 +123,7 @@ func (l loggingMiddleware) ViewAgentMatchingGroupsByID(ctx context.Context, toke
zap.Error(err),
zap.Duration("duration", time.Since(begin)))
} else {
l.logger.Info("method call: view_agent_matching_groups_by_id",
l.logger.Debug("method call: view_agent_matching_groups_by_id",
zap.Duration("duration", time.Since(begin)))
}
}(time.Now())
Expand All @@ -137,7 +137,7 @@ func (l loggingMiddleware) EditAgent(ctx context.Context, token string, agent fl
zap.Error(err),
zap.Duration("duration", time.Since(begin)))
} else {
l.logger.Info("method call: edit_agent_by_id",
l.logger.Debug("method call: edit_agent_by_id",
zap.Duration("duration", time.Since(begin)))
}
}(time.Now())
Expand All @@ -151,7 +151,7 @@ func (l loggingMiddleware) ViewAgentGroupByIDInternal(ctx context.Context, group
zap.Error(err),
zap.Duration("duration", time.Since(begin)))
} else {
l.logger.Info("method call: view_agent_group_by_id_internal",
l.logger.Debug("method call: view_agent_group_by_id_internal",
zap.Duration("duration", time.Since(begin)))
}
}(time.Now())
Expand All @@ -165,7 +165,7 @@ func (l loggingMiddleware) ViewAgentGroupByID(ctx context.Context, groupID strin
zap.Error(err),
zap.Duration("duration", time.Since(begin)))
} else {
l.logger.Info("method call: view_agent_group_by_id",
l.logger.Debug("method call: view_agent_group_by_id",
zap.Duration("duration", time.Since(begin)))
}
}(time.Now())
Expand All @@ -179,7 +179,7 @@ func (l loggingMiddleware) ListAgentGroups(ctx context.Context, token string, pm
zap.Error(err),
zap.Duration("duration", time.Since(begin)))
} else {
l.logger.Info("method call: list_agent_groups",
l.logger.Debug("method call: list_agent_groups",
zap.Duration("duration", time.Since(begin)))
}
}(time.Now())
Expand All @@ -193,7 +193,7 @@ func (l loggingMiddleware) EditAgentGroup(ctx context.Context, token string, ag
zap.Error(err),
zap.Duration("duration", time.Since(begin)))
} else {
l.logger.Info("method call: edit_agent_groups",
l.logger.Debug("method call: edit_agent_groups",
zap.Duration("duration", time.Since(begin)))
}
}(time.Now())
Expand All @@ -207,7 +207,7 @@ func (l loggingMiddleware) ListAgents(ctx context.Context, token string, pm flee
zap.Error(err),
zap.Duration("duration", time.Since(begin)))
} else {
l.logger.Info("method call: list_agents",
l.logger.Debug("method call: list_agents",
zap.Duration("duration", time.Since(begin)))
}
}(time.Now())
Expand All @@ -222,7 +222,7 @@ func (l loggingMiddleware) CreateAgent(ctx context.Context, token string, a flee
zap.Error(err),
zap.Duration("duration", time.Since(begin)))
} else {
l.logger.Info("method call: create_agent",
l.logger.Debug("method call: create_agent",
zap.String("name", a.Name.String()),
zap.Duration("duration", time.Since(begin)))
}
Expand All @@ -238,7 +238,7 @@ func (l loggingMiddleware) CreateAgentGroup(ctx context.Context, token string, s
zap.Error(err),
zap.Duration("duration", time.Since(begin)))
} else {
l.logger.Info("method call: create_agent_group",
l.logger.Debug("method call: create_agent_group",
zap.String("name", s.Name.String()),
zap.Duration("duration", time.Since(begin)))
}
Expand All @@ -253,7 +253,7 @@ func (l loggingMiddleware) RemoveAgentGroup(ctx context.Context, token, groupID
zap.Error(err),
zap.Duration("duration", time.Since(begin)))
} else {
l.logger.Info("method call: delete_agent_groups",
l.logger.Debug("method call: delete_agent_groups",
zap.Duration("duration", time.Since(begin)))
}
}(time.Now())
Expand All @@ -268,7 +268,7 @@ func (l loggingMiddleware) ValidateAgentGroup(ctx context.Context, token string,
zap.Error(err),
zap.Duration("duration", time.Since(begin)))
} else {
l.logger.Info("method call: validate_agent_group",
l.logger.Debug("method call: validate_agent_group",
zap.String("name", s.Name.String()),
zap.Duration("duration", time.Since(begin)))
}
Expand All @@ -284,7 +284,7 @@ func (l loggingMiddleware) ValidateAgent(ctx context.Context, token string, a fl
zap.Error(err),
zap.Duration("duration", time.Since(begin)))
} else {
l.logger.Info("method call: validate_agent",
l.logger.Debug("method call: validate_agent",
zap.String("name", a.Name.String()),
zap.Duration("duration", time.Since(begin)))
}
Expand All @@ -299,7 +299,7 @@ func (l loggingMiddleware) RemoveAgent(ctx context.Context, token, thingID strin
zap.Error(err),
zap.Duration("duration", time.Since(begin)))
} else {
l.logger.Info("method call: delete_agent",
l.logger.Debug("method call: delete_agent",
zap.Duration("duration", time.Since(begin)))
}
}(time.Now())
Expand All @@ -314,7 +314,7 @@ func (l loggingMiddleware) GetPolicyState(ctx context.Context, agent fleet.Agent
zap.Error(err),
zap.Duration("duration", time.Since(begin)))
} else {
l.logger.Info("method call: get_policy_state",
l.logger.Debug("method call: get_policy_state",
zap.Duration("duration", time.Since(begin)))
}
}(time.Now())
Expand Down
6 changes: 4 additions & 2 deletions maestro/monitor/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,12 @@ func (svc *monitorService) monitorSinks(ctx context.Context) {
}
}
if sink == nil {
svc.logger.Warn("collector not found for sink, depleting collector", zap.String("collector name", collector.Name))
svc.logger.Warn("sink not found for collector, depleting collector", zap.String("collector name", collector.Name))
sinkId := collector.Name[5:41]
deploymentName := "otel-" + sinkId
err = svc.kubecontrol.KillOtelCollector(ctx, deploymentName, sinkId)
svc.logger.Debug("compare deploymentName with collector name", zap.String("deploy name", deploymentName),
zap.String("collector name", collector.Name))
err = svc.kubecontrol.KillOtelCollector(ctx, collector.Name, sinkId)
if err != nil {
svc.logger.Error("error removing otel collector", zap.Error(err))
}
Expand Down
3 changes: 0 additions & 3 deletions maestro/redis/consumer/sinker.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ func (s *sinkerActivityListenerService) ReadSinksActivity(ctx context.Context) e
}
for _, msg := range streams[0].Messages {
event := maestroredis.SinkerUpdateEvent{}
s.logger.Debug("Debug Message", zap.Any("message", msg.Values))
event.Decode(msg.Values)
s.logger.Debug("Reading message from activity stream",
zap.String("message_id", msg.ID),
Expand Down Expand Up @@ -87,9 +86,7 @@ func (s *sinkerActivityListenerService) ReadSinksIdle(ctx context.Context) error
}
for _, msg := range streams[0].Messages {
event := maestroredis.SinkerUpdateEvent{}
s.logger.Debug("Debug Message", zap.Any("message", msg.Values))
event.Decode(msg.Values)
s.logger.Debug("Debug Message", zap.Any("message", msg.Values), zap.Any("event", event))
s.logger.Debug("Reading message from idle stream",
zap.String("message_id", msg.ID),
zap.String("sink_id", event.SinkID),
Expand Down
Loading
Loading