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

Pile is deprecated, what to do now? #23

Open
espenfjo opened this issue Mar 9, 2015 · 1 comment
Open

Pile is deprecated, what to do now? #23

espenfjo opened this issue Mar 9, 2015 · 1 comment

Comments

@espenfjo
Copy link

espenfjo commented Mar 9, 2015

Hi,
Since the Pile class is marked as deprecated, how should I match against several different patterns?

Something ideal would probably have been something like:

        Grok grok = new Grok();

        grok.addPatternFromFile("src/main/resources/grok-patterns");
        grok.compile("%{CISCOFW305011}");
        grok.compile("%{CISCOFW313001_313004_313008}");
        grok.compile("%{CISCOFW313005}");
        grok.compile("%{CISCOFW402117}");
        grok.compile("%{CISCOFW402119}");

         Match gm = grok.match(message);
         gm.captures();
         System.out.println(gm.toJson());

This would match any of the given patterns.

Now I would have to do something like:


 List<Grok> groks = new ArrayList<Grok>();
 List<String> grokPatterns = new ArrayList<String>();
 grokPatterns.add("%{CISCOFW106023}");
 grokPatterns.add("%{CISCOFW313005}");
 grokPatterns.add("%{CISCOFW106001}");
 grokPatterns.add("%{CISCOFW106006_106007_106010}");
 grokPatterns.add("%{CISCOFW106014}");
 grokPatterns.add("%{CISCOFW106015}");
 grokPatterns.add("%{CISCOFW106021}");
for (String grokPattern : grokPatterns) {
            try {
                Grok grok = new Grok();
                grok.addPatternFromFile("resources/grok-patterns");
                grok.compile(grokPattern);
                groks.add(grok);

            } catch (GrokException e) {
                e.printStackTrace();
            }
}
 for (Grok grok : groks ) {
            Match gm = grok.match(message);
            if (gm.isNull())
                continue;
            gm.captures();
            System.out.println(gm.toJson());
        }

I find this somewhat sub-optimal.

@anthonycorbacho
Copy link
Member

Hi,

I deprecated grok pile, because the class was never use and not up to date.

But I guess I can bring it back and update the logic.

sachin2191 added a commit to sachin2191/java-grok that referenced this issue Apr 10, 2015
sachin2191 added a commit to sachin2191/java-grok that referenced this issue Apr 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants