use of oi.thekraken.grok.api.exception.GrokException in project graylog2-server by Graylog2.
the class InMemoryGrokPatternService method validate.
@Override
public boolean validate(GrokPattern pattern) {
final boolean fieldsMissing = !(Strings.isNullOrEmpty(pattern.name()) || Strings.isNullOrEmpty(pattern.pattern()));
try {
final Grok grok = new Grok();
grok.addPattern(pattern.name(), pattern.pattern());
grok.compile("%{" + pattern.name() + "}");
} catch (GrokException ignored) {
// this only checks for null or empty again.
} catch (PatternSyntaxException e) {
LOG.warn("Invalid regular expression syntax for '" + pattern.name() + "' with pattern " + pattern.pattern(), e);
return false;
}
return fieldsMissing;
}
use of oi.thekraken.grok.api.exception.GrokException in project graylog2-server by Graylog2.
the class MongoDbGrokPatternService method validate.
@Override
public boolean validate(GrokPattern pattern) {
final boolean fieldsMissing = !(Strings.isNullOrEmpty(pattern.name()) || Strings.isNullOrEmpty(pattern.pattern()));
try {
final Grok grok = new Grok();
grok.addPattern(pattern.name(), pattern.pattern());
grok.compile("%{" + pattern.name() + "}");
} catch (GrokException ignored) {
// this only checks for null or empty again.
} catch (PatternSyntaxException e) {
log.warn("Invalid regular expression syntax for '" + pattern.name() + "' with pattern " + pattern.pattern(), e);
return false;
}
return fieldsMissing;
}
Aggregations