-
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
Reusable/common snippets of filebeat input config #16084
Comments
In general, I'd probably like most If I could write sht like
with general rule that imported group is simply blended into appropriate section (whether conflict between imported setting and sth written in place generates an error, or is resolved in favor of specific setting, I have no strict opinion, in case of Such or similar approach would let me have 2-3 predefined sets I need (for 2-3 log kinds, differing in multiline pattern) and keep my sections compact Or mayhaps it could be done per-file (wherever I use two/three log kinds, I usually end having inputs.d directory with separate
Or sth else. Some kind of define macro/use macro (with go templates inside) could also be nice. I considered templating externally, but this is troublesome considering people happen to patch filebeat configs manually in their final resting place… |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Bah, but how to add such label? |
Pinging @elastic/agent (Team:Agent) |
Hey @Mekk, I'd say that a feature like this belongs more to configuration management grounds. I don't think that beats should include a general purpose templating or something like this. But there are already some features that use to help to manage complex configurations:
I am going to close this issue as I don't think that anything more general is going to be implemented for Beats config. I'd suggest you to try with the existing options, and/or open a topic in https://discuss.elastic.co/c/elastic-stack/beats/28 to look for suggestions from the community. |
Most of the suggestions above doesn't seem at all related to the problem I describe. That's not about consistency of individual params (which could be improved by reusing env variable or referring keystore) and not about configuration management. That's simply about the fact, that I have long sections (like multiline pattern) which are always the same, but must be repeated. In the result, filebeat configs turn long, difficult to read, troublesome to edit in case sth here changes, etc. Of course it can be templated outside. But this makes using ansible, feet or sth necessity, and fixing configs manually impossible. Mayhaps yaml anchors could do. I learned to deeply hate them some time ago (syntax is very confusing and errors, in case they happen, difficult to comprehend, and „accidental admin” is unlikely to understand this syntax). And they can't merge things (like merging I think that sth like „log kind / log class”, which would define common features of many logs would be much nicer. Well… |
@Mekk yes, I only wanted to mention some of the features Beats already have to support some cases of complex configurations, in case some of them can help you in your case 🙂
This "log class" makes me think that perhaps you could create a custom Filebeat module for your case. Filebeat modules are implemented with config-like text files, and allow a high level of reusability. They can include fully templatized configurations, for example the config in the Filebeat module for MySQL includes a loop, multiline and some processors: beats/filebeat/module/mysql/error/config/error.yml Lines 1 to 19 in 465750c
Then it filebeat config you can "instantiate" this "log class" or module several times with something like:
There are some docs about creating new modules: https://www.elastic.co/guide/en/beats/devguide/7.11/filebeat-modules-devguide.html |
That's closer, I will take a look, thank you for the hint. Still, IMHO generic problem (I have plenty of logs which differ in some minor detail, like label, but have large common set of settings) isn't that rare and requiring custom templating here raises the bar (not to mention non-obviousness of that solution). Sth like I suggested above ( #16084 (comment) , maybe better named - say |
Yep, agree that perhaps we should add some documentation about recommendations on how to manage extensive configurations. Out of curiosity, to better understand your use case, are these logs generated by multiple deployments of some custom application? |
Regarding docs (I was just writing that): currently they leave strong impression, that modules constitute some advanced feature mostly intended to be used, not created. Small touches like adding sentence „If you reuse the same multiline pattern in many cases, you may consider -Creating module- to simplify your config” to the chapter about multiline inputs, and some similar remarks, plus creating such example chapter showing how to make simple module (say on this very example: reusing custom multiline rule) would help a lot. Regarding my case: I parse numerous logs created by plenty of custom applications built around some common frameworks (so they emit few consistend log kinds). So I have not-that-trivial multiline patterns, I have fields which classify log formats/types before logstash processing, and such. And frequently I happen to have 15 directories with logs on some machine, which are more-or-less identical (the format is the same) except each needs custom field or label to classify log project or app (otherwise I'd have one entry with many paths). So I end up having many similar entries. Think just that: complex multiline rule, 8 common fields or labels, common tech fields like scan frequency … and the need to add 1-2 specific fields/labels per directory (or sometimes per more narrow pattern). And 10 such directories |
… and I suppose modules are indeed good answer to my needs and I am to try them. But note that I haven't even considered using them in spite of using filebeat for 2 years and reading docs many times. |
(note-after-some-time) I finally wrote „my” modules and they work nicely, so this is indeed correct way to proceeed. But there is some problem (apart from documentation remarks above): modules must be installed to Would be nice if filebeat handled some out-of-its-normal-directory module directory in addendum (maybe |
My filebeat input configs start being very copypastish.
They usually look so:
where sections differ only by
paths
and (some)fields
(less frequentlyencoding
orharvester_limit
), and remaning settings remain the same. Copy. Paste. Copy. Paste. Copy. Paste.So it would be great if I could write common settings somewhere somehow.
The text was updated successfully, but these errors were encountered: