Install Node.js packages for custom scripts

From what I gather, Cribl uses Node.js under the covers. Is there a way to install Node.js packages in order to write some custom scripts? I think writing a Pack could be the path to take but not certain.

I got the idea from reading these posts:

1 UpGoat

Hi @dmtrs, yes, your assumption that Cribl uses Node.js is correct.

I would also recommend this blog for reading about custom functions: Extending [Log]Stream: Building Custom Functions

You can use NPM or Yarn to install packages for your custom functions. The node_modules folder must be inside the custom function folder.

Custom functions must be installed in these locations:
Standalone: $CRIBL_HOME/local/cribl/functions/
Distributed: $CRIBL_HOME/groups/<group_name>/local/cribl/functions/

The directory would look something like this:

functions
`-- guid
    |-- node_modules
    |   `-- uuid
    |       | -- bunch of files here
    |       ...
    |-- package.json
    |-- package-lock.json
    |-- LICENSE.md
    |-- README.md
    |-- conf.schema.json
    `-- index.js

In your custom code, use the require function to import the library.

If you want to see some more examples, I’ve published a few custom functions on my Github. The project also shows how to use Webpack to merge all package imports into a single index.js file for distribution.

Standard disclaimer: Custom functions are not something that our support team members are able to assist or help troubleshoot. We are also not able to ensure performance of your custom functions.

4 UpGoats

This worked for me!

The function I was writing when I posted this question I couldn’t get to work. I think there was an issue between the module I needed for the function and running in Cribl. I took a different approach.

However, I wrote another function and it works.