Log Transformer Javascript
  • Dark
    Light

Log Transformer Javascript

  • Dark
    Light

Overview

This filter type uses Goja (a type of script in JavaScript) to transform specified log messages.

When a log matches the criteria, it will be transformed, and then passed through the filter.


Review Sample Configuration

Review the following sample configuration:

- name:  add_json_field
  type: log-transformer-javascript
  script: |
    var obj = JSON.parse(log);
    obj.version = "latest";
    log = JSON.stringify(obj);
  required: true

Review Parameters

Review the following parameters that you can configure in the Edge Delta App.


name

Required

Enter a descriptive name for this filter.

When you create a workflow, you will use this label to enter your filter into the workflow.

Review the following example:

name: all_add_json_field

type

Required

Enter log-transformer-javascript.

Review the following example:

type: log-transformer-javascript

script

Define a script to transform matching logs. After a matched log has been transformed, it will pass through the filter.

In the script, you must set the raw log variable to log.

Review the following example:

script: |
  var obj = JSON.parse(log)
  obj.version = "latest"
  log = JSON.stringify(obj)

Based on the above example, the first log line will be transformed into the second log line:

{"app": "alpine", "service": "nonprod", "source": "tomcat"}
  
{"app": "alpine", service": "nonprod", "source": "tomcat", "version": "latest"}

required

Optional

Enter true to pass only logs that have been transformed by the script.

The default action is false.

Review the following example:

required: true


Was this article helpful?

What's Next
Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.