Skip to content

getPattern and loadDefault misbehaving #18

Description

@dankearns

I have some sample code which seems like it should work, but does not:

'use strict';
const grok = require('node-grok');
const patterns = grok.loadDefaultSync(["grok-patterns","linux-syslog"]);
const test = "<34>1 2003-10-11T22:14:15.003Z mymachine.example.com su - ID47 - message"
const pattern = patterns.getPattern('SYSLOG5424LINE');
const parsed = pattern.parseSync(test);
console.log(parsed); // "null"

If I make this change, it works. Is it a bug or pilot error?

index 0de33ff..353e506 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -171,7 +171,7 @@ function GrokCollection() {
     };

     t.getPattern = function (id) {
-        return patterns.get(id);
+        return resolvePattern(patterns.get(id));
     };

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions