use of io.krakens.grok.api.GrokCompiler in project graylog2-server by Graylog2.
the class MongoDbGrokPatternService method validateAll.
@Override
public boolean validateAll(Collection<GrokPattern> newPatterns) throws GrokException {
final Set<GrokPattern> patterns = loadAll();
final GrokCompiler grokCompiler = GrokCompiler.newInstance();
for (GrokPattern newPattern : newPatterns) {
final boolean fieldsMissing = Strings.isNullOrEmpty(newPattern.name()) || Strings.isNullOrEmpty(newPattern.pattern());
if (fieldsMissing) {
return false;
}
grokCompiler.register(newPattern.name(), newPattern.pattern());
}
for (GrokPattern storedPattern : patterns) {
grokCompiler.register(storedPattern.name(), storedPattern.pattern());
}
for (GrokPattern newPattern : newPatterns) {
grokCompiler.compile("%{" + newPattern.name() + "}");
}
return true;
}
use of io.krakens.grok.api.GrokCompiler in project graylog2-server by Graylog2.
the class MongoDbGrokPatternService method validate.
@Override
public boolean validate(GrokPattern pattern) throws GrokException {
checkNotNull(pattern, "A pattern must be given");
final Set<GrokPattern> patterns = loadAll();
final boolean fieldsMissing = Strings.isNullOrEmpty(pattern.name()) || Strings.isNullOrEmpty(pattern.pattern());
final GrokCompiler grokCompiler = GrokCompiler.newInstance();
for (GrokPattern storedPattern : patterns) {
grokCompiler.register(storedPattern.name(), storedPattern.pattern());
}
grokCompiler.register(pattern.name(), pattern.pattern());
grokCompiler.compile("%{" + pattern.name() + "}");
return !fieldsMissing;
}
use of io.krakens.grok.api.GrokCompiler in project graylog2-server by Graylog2.
the class MongoDbGrokPatternService method match.
@Override
public Map<String, Object> match(GrokPattern pattern, String sampleData) throws GrokException {
final Set<GrokPattern> patterns = loadAll();
final GrokCompiler grokCompiler = GrokCompiler.newInstance();
for (GrokPattern storedPattern : patterns) {
grokCompiler.register(storedPattern.name(), storedPattern.pattern());
}
grokCompiler.register(pattern.name(), pattern.pattern());
Grok grok = grokCompiler.compile("%{" + pattern.name() + "}");
return grok.match(sampleData).captureFlattened();
}
use of io.krakens.grok.api.GrokCompiler in project graylog2-server by Graylog2.
the class InMemoryGrokPatternService method validateAll.
@Override
public boolean validateAll(Collection<GrokPattern> newPatterns) throws GrokException {
final Set<GrokPattern> patterns = loadAll();
final GrokCompiler grokCompiler = GrokCompiler.newInstance();
for (GrokPattern newPattern : newPatterns) {
final boolean fieldsMissing = Strings.isNullOrEmpty(newPattern.name()) || Strings.isNullOrEmpty(newPattern.pattern());
if (fieldsMissing) {
return false;
}
grokCompiler.register(newPattern.name(), newPattern.pattern());
}
for (GrokPattern storedPattern : patterns) {
grokCompiler.register(storedPattern.name(), storedPattern.pattern());
}
for (GrokPattern newPattern : newPatterns) {
grokCompiler.compile("%{" + newPattern.name() + "}");
}
return true;
}
use of io.krakens.grok.api.GrokCompiler in project graylog2-server by Graylog2.
the class InMemoryGrokPatternService method validate.
@Override
public boolean validate(GrokPattern pattern) throws GrokException {
final Set<GrokPattern> patterns = loadAll();
final boolean fieldsMissing = Strings.isNullOrEmpty(pattern.name()) || Strings.isNullOrEmpty(pattern.pattern());
final GrokCompiler grokCompiler = GrokCompiler.newInstance();
for (GrokPattern storedPattern : patterns) {
grokCompiler.register(storedPattern.name(), storedPattern.pattern());
}
grokCompiler.register(pattern.name(), pattern.pattern());
grokCompiler.compile("%{" + pattern.name() + "}");
return !fieldsMissing;
}
Aggregations