Skip to content

TypeError: Cannot read property 'createPattern' of null #19

Description

@gauravsheel

Apologies if I have overlooked something or this has been discussed before.

The async patterns.createPattern method returns exception. Node version used is 8.9.0 (including other versions on runKit). The code sample on github/memz page doesn't work for me as well.

Example code run :

`// define grok pattern string
var p = '%{IP:client} \[%{TIMESTAMP_ISO8601:timestamp}\] "%{WORD:method} %{URIHOST:site}%{URIPATHPARAM:url}" %{INT:code} %{INT:request} %{INT:response} - %{NUMBER:took} \[%{DATA:cache}\] "%{DATA:mtag}" "%{DATA:agent}"';
// define test input string
var str = '203.35.135.165 [2016-03-15T12:42:04+11:00] "GET memz.co/cloud/" 304 962 0 - 0.003 [MISS] "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36"';

// asynchronously load default grop patterns
require('node-grok').loadDefault(function (patterns) {
// create new anonymous grok pattern
var pattern = patterns.createPattern(p);
// parse test string
pattern.parse(str, function (err, obj) {
// output result object
console.log(obj);
});
});`

## error returned --
var pattern = patterns.createPattern(p);
^

TypeError: Cannot read property 'createPattern' of null
at /Users/gauravsheel/workfiles/web-work/tools/ngrok/tmp.js:9:28
at /Users/gauravsheel/workfiles/web-work/tools/ngrok/node_modules/node-grok/lib/index.js:232:24
at /Users/gauravsheel/workfiles/web-work/tools/ngrok/node_modules/async/lib/async.js:726:13
at /Users/gauravsheel/workfiles/web-work/tools/ngrok/node_modules/async/lib/async.js:52:16
at done (/Users/gauravsheel/workfiles/web-work/tools/ngrok/node_modules/async/lib/async.js:246:17)
at /Users/gauravsheel/workfiles/web-work/tools/ngrok/node_modules/async/lib/async.js:44:16
at /Users/gauravsheel/workfiles/web-work/tools/ngrok/node_modules/async/lib/async.js:723:17
at /Users/gauravsheel/workfiles/web-work/tools/ngrok/node_modules/async/lib/async.js:167:37
at /Users/gauravsheel/workfiles/web-work/tools/ngrok/node_modules/node-grok/lib/index.js:183:20
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)

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