Extract filebeat prospector 'fileds' used from all attributes definitions (ruby based)












0















I'm currently adding filebeat support for services we provide;
For every service we have several log files I would like to track;
I have 1 common filebeat recipe and I'm distinguishing between the different services' logs in different attributes .rb files;
In those I have a separate definition per log;



All definitions have the same "fileds" configuration;
Can I add it to someplace to be used by all configurations?



My structure:



  cookbooks    
common
recipes
filebeat.rb
services
attributes
service1.rb
service2.rb


The content of servicesX.rb has the following definitions:



access_log = {
'paths' => ['TBD'],
'input_type' => 'log',
'fields' => {
'hostname' => node["opsworks"]["instance"]["hostname"],
'customer' => node["opsworks"]["instance"]["layers"][0],
'internal_ip' => node["opsworks"]["instance"]["private_ip"],
'ec2id' => node["opsworks"]["instance"]["aws_instance_id"],
'os' => node["opsworks"]["instance"]["os"],
'instance_type' => node["opsworks"]["instance"]["instance_type"] },
'fields_under_root' => true
}


audit_log = {
'paths' => ['TBD'],
'input_type' => 'log',
'fields' => {
'hostname' => node["opsworks"]["instance"]["hostname"],
'customer' => node["opsworks"]["instance"]["layers"][0],
'internal_ip' => node["opsworks"]["instance"]["private_ip"],
'ec2id' => node["opsworks"]["instance"]["aws_instance_id"],
'os' => node["opsworks"]["instance"]["os"],
'instance_type' => node["opsworks"]["instance"]["instance_type"]
},
'fields_under_root' => true
}


How can I extract



'fields' => {
'hostname' => node["opsworks"]["instance"]["hostname"],
'customer' => node["opsworks"]["instance"]["layers"][0],
'internal_ip' => node["opsworks"]["instance"]["private_ip"],
'ec2id' => node["opsworks"]["instance"]["aws_instance_id"],
'os' => node["opsworks"]["instance"]["os"],
'instance_type' => node["opsworks"]["instance"]["instance_type"]


Someplace in the same file (servicesX.rb) so to be used by all log files definitions?



Note: I'm a ruby novice :/



Thank you!!










share|improve this question



























    0















    I'm currently adding filebeat support for services we provide;
    For every service we have several log files I would like to track;
    I have 1 common filebeat recipe and I'm distinguishing between the different services' logs in different attributes .rb files;
    In those I have a separate definition per log;



    All definitions have the same "fileds" configuration;
    Can I add it to someplace to be used by all configurations?



    My structure:



      cookbooks    
    common
    recipes
    filebeat.rb
    services
    attributes
    service1.rb
    service2.rb


    The content of servicesX.rb has the following definitions:



    access_log = {
    'paths' => ['TBD'],
    'input_type' => 'log',
    'fields' => {
    'hostname' => node["opsworks"]["instance"]["hostname"],
    'customer' => node["opsworks"]["instance"]["layers"][0],
    'internal_ip' => node["opsworks"]["instance"]["private_ip"],
    'ec2id' => node["opsworks"]["instance"]["aws_instance_id"],
    'os' => node["opsworks"]["instance"]["os"],
    'instance_type' => node["opsworks"]["instance"]["instance_type"] },
    'fields_under_root' => true
    }


    audit_log = {
    'paths' => ['TBD'],
    'input_type' => 'log',
    'fields' => {
    'hostname' => node["opsworks"]["instance"]["hostname"],
    'customer' => node["opsworks"]["instance"]["layers"][0],
    'internal_ip' => node["opsworks"]["instance"]["private_ip"],
    'ec2id' => node["opsworks"]["instance"]["aws_instance_id"],
    'os' => node["opsworks"]["instance"]["os"],
    'instance_type' => node["opsworks"]["instance"]["instance_type"]
    },
    'fields_under_root' => true
    }


    How can I extract



    'fields' => {
    'hostname' => node["opsworks"]["instance"]["hostname"],
    'customer' => node["opsworks"]["instance"]["layers"][0],
    'internal_ip' => node["opsworks"]["instance"]["private_ip"],
    'ec2id' => node["opsworks"]["instance"]["aws_instance_id"],
    'os' => node["opsworks"]["instance"]["os"],
    'instance_type' => node["opsworks"]["instance"]["instance_type"]


    Someplace in the same file (servicesX.rb) so to be used by all log files definitions?



    Note: I'm a ruby novice :/



    Thank you!!










    share|improve this question

























      0












      0








      0








      I'm currently adding filebeat support for services we provide;
      For every service we have several log files I would like to track;
      I have 1 common filebeat recipe and I'm distinguishing between the different services' logs in different attributes .rb files;
      In those I have a separate definition per log;



      All definitions have the same "fileds" configuration;
      Can I add it to someplace to be used by all configurations?



      My structure:



        cookbooks    
      common
      recipes
      filebeat.rb
      services
      attributes
      service1.rb
      service2.rb


      The content of servicesX.rb has the following definitions:



      access_log = {
      'paths' => ['TBD'],
      'input_type' => 'log',
      'fields' => {
      'hostname' => node["opsworks"]["instance"]["hostname"],
      'customer' => node["opsworks"]["instance"]["layers"][0],
      'internal_ip' => node["opsworks"]["instance"]["private_ip"],
      'ec2id' => node["opsworks"]["instance"]["aws_instance_id"],
      'os' => node["opsworks"]["instance"]["os"],
      'instance_type' => node["opsworks"]["instance"]["instance_type"] },
      'fields_under_root' => true
      }


      audit_log = {
      'paths' => ['TBD'],
      'input_type' => 'log',
      'fields' => {
      'hostname' => node["opsworks"]["instance"]["hostname"],
      'customer' => node["opsworks"]["instance"]["layers"][0],
      'internal_ip' => node["opsworks"]["instance"]["private_ip"],
      'ec2id' => node["opsworks"]["instance"]["aws_instance_id"],
      'os' => node["opsworks"]["instance"]["os"],
      'instance_type' => node["opsworks"]["instance"]["instance_type"]
      },
      'fields_under_root' => true
      }


      How can I extract



      'fields' => {
      'hostname' => node["opsworks"]["instance"]["hostname"],
      'customer' => node["opsworks"]["instance"]["layers"][0],
      'internal_ip' => node["opsworks"]["instance"]["private_ip"],
      'ec2id' => node["opsworks"]["instance"]["aws_instance_id"],
      'os' => node["opsworks"]["instance"]["os"],
      'instance_type' => node["opsworks"]["instance"]["instance_type"]


      Someplace in the same file (servicesX.rb) so to be used by all log files definitions?



      Note: I'm a ruby novice :/



      Thank you!!










      share|improve this question














      I'm currently adding filebeat support for services we provide;
      For every service we have several log files I would like to track;
      I have 1 common filebeat recipe and I'm distinguishing between the different services' logs in different attributes .rb files;
      In those I have a separate definition per log;



      All definitions have the same "fileds" configuration;
      Can I add it to someplace to be used by all configurations?



      My structure:



        cookbooks    
      common
      recipes
      filebeat.rb
      services
      attributes
      service1.rb
      service2.rb


      The content of servicesX.rb has the following definitions:



      access_log = {
      'paths' => ['TBD'],
      'input_type' => 'log',
      'fields' => {
      'hostname' => node["opsworks"]["instance"]["hostname"],
      'customer' => node["opsworks"]["instance"]["layers"][0],
      'internal_ip' => node["opsworks"]["instance"]["private_ip"],
      'ec2id' => node["opsworks"]["instance"]["aws_instance_id"],
      'os' => node["opsworks"]["instance"]["os"],
      'instance_type' => node["opsworks"]["instance"]["instance_type"] },
      'fields_under_root' => true
      }


      audit_log = {
      'paths' => ['TBD'],
      'input_type' => 'log',
      'fields' => {
      'hostname' => node["opsworks"]["instance"]["hostname"],
      'customer' => node["opsworks"]["instance"]["layers"][0],
      'internal_ip' => node["opsworks"]["instance"]["private_ip"],
      'ec2id' => node["opsworks"]["instance"]["aws_instance_id"],
      'os' => node["opsworks"]["instance"]["os"],
      'instance_type' => node["opsworks"]["instance"]["instance_type"]
      },
      'fields_under_root' => true
      }


      How can I extract



      'fields' => {
      'hostname' => node["opsworks"]["instance"]["hostname"],
      'customer' => node["opsworks"]["instance"]["layers"][0],
      'internal_ip' => node["opsworks"]["instance"]["private_ip"],
      'ec2id' => node["opsworks"]["instance"]["aws_instance_id"],
      'os' => node["opsworks"]["instance"]["os"],
      'instance_type' => node["opsworks"]["instance"]["instance_type"]


      Someplace in the same file (servicesX.rb) so to be used by all log files definitions?



      Note: I'm a ruby novice :/



      Thank you!!







      ruby attributes filebeat






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 23 '18 at 8:59









      user2458507user2458507

      155




      155
























          2 Answers
          2






          active

          oldest

          votes


















          0














          After feedback and clarification in comments below, OP seems to want to DRY the code and re-use a fields definition.



          Simplest is to store it in a variable and then use that:



          fields = {
          'hostname' => node["opsworks"]["instance"]["hostname"],
          'customer' => node["opsworks"]["instance"]["layers"][0],
          'internal_ip' => node["opsworks"]["instance"]["private_ip"],
          'ec2id' => node["opsworks"]["instance"]["aws_instance_id"],
          'os' => node["opsworks"]["instance"]["os"],
          'instance_type' => node["opsworks"]["instance"]["instance_type"]
          }

          audit_log = {
          'paths' => ['TBD'],
          'input_type' => 'log',
          'fields' => fields
          }


          This, however, may cause issues with how node is set. It really depends on the flow of the rest of your script. In chef (assuming this is about chef) a node is the context on which the script runs, so setting the fields too early might give issues when that node is used much later:



          fields = { hostname: node["opsworks"]["instance"]["hostname"] }
          # ... do lots of stuff, like fetching, preparing, connecting and whatnot.
          fields # now contains the `node` values as set before connecting etc.


          If this is an issue, a better option would be to define a method that returns the fields from a passed-in node:



          def fields(node)
          {
          'hostname' => node["opsworks"]["instance"]["hostname"],
          'customer' => node["opsworks"]["instance"]["layers"][0],
          'internal_ip' => node["opsworks"]["instance"]["private_ip"],
          'ec2id' => node["opsworks"]["instance"]["aws_instance_id"],
          'os' => node["opsworks"]["instance"]["os"],
          'instance_type' => node["opsworks"]["instance"]["instance_type"]
          }
          end


          Or, cleaned up:



          def fields(node)
          instance = node["opsworks"]["instance"]
          {
          hostname: instance["hostname"],
          customer: instance["layers"][0],
          internal_ip: instance["private_ip"],
          ec2id: instance["aws_instance_id"],
          os: instance["os"],
          instance_type: instance["instance_type"]
          }
          end


          Then use that function:



          audit_log = {
          'paths' => ['TBD'],
          'input_type' => 'log',
          'fields' => fields(node)
          }





          share|improve this answer


























          • thank you for your response . I want to use all fields parameters as they are set, in every log definition, without copy-paste the same code (for those fields parameters )definition for every log; Thus I thought there might be a way to extract them at the beginning of the the file (or else) and just call them inside every log definition;

            – user2458507
            Nov 23 '18 at 10:35













          • I don't understand what you want, then. Could you reword your question to show more clearly what data you start with and what data you want to end up with?

            – berkes
            Nov 23 '18 at 10:46











          • apologies; sure, here it goes: I would like to be able to extract the whole "'fields'" section outside of the separate logs definitions. Maybe at the beginning of the .rb file? and inside the logs definitions, I want to just call for them. As it seems I will add parameters in 'fields' and I don't want to copy-paste the same thing for every log file definition; Hope this helps?

            – user2458507
            Nov 23 '18 at 11:08













          • So, to be certain: you want to define the fields once and then use that definition in the rest of the places?

            – berkes
            Nov 23 '18 at 11:18











          • yep :) I found erichelgeson.github.io/blog/2014/02/02/… .. Not sure if I'm the right path

            – user2458507
            Nov 23 '18 at 11:33



















          0














          After my research: The benefits of the implementation does not justify the time invested;
          Leaving it;






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53443445%2fextract-filebeat-prospector-fileds-used-from-all-attributes-definitions-ruby%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            After feedback and clarification in comments below, OP seems to want to DRY the code and re-use a fields definition.



            Simplest is to store it in a variable and then use that:



            fields = {
            'hostname' => node["opsworks"]["instance"]["hostname"],
            'customer' => node["opsworks"]["instance"]["layers"][0],
            'internal_ip' => node["opsworks"]["instance"]["private_ip"],
            'ec2id' => node["opsworks"]["instance"]["aws_instance_id"],
            'os' => node["opsworks"]["instance"]["os"],
            'instance_type' => node["opsworks"]["instance"]["instance_type"]
            }

            audit_log = {
            'paths' => ['TBD'],
            'input_type' => 'log',
            'fields' => fields
            }


            This, however, may cause issues with how node is set. It really depends on the flow of the rest of your script. In chef (assuming this is about chef) a node is the context on which the script runs, so setting the fields too early might give issues when that node is used much later:



            fields = { hostname: node["opsworks"]["instance"]["hostname"] }
            # ... do lots of stuff, like fetching, preparing, connecting and whatnot.
            fields # now contains the `node` values as set before connecting etc.


            If this is an issue, a better option would be to define a method that returns the fields from a passed-in node:



            def fields(node)
            {
            'hostname' => node["opsworks"]["instance"]["hostname"],
            'customer' => node["opsworks"]["instance"]["layers"][0],
            'internal_ip' => node["opsworks"]["instance"]["private_ip"],
            'ec2id' => node["opsworks"]["instance"]["aws_instance_id"],
            'os' => node["opsworks"]["instance"]["os"],
            'instance_type' => node["opsworks"]["instance"]["instance_type"]
            }
            end


            Or, cleaned up:



            def fields(node)
            instance = node["opsworks"]["instance"]
            {
            hostname: instance["hostname"],
            customer: instance["layers"][0],
            internal_ip: instance["private_ip"],
            ec2id: instance["aws_instance_id"],
            os: instance["os"],
            instance_type: instance["instance_type"]
            }
            end


            Then use that function:



            audit_log = {
            'paths' => ['TBD'],
            'input_type' => 'log',
            'fields' => fields(node)
            }





            share|improve this answer


























            • thank you for your response . I want to use all fields parameters as they are set, in every log definition, without copy-paste the same code (for those fields parameters )definition for every log; Thus I thought there might be a way to extract them at the beginning of the the file (or else) and just call them inside every log definition;

              – user2458507
              Nov 23 '18 at 10:35













            • I don't understand what you want, then. Could you reword your question to show more clearly what data you start with and what data you want to end up with?

              – berkes
              Nov 23 '18 at 10:46











            • apologies; sure, here it goes: I would like to be able to extract the whole "'fields'" section outside of the separate logs definitions. Maybe at the beginning of the .rb file? and inside the logs definitions, I want to just call for them. As it seems I will add parameters in 'fields' and I don't want to copy-paste the same thing for every log file definition; Hope this helps?

              – user2458507
              Nov 23 '18 at 11:08













            • So, to be certain: you want to define the fields once and then use that definition in the rest of the places?

              – berkes
              Nov 23 '18 at 11:18











            • yep :) I found erichelgeson.github.io/blog/2014/02/02/… .. Not sure if I'm the right path

              – user2458507
              Nov 23 '18 at 11:33
















            0














            After feedback and clarification in comments below, OP seems to want to DRY the code and re-use a fields definition.



            Simplest is to store it in a variable and then use that:



            fields = {
            'hostname' => node["opsworks"]["instance"]["hostname"],
            'customer' => node["opsworks"]["instance"]["layers"][0],
            'internal_ip' => node["opsworks"]["instance"]["private_ip"],
            'ec2id' => node["opsworks"]["instance"]["aws_instance_id"],
            'os' => node["opsworks"]["instance"]["os"],
            'instance_type' => node["opsworks"]["instance"]["instance_type"]
            }

            audit_log = {
            'paths' => ['TBD'],
            'input_type' => 'log',
            'fields' => fields
            }


            This, however, may cause issues with how node is set. It really depends on the flow of the rest of your script. In chef (assuming this is about chef) a node is the context on which the script runs, so setting the fields too early might give issues when that node is used much later:



            fields = { hostname: node["opsworks"]["instance"]["hostname"] }
            # ... do lots of stuff, like fetching, preparing, connecting and whatnot.
            fields # now contains the `node` values as set before connecting etc.


            If this is an issue, a better option would be to define a method that returns the fields from a passed-in node:



            def fields(node)
            {
            'hostname' => node["opsworks"]["instance"]["hostname"],
            'customer' => node["opsworks"]["instance"]["layers"][0],
            'internal_ip' => node["opsworks"]["instance"]["private_ip"],
            'ec2id' => node["opsworks"]["instance"]["aws_instance_id"],
            'os' => node["opsworks"]["instance"]["os"],
            'instance_type' => node["opsworks"]["instance"]["instance_type"]
            }
            end


            Or, cleaned up:



            def fields(node)
            instance = node["opsworks"]["instance"]
            {
            hostname: instance["hostname"],
            customer: instance["layers"][0],
            internal_ip: instance["private_ip"],
            ec2id: instance["aws_instance_id"],
            os: instance["os"],
            instance_type: instance["instance_type"]
            }
            end


            Then use that function:



            audit_log = {
            'paths' => ['TBD'],
            'input_type' => 'log',
            'fields' => fields(node)
            }





            share|improve this answer


























            • thank you for your response . I want to use all fields parameters as they are set, in every log definition, without copy-paste the same code (for those fields parameters )definition for every log; Thus I thought there might be a way to extract them at the beginning of the the file (or else) and just call them inside every log definition;

              – user2458507
              Nov 23 '18 at 10:35













            • I don't understand what you want, then. Could you reword your question to show more clearly what data you start with and what data you want to end up with?

              – berkes
              Nov 23 '18 at 10:46











            • apologies; sure, here it goes: I would like to be able to extract the whole "'fields'" section outside of the separate logs definitions. Maybe at the beginning of the .rb file? and inside the logs definitions, I want to just call for them. As it seems I will add parameters in 'fields' and I don't want to copy-paste the same thing for every log file definition; Hope this helps?

              – user2458507
              Nov 23 '18 at 11:08













            • So, to be certain: you want to define the fields once and then use that definition in the rest of the places?

              – berkes
              Nov 23 '18 at 11:18











            • yep :) I found erichelgeson.github.io/blog/2014/02/02/… .. Not sure if I'm the right path

              – user2458507
              Nov 23 '18 at 11:33














            0












            0








            0







            After feedback and clarification in comments below, OP seems to want to DRY the code and re-use a fields definition.



            Simplest is to store it in a variable and then use that:



            fields = {
            'hostname' => node["opsworks"]["instance"]["hostname"],
            'customer' => node["opsworks"]["instance"]["layers"][0],
            'internal_ip' => node["opsworks"]["instance"]["private_ip"],
            'ec2id' => node["opsworks"]["instance"]["aws_instance_id"],
            'os' => node["opsworks"]["instance"]["os"],
            'instance_type' => node["opsworks"]["instance"]["instance_type"]
            }

            audit_log = {
            'paths' => ['TBD'],
            'input_type' => 'log',
            'fields' => fields
            }


            This, however, may cause issues with how node is set. It really depends on the flow of the rest of your script. In chef (assuming this is about chef) a node is the context on which the script runs, so setting the fields too early might give issues when that node is used much later:



            fields = { hostname: node["opsworks"]["instance"]["hostname"] }
            # ... do lots of stuff, like fetching, preparing, connecting and whatnot.
            fields # now contains the `node` values as set before connecting etc.


            If this is an issue, a better option would be to define a method that returns the fields from a passed-in node:



            def fields(node)
            {
            'hostname' => node["opsworks"]["instance"]["hostname"],
            'customer' => node["opsworks"]["instance"]["layers"][0],
            'internal_ip' => node["opsworks"]["instance"]["private_ip"],
            'ec2id' => node["opsworks"]["instance"]["aws_instance_id"],
            'os' => node["opsworks"]["instance"]["os"],
            'instance_type' => node["opsworks"]["instance"]["instance_type"]
            }
            end


            Or, cleaned up:



            def fields(node)
            instance = node["opsworks"]["instance"]
            {
            hostname: instance["hostname"],
            customer: instance["layers"][0],
            internal_ip: instance["private_ip"],
            ec2id: instance["aws_instance_id"],
            os: instance["os"],
            instance_type: instance["instance_type"]
            }
            end


            Then use that function:



            audit_log = {
            'paths' => ['TBD'],
            'input_type' => 'log',
            'fields' => fields(node)
            }





            share|improve this answer















            After feedback and clarification in comments below, OP seems to want to DRY the code and re-use a fields definition.



            Simplest is to store it in a variable and then use that:



            fields = {
            'hostname' => node["opsworks"]["instance"]["hostname"],
            'customer' => node["opsworks"]["instance"]["layers"][0],
            'internal_ip' => node["opsworks"]["instance"]["private_ip"],
            'ec2id' => node["opsworks"]["instance"]["aws_instance_id"],
            'os' => node["opsworks"]["instance"]["os"],
            'instance_type' => node["opsworks"]["instance"]["instance_type"]
            }

            audit_log = {
            'paths' => ['TBD'],
            'input_type' => 'log',
            'fields' => fields
            }


            This, however, may cause issues with how node is set. It really depends on the flow of the rest of your script. In chef (assuming this is about chef) a node is the context on which the script runs, so setting the fields too early might give issues when that node is used much later:



            fields = { hostname: node["opsworks"]["instance"]["hostname"] }
            # ... do lots of stuff, like fetching, preparing, connecting and whatnot.
            fields # now contains the `node` values as set before connecting etc.


            If this is an issue, a better option would be to define a method that returns the fields from a passed-in node:



            def fields(node)
            {
            'hostname' => node["opsworks"]["instance"]["hostname"],
            'customer' => node["opsworks"]["instance"]["layers"][0],
            'internal_ip' => node["opsworks"]["instance"]["private_ip"],
            'ec2id' => node["opsworks"]["instance"]["aws_instance_id"],
            'os' => node["opsworks"]["instance"]["os"],
            'instance_type' => node["opsworks"]["instance"]["instance_type"]
            }
            end


            Or, cleaned up:



            def fields(node)
            instance = node["opsworks"]["instance"]
            {
            hostname: instance["hostname"],
            customer: instance["layers"][0],
            internal_ip: instance["private_ip"],
            ec2id: instance["aws_instance_id"],
            os: instance["os"],
            instance_type: instance["instance_type"]
            }
            end


            Then use that function:



            audit_log = {
            'paths' => ['TBD'],
            'input_type' => 'log',
            'fields' => fields(node)
            }






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 23 '18 at 12:14

























            answered Nov 23 '18 at 9:40









            berkesberkes

            17.2k1886172




            17.2k1886172













            • thank you for your response . I want to use all fields parameters as they are set, in every log definition, without copy-paste the same code (for those fields parameters )definition for every log; Thus I thought there might be a way to extract them at the beginning of the the file (or else) and just call them inside every log definition;

              – user2458507
              Nov 23 '18 at 10:35













            • I don't understand what you want, then. Could you reword your question to show more clearly what data you start with and what data you want to end up with?

              – berkes
              Nov 23 '18 at 10:46











            • apologies; sure, here it goes: I would like to be able to extract the whole "'fields'" section outside of the separate logs definitions. Maybe at the beginning of the .rb file? and inside the logs definitions, I want to just call for them. As it seems I will add parameters in 'fields' and I don't want to copy-paste the same thing for every log file definition; Hope this helps?

              – user2458507
              Nov 23 '18 at 11:08













            • So, to be certain: you want to define the fields once and then use that definition in the rest of the places?

              – berkes
              Nov 23 '18 at 11:18











            • yep :) I found erichelgeson.github.io/blog/2014/02/02/… .. Not sure if I'm the right path

              – user2458507
              Nov 23 '18 at 11:33



















            • thank you for your response . I want to use all fields parameters as they are set, in every log definition, without copy-paste the same code (for those fields parameters )definition for every log; Thus I thought there might be a way to extract them at the beginning of the the file (or else) and just call them inside every log definition;

              – user2458507
              Nov 23 '18 at 10:35













            • I don't understand what you want, then. Could you reword your question to show more clearly what data you start with and what data you want to end up with?

              – berkes
              Nov 23 '18 at 10:46











            • apologies; sure, here it goes: I would like to be able to extract the whole "'fields'" section outside of the separate logs definitions. Maybe at the beginning of the .rb file? and inside the logs definitions, I want to just call for them. As it seems I will add parameters in 'fields' and I don't want to copy-paste the same thing for every log file definition; Hope this helps?

              – user2458507
              Nov 23 '18 at 11:08













            • So, to be certain: you want to define the fields once and then use that definition in the rest of the places?

              – berkes
              Nov 23 '18 at 11:18











            • yep :) I found erichelgeson.github.io/blog/2014/02/02/… .. Not sure if I'm the right path

              – user2458507
              Nov 23 '18 at 11:33

















            thank you for your response . I want to use all fields parameters as they are set, in every log definition, without copy-paste the same code (for those fields parameters )definition for every log; Thus I thought there might be a way to extract them at the beginning of the the file (or else) and just call them inside every log definition;

            – user2458507
            Nov 23 '18 at 10:35







            thank you for your response . I want to use all fields parameters as they are set, in every log definition, without copy-paste the same code (for those fields parameters )definition for every log; Thus I thought there might be a way to extract them at the beginning of the the file (or else) and just call them inside every log definition;

            – user2458507
            Nov 23 '18 at 10:35















            I don't understand what you want, then. Could you reword your question to show more clearly what data you start with and what data you want to end up with?

            – berkes
            Nov 23 '18 at 10:46





            I don't understand what you want, then. Could you reword your question to show more clearly what data you start with and what data you want to end up with?

            – berkes
            Nov 23 '18 at 10:46













            apologies; sure, here it goes: I would like to be able to extract the whole "'fields'" section outside of the separate logs definitions. Maybe at the beginning of the .rb file? and inside the logs definitions, I want to just call for them. As it seems I will add parameters in 'fields' and I don't want to copy-paste the same thing for every log file definition; Hope this helps?

            – user2458507
            Nov 23 '18 at 11:08







            apologies; sure, here it goes: I would like to be able to extract the whole "'fields'" section outside of the separate logs definitions. Maybe at the beginning of the .rb file? and inside the logs definitions, I want to just call for them. As it seems I will add parameters in 'fields' and I don't want to copy-paste the same thing for every log file definition; Hope this helps?

            – user2458507
            Nov 23 '18 at 11:08















            So, to be certain: you want to define the fields once and then use that definition in the rest of the places?

            – berkes
            Nov 23 '18 at 11:18





            So, to be certain: you want to define the fields once and then use that definition in the rest of the places?

            – berkes
            Nov 23 '18 at 11:18













            yep :) I found erichelgeson.github.io/blog/2014/02/02/… .. Not sure if I'm the right path

            – user2458507
            Nov 23 '18 at 11:33





            yep :) I found erichelgeson.github.io/blog/2014/02/02/… .. Not sure if I'm the right path

            – user2458507
            Nov 23 '18 at 11:33













            0














            After my research: The benefits of the implementation does not justify the time invested;
            Leaving it;






            share|improve this answer




























              0














              After my research: The benefits of the implementation does not justify the time invested;
              Leaving it;






              share|improve this answer


























                0












                0








                0







                After my research: The benefits of the implementation does not justify the time invested;
                Leaving it;






                share|improve this answer













                After my research: The benefits of the implementation does not justify the time invested;
                Leaving it;







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 27 '18 at 8:18









                user2458507user2458507

                155




                155






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53443445%2fextract-filebeat-prospector-fileds-used-from-all-attributes-definitions-ruby%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    404 Error Contact Form 7 ajax form submitting

                    How to know if a Active Directory user can login interactively

                    Refactoring coordinates for Minecraft Pi buildings written in Python