GithubHelp home page GithubHelp logo

Comments (6)

fbaligand avatar fbaligand commented on June 9, 2024

You say you managed to include external class or method into aggregate call.
How did you do that ?
Globally, how do you see the feature ?

from logstash-filter-aggregate.

alkuzad avatar alkuzad commented on June 9, 2024

@fbaligand
Just for test I've added includes option to aggregate:
config :includes, :validate => :array, :required => false, :default => []

and required files on register:

@includes.each do |i|
  require i
end

Then I've added includes to aggregate filter and I could use new functions.

I've experimented with separate aggregate call class to dynamically include another module but I do not have this code right now. It shouldn't be too hard though.

from logstash-filter-aggregate.

fbaligand avatar fbaligand commented on June 9, 2024

Thanks for these details.

Actually, I think you can already do what you need with aggregate plugin as it is :

aggregate {
    code => "require 'your-module'
             callToYourMethod(event, map)"
     ...
  }

from logstash-filter-aggregate.

alkuzad avatar alkuzad commented on June 9, 2024

@fbaligand yes it's true. The problem is that you can easily mess up the imported code with internal aggregate code.

I.e one can declare simple "filter" function to do whole task. It can't be done as filter is already declared as main function in LogStash::Filters::Aggregate and it's declaration will be first on the list to use. Of course I can use Module::Function syntax but still it's quite cumbersome (until you made some note in README about that problem).

This is why I wanted to remove @codeblock from Logstash::Filter::Aggregate and move it to smth like Logstash::Filter::Codeblock. This way method running inside class will not have access to Aggregate internals.

from logstash-filter-aggregate.

fbaligand avatar fbaligand commented on June 9, 2024

Hi @alkuzad,
Firstable, sorry for my late answer.

OK, so I think I understand well your need.

To reach your need, I can :

  • add a new independant class inside aggregate.rb called LogStash::Filters::Aggregate::CodeBlockHolder
  • at register time, I create a new CodeBlockHolder instance that I keep, and I put @codeblock inside this instance.
  • and at filter time, I call codeblock which is inside codeBlockHolder instance.
  • for your information, I have checked that inside CodeBlockHolder class, you have no direct access to aggregate methods, so you can't call an aggregate method mistakenly.

Does this reach your need ?

from logstash-filter-aggregate.

alkuzad avatar alkuzad commented on June 9, 2024

@fbaligand right, this is it :)

Currently I have such code:

require '/home/alkuzad/scripts/aggregate_scripts/arch_calculations.rb';
a = Foo::Bar::Baz.new(map, event); 
a.initialize_event('arch1');
map.merge!(a.map)

So I have require, initialization of object (passed values of map and event), calculations and merge back map from object. The problems are two:

  1. Every code needs require, even if my 30 aggregate uses same class
  2. Every code needs map/event assignment or merge (dependent on map_action) as I can only pass values

The best solution would require to require/include only once and extend the class code as it can use the event/map directly.

from logstash-filter-aggregate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.