Formula - ContextKey
Use the contextKey Formula function with a regular expression to extract matching Key-names from the Log Event context (Key-Value collection).
✅ Extract multiple context keys matching a pattern ✅ Use regular expressions for flexible key filtering ✅ Simplify context key discovery and analysis
🎯 Design Note: The contextKey() function finds all context key names that match a regular expression pattern.
What does the contextKey formula do?
The contextKey() formula extracts all key names from the context that match a provided regular expression. This is useful for finding dynamically named keys or filtering specific context properties.
Examples
Let's get you started with the following example (Get all Keys matching the provided regular expression)
| Input | Expression | Result |
|---|---|---|
|
|
|
| Text Data | Context | Unique values |
Features
- Extracts all Key names from the Key-Value collection (Context)
- Uses regular expressions for flexible pattern matching
- Returns unique matching key names
- Ideal for dynamic key discovery and filtering
Important
This plugin loads the entire message into RAM. For best performance, use it only on small messages.
How to use the contextKey formula
To configure the Formula plugin with the contextKey function:
- Select Formula as the expression type plugin
- Write down the expression to use in the 'Expression' text area with the named Key to extract
contextKey(regex('Order#.*')) - The Context Key names are displayed in the Message Context tab
- The result is displayed
Syntax
contextKey(regex('Expression'))
Next step
- RegEx - Learn more about regular expressions
- How to Add or manage Search Fields
- How to Add or manage Log Views
Related Topics
- 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?
- Other Source formulas: body, context, field
