Issue Description:
The current implementation of Grok does not validate if the Grok patterns specified in an expression are defined in the loaded patterns. This can lead to runtime errors when there are typos or usage of undefined patterns.
Proposed Enhancement:
I propose adding a method to validate Grok patterns against the set of loaded patterns. This method will ensure each pattern used in a Grok expression is defined. Here's the proposed implementation:
private void ValidateGrokPattern(string grokPattern)
{
var grokPatternRegex = new Regex("%\\{(.*?)(?::\\w+)?\\}");
MatchCollection matches = grokPatternRegex.Matches(grokPattern);
foreach (Match match in matches.Cast<Match>())
{
var patternName = match.Groups[1].Value;
if (!_patterns.ContainsKey(patternName))
{
throw new FormatException($"Invalid Grok pattern: Pattern '{patternName}' not found.");
}
}
}
If you agree on this enhancement I can be assigned this issue and will submit a PR. Thank you.
Issue Description: The current implementation of Grok does not validate if the Grok patterns specified in an expression are defined in the loaded patterns. This can lead to runtime errors when there are typos or usage of undefined patterns.
Proposed Enhancement: I propose adding a method to validate Grok patterns against the set of loaded patterns. This method will ensure each pattern used in a Grok expression is defined. Here's the proposed implementation:
If you agree on this enhancement I can be assigned this issue and will submit a PR. Thank you.