-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[Ingest Manager] Log level reloadable from fleet #22690
Merged
michalpristas
merged 5 commits into
elastic:master
from
michalpristas:agent-log-level-reload
Nov 24, 2020
+255
−55
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4e337a5
log level reloadable from fleet
michalpristas 84a9e41
changelog
michalpristas 714ff46
comments resolved
michalpristas e5b86c8
fmt
michalpristas ea599e1
Merge branch 'master' of github.com:elastic/beats into agent-log-leve…
michalpristas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
x-pack/elastic-agent/pkg/agent/application/handler_action_settings.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
// or more contributor license agreements. Licensed under the Elastic License; | ||
// you may not use this file except in compliance with the Elastic License. | ||
|
||
package application | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/application/info" | ||
"github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" | ||
"github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" | ||
"github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/fleetapi" | ||
) | ||
|
||
// handlerSettings handles settings change coming from fleet and updates log level. | ||
type handlerSettings struct { | ||
log *logger.Logger | ||
reexec reexecManager | ||
agentInfo *info.AgentInfo | ||
} | ||
|
||
// Handle handles SETTINGS action. | ||
func (h *handlerSettings) Handle(ctx context.Context, a action, acker fleetAcker) error { | ||
h.log.Debugf("handlerUpgrade: action '%+v' received", a) | ||
action, ok := a.(*fleetapi.ActionSettings) | ||
if !ok { | ||
return fmt.Errorf("invalid type, expected ActionSettings and received %T", a) | ||
} | ||
|
||
if !isSupportedLogLevel(action.LogLevel) { | ||
return fmt.Errorf("invalid log level, expected debug|info|warning|error and received '%s'", action.LogLevel) | ||
} | ||
|
||
if err := h.agentInfo.LogLevel(action.LogLevel); err != nil { | ||
return errors.New("failed to update log level", err) | ||
} | ||
|
||
if err := acker.Ack(ctx, a); err != nil { | ||
h.log.Errorf("failed to acknowledge SETTINGS action with id '%s'", action.ActionID) | ||
} else if err := acker.Commit(ctx); err != nil { | ||
h.log.Errorf("failed to commit acker after acknowledging action with id '%s'", action.ActionID) | ||
} | ||
|
||
h.reexec.ReExec() | ||
return nil | ||
} | ||
|
||
func isSupportedLogLevel(level string) bool { | ||
return level == "error" || level == "debug" || level == "info" || level == "warning" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this change can we move the default up to info?
Debug level is still causing duplicate events, which still needs to be solved even in debug.