- 4 minutes to read

Formula

You hide it, we find it! Learn how to extract and modify returned values from any data structure

The formula plugin helps you extract any value from any given message by applying one or more (nested) functions. The Nodinite formula plugin, works much like formulas in Microsoft Excel (with the functions as listed in the reference table below)

The Formula plugin supports many powerful functions, (Multilevel Nested Functions) which is the key feature of this search field expressions plugin. However, it is too early to consider it right away. We will demonstrate this as we move further with the examples (Test Expressions).


Where does the extracted values come from?

The extracted values comes from the Body and/or Context that was logged by the Nodinite Logging Agents or from custom logged Log Events.

The documentation for the Formula plugin uses the notion of Content meaning either the Body (actual payload), Context or Result from previous Formula operation.

Content

The operations execute on data that comes any of the following

  • body

    • Flatfile and CSV structures
    • JSON
    • XML
  • context

    • Key/Value
  • Result from previous Formula operation

The Formula plugin, has different types of functions for example math, string, logical, base64 and these can be nested like:

  • function(content)
  • function(expression, content)
  • function(1st expression, 2nd expression, content)
  • function(1st expression, 2nd exp.., 3rd.., ..., content)
  • function(content, ..., content)

Sources:

Function Description
body Returns the whole Body part as a string from the payload of the logged event
context('Key Name1') Returns the value of the specified name from the collection of Context Values of the logged event
context(regex('Key Name.*')) Returns the values of the Regular Expression matching names from the collection of Context Values of the logged event
contextKey(regex('Key Name.*')) Returns the keys of the Regular Expression matching names from the collection of Context Keys of the logged event

Extract:

Function Description
csv(headerRowsToSkip, 'delimiter', columnIndex, 'commentSymbol', content) Extract data from any valid CSV file
jsonPath('expression', content) Used to extract value for the given path from a JSON valid structure
jsonPathKey('expression', content) Used to extract keys for the given path from a JSON valid structure
regex('expression', content) Use Regular Expression as it is implemented everywhere to extract values
regexGroup('expression', 'groups', content) Use Regular Expression and get the value from selected groups as it is implemented everywhere to extract values
xPath('expression', content) Retrieve values from XML body using a fast forward only reader XPath 1.0
xPath2('expression', content) Retrieve values from XML body using a XPath 2.0 (high memory usage)

Convert:

Function Description
base64decode(content) Decode the provided data into a human-readable format
base64encode(content) Encode text to base64
toLowerCase(content) Convert any given text to 'lower case'
toUpperCase(content) Convert any given text to 'UPPER CASE'

Alter:

Function Description
concat(content, ..., content) Can be used as a source, or concatenate any number of parameters
replace('oldValue', 'newValue',Content) Used to replace old text/letter with a new text.
substring(startIndex0, length, content) Extract specific text from any given statement/text

Logical:

Function Description
equal('expression', content) Check the equality of two given texts
endsWith('expression', content) Check if text ends with certain word/letter
notEqual('expression', content) Check the inequality of two given texts
startsWith('expression', content) Check if text starts with certain word/letter

Math Functions :

Function Description
count(Content, [bool unique = false]) Return the count of the extracted values, based on the result of any previous operation
sum(Content, [bool unique = true]) Return the sum of the extracted values, based on the result of any previous operation
length(content, [bool unique = true]) 'Returns the numerical value(s) with the Length of the content
min(content, [bool unique = true]) Return the minimum value of numerical values, returns nothing if no numerical values was found
max(content, [bool unique = true]) Return the maximum value of numerical values, returns nothing if no numerical values was found

Next Step

How to Add or manage Search Fields
How to Add or manage Log Views

Expression Type Plugins are used in Search Fields.
What are Search Fields?
What are Search Field Expressions?
What are Message Types?
What are Log Views?