Skip to content

paStash NG Commands

Lorenzo Mangani edited this page Jan 26, 2019 · 11 revisions

paStash Commands

This WIP outlines the nature of paStash commands and their general usage.

What?

Command filters are pluggable pipeline functions users can inject in their logic using npm modules. By default they provide useful aggregation functions from the aggro module, easily extensible with the use of custom plugins for custom tasks outside of the mainline, keeping everything simple and smoothly intersected.

Command Example:
  .filter('method', 'INVITE')
  .groupBy('response')
  .divide('timestamp',1000,data)
  .data(data)

Usage

In order to understand the potential usage of command filters in paStash we'll create a custom command plugin providing a dummy divide and multiply set of commands to our pipeline. This could be anything

Requirements

The following modules are required to run this example:

sudo npm install -g @pastash/pastash @pastash/filter_command @pastash/command_math

Proceed to create a pipeline using your preferred in/out combination. Our custom plugin (and any other) will be loaded at runtime via the plugins property of the command filter:

input {
  stdin{}
}

filter {
  json_fields {}
  command {
    debug => false
    cmd => ".divide('age',2,data).multiply('eyes',2,data).data(data)"
    plugins => ['@pastash/command_chain','@pastash/command_math']
  }
}

output {
  stdout {}
}

Feed it!

The following input should transverse the command pipeline and return all changes to the output:

[{ "sex": "male", "age": 35, "eyes": 2 },{ "sex": "female", "age": 38, "eyes": 2 },{ "sex": "male", "age": 29, "eyes": 2 }]
TO BE CONTINUED
Clone this wiki locally