You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
The text was updated successfully, but these errors were encountered:
the callback specified in the readme is missing the error parameter.
The API description is correct (Callback receives patterns collection filled in with default templates: function(err, patterns)) but the sample code is not right as it's missing the error argument.
I had the same issue, just run the code as follows:
require('node-grok').loadDefault(function (err, patterns) {
console.log('patterns is ', patterns);
var pattern = patterns.createPattern(p);
pattern.parse(str, function (err, obj) {
console.log(obj);
});
});
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)
The text was updated successfully, but these errors were encountered: