Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give useful message on default grok patterns fail #5629

Merged
merged 2 commits into from May 13, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -24,6 +24,7 @@
import org.graylog.autovalue.WithBeanGetter;
import org.graylog2.contentpacks.ContentPackPersistenceService;
import org.graylog2.contentpacks.ContentPackService;
import org.graylog2.contentpacks.exceptions.ContentPackException;
import org.graylog2.contentpacks.model.ContentPack;
import org.graylog2.plugin.cluster.ClusterConfigService;
import org.slf4j.Logger;
Expand Down Expand Up @@ -71,9 +72,19 @@ public void upgrade() {
.getResource("V20180924111644_AddDefaultGrokPatterns_Default_Grok_Patterns.json");
final ContentPack contentPack = this.objectMapper.readValue(contentPackURL, ContentPack.class);
final ContentPack pack = this.contentPackPersistenceService.insert(contentPack)
.orElseThrow(() -> new Error("Content pack " + contentPack.id() + " with this revision " + contentPack.revision() + " already found!"));
.orElseThrow(() -> {
configService.write(MigrationCompleted.create(contentPack.id().toString()));
return new ContentPackException("Content pack " + contentPack.id() + " with this revision " + contentPack.revision() + " already found!");
});

contentPackService.installContentPack(pack, Collections.emptyMap(), "Add default Grok patterns", "admin");
try {
contentPackService.installContentPack(pack, Collections.emptyMap(), "Add default Grok patterns", "admin");
} catch(ContentPackException e) {
LOG.warn("Could not install default grok patterns: the installation found some modified default grok" +
"patterns in your setup and did not update them. If you wish to use to the default grok" +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small typo here

Suggested change
"patterns in your setup and did not update them. If you wish to use to the default grok" +
"patterns in your setup and did not update them. If you wish to use the default grok" +

"patterns we provide, please delete the grok pattern and install the 'Default grok" +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we show which grok pattern caused troubles in there? Otherwise we need to rephrase this:
(...) please delete the grok pattern (...)

"patterns' content pack manually.");
}

configService.write(MigrationCompleted.create(pack.id().toString()));
} catch (IOException e) {
Expand Down