-
Notifications
You must be signed in to change notification settings - Fork 5k
[Fleet] Enable log introspections #14390
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
Merged
michalpristas
merged 20 commits into
elastic:fleet
from
michalpristas:feat-fleet-logintro
Dec 5, 2019
Merged
Changes from 16 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
5590fc3
merged PR from fleet
michalpristas c2e585f
missing files oh my
michalpristas a812378
fmt
michalpristas 4e186f8
conditional append
michalpristas 2da406e
const for keys
michalpristas c2dbc62
outputs
michalpristas 70b22eb
beat name
michalpristas cd1d0d0
beat name
michalpristas 477a4f8
data path injection
michalpristas 8b21e2d
Merge branch 'fleet' into feat-fleet-logintro
michalpristas b9be9a6
more readable types
michalpristas 82ecda3
Merge branch 'fleet' into feat-fleet-logintro
michalpristas 5ee8c78
http prefix for unix paths
michalpristas 26f08d4
resolved comments
michalpristas 55afb6c
confglicts
michalpristas 37d2408
Merge branch 'fleet' into feat-fleet-logintro
michalpristas ad816ea
merged conflicts
michalpristas 79ead69
Merge branch 'fleet' into feat-fleet-logintro
michalpristas 44da9c1
groups done right
michalpristas 4a84c25
use monitoring.elasticsearch for output
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
66 changes: 66 additions & 0 deletions
66
x-pack/agent/pkg/agent/application/monitoring_decorator.go
This file contains hidden or 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,66 @@ | ||
| // 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 ( | ||
| "github.com/elastic/beats/x-pack/agent/pkg/agent/program" | ||
| "github.com/elastic/beats/x-pack/agent/pkg/agent/transpiler" | ||
| ) | ||
|
|
||
| const ( | ||
| monitoringName = "FLEET_MONITORING" | ||
| programsKey = "programs" | ||
| monitoringKey = "monitoring" | ||
| enabledKey = "monitoring.enabled" | ||
| outputKey = "output" | ||
| ) | ||
|
|
||
| func injectMonitoring(rootAst *transpiler.AST, programsToRun []program.Program) ([]program.Program, error) { | ||
| var err error | ||
| monitoringProgram := program.Program{ | ||
| Spec: program.Spec{ | ||
| Name: monitoringName, | ||
| Cmd: monitoringName, | ||
| }, | ||
| } | ||
|
|
||
| var config map[string]interface{} | ||
|
|
||
| if _, found := transpiler.Lookup(rootAst, monitoringKey); !found { | ||
| config = make(map[string]interface{}) | ||
| config[enabledKey] = false | ||
| } else { | ||
| ast := rootAst.Clone() | ||
| if err := getMonitoringRule().Apply(ast); err != nil { | ||
| return programsToRun, err | ||
| } | ||
|
|
||
| config, err = ast.Map() | ||
| if err != nil { | ||
| return programsToRun, err | ||
| } | ||
|
|
||
| programList := make([]string, 0, len(programsToRun)) | ||
| for _, p := range programsToRun { | ||
| programList = append(programList, p.Spec.Cmd) | ||
| } | ||
| // making program list part of the config | ||
| // so it will get regenerated with every change | ||
| config[programsKey] = programList | ||
| } | ||
|
|
||
| monitoringProgram.Config, err = transpiler.NewAST(config) | ||
| if err != nil { | ||
| return programsToRun, err | ||
| } | ||
|
|
||
| return append(programsToRun, monitoringProgram), nil | ||
| } | ||
|
|
||
| func getMonitoringRule() *transpiler.RuleList { | ||
| return transpiler.NewRuleList( | ||
| transpiler.Filter(monitoringKey, programsKey, outputKey), | ||
| ) | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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.
I like the idea of the decorators.