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
Enable Logstash output #13345
Merged
kvch
merged 6 commits into
elastic:master
from
kvch:feature-functionbeat-logstash-output
Aug 27, 2019
Merged
Enable Logstash output #13345
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5194fe0
add LS output to configuration
kvch f7011a3
init LS support
kvch 640a669
address review notes
kvch 4158595
feed the hound
kvch 36c3203
only print to stdout if function
kvch bcb3572
enforce lisence check if elasticsearch is configured
kvch File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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
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 |
---|---|---|
|
@@ -11,26 +11,60 @@ import ( | |
"fmt" | ||
"regexp" | ||
|
||
"github.com/elastic/beats/libbeat/cfgfile" | ||
"github.com/elastic/beats/libbeat/common" | ||
) | ||
|
||
// ConfigOverrides overrides the defaults provided by libbeat. | ||
var ( | ||
functionPattern = "^[A-Za-z][A-Za-z0-9\\-]{0,139}$" | ||
functionRE = regexp.MustCompile(functionPattern) | ||
ConfigOverrides = common.MustNewConfigFrom(map[string]interface{}{ | ||
configOverrides = common.MustNewConfigFrom(map[string]interface{}{ | ||
"path.data": "/tmp", | ||
"path.logs": "/tmp/logs", | ||
"logging.to_stderr": true, | ||
"logging.to_files": false, | ||
"setup.template.enabled": true, | ||
"queue.mem": map[string]interface{}{ | ||
"events": "${output.elasticsearch.bulk_max_size}", | ||
"flush.min_events": 10, | ||
"flush.timeout": "0.01s", | ||
}, | ||
}) | ||
functionLoggingOverrides = common.MustNewConfigFrom(map[string]interface{}{ | ||
"logging.to_stderr": true, | ||
"logging.to_files": false, | ||
}) | ||
esOverrides = common.MustNewConfigFrom(map[string]interface{}{ | ||
"queue.mem.events": "${output.elasticsearch.bulk_max_size}", | ||
"output.elasticsearch.bulk_max_size": 50, | ||
}) | ||
logstashOverrides = common.MustNewConfigFrom(map[string]interface{}{ | ||
"queue.mem.events": "${output.logstash.bulk_max_size}", | ||
"output.logstash": map[string]interface{}{ | ||
"bulk_max_size": 50, | ||
"pipelining": 0, | ||
}, | ||
}) | ||
|
||
// Overrides overrides the default configuration provided by libbeat. | ||
Overrides = []cfgfile.ConditionalOverride{ | ||
cfgfile.ConditionalOverride{ | ||
Check: always, | ||
Config: configOverrides, | ||
}, | ||
cfgfile.ConditionalOverride{ | ||
Check: isLogstash, | ||
Config: logstashOverrides, | ||
}, | ||
cfgfile.ConditionalOverride{ | ||
Check: isElasticsearch, | ||
Config: esOverrides, | ||
}, | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. neat I haven't thought about doing it this way. |
||
|
||
functionOverride = cfgfile.ConditionalOverride{ | ||
Check: always, | ||
Config: functionLoggingOverrides, | ||
} | ||
// FunctionOverrides contain logging settings | ||
FunctionOverrides = append(Overrides, functionOverride) | ||
) | ||
|
||
// Config default configuration for Functionbeat. | ||
|
@@ -58,6 +92,26 @@ var DefaultFunctionConfig = FunctionConfig{ | |
Enabled: true, | ||
} | ||
|
||
var always = func(_ *common.Config) bool { | ||
return true | ||
} | ||
|
||
var isLogstash = func(cfg *common.Config) bool { | ||
return isOutput(cfg, "logstash") | ||
} | ||
|
||
var isElasticsearch = func(cfg *common.Config) bool { | ||
return isOutput(cfg, "elasticsearch") | ||
} | ||
|
||
func isOutput(cfg *common.Config, name string) bool { | ||
outputCfg, err := cfg.Child("output", -1) | ||
if err != nil { | ||
return false | ||
} | ||
return outputCfg.HasField(name) | ||
} | ||
|
||
type functionName string | ||
|
||
func (f *functionName) Unpack(s string) error { | ||
|
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 was deleted.
Oops, something went wrong.
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.
Could we merge
BeatsOverrides
withconditionalsOverrides
, the only difference between the two is that one of them should be applied all the time. No?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.
Yes, after taking a walk I realized that they could be in the same list. :D