This is regarding the grokparsefailure - elastic-stack

This is my sample log.
<4>Nov 19 17:08:28 BAGW-R kernel: [BlackRidge|Gateway|5.0.0.8928M]
class="Attribution" category="Filter Rule: To_Trusted Drop"
ctx="bump0" filterNumber="1022" src="192.168.120.173" srcPort="41178"
dest="192.168.120.100" destPort="443" gwAction="DISCARD"
gwMode="Enforce"
Grok pattern:
%{WORD:class} %{WORD:category} %{WORD:ctx} %{NUMBER:fil ternumber}
%{IP:src} %{NUMBER:srcPort} %{IP:dest} %{NUMBER:destPort} %{WORD:gwAc
tion} %{WORD:gwMode}
I get a grokparsefailure.
Can anyone please help.

As per my understanding you're getting this error because the pattern you have used does not match the logs you have provided.
Can you be more specific what fields you are trying to capture from this log ?
I have wrote a grok pattern for the logs you must follow similar way such that it matches the whole log. In case you get found unknown escape character error use \ twice instead of single \
%{MONTH:month}%{SPACE}%{MONTHDAY:date}%{SPACE}%{TIME:time}%{SPACE}%{GREEDYDATA:temp1}\]%{SPACE}class\=\"%{WORD:class}\"%{SPACE}category\=\"%{GREEDYDATA:category}\"%{SPACE}ctx\=\"%{WORD:ctx}\"%{SPACE}filterNumber\=\"%{NUMBER:filternumber}\"%{SPACE}src\=\"%{IPV4:src}\"%{SPACE}srcPort\=\"%{DATA:srcport}\"%{SPACE}dest\=\"%{IPV4:dest}\"%{SPACE}destPort\=\"%{NUMBER:destport}\"%{SPACE}gwAction\=\"%{WORD:gwaction}\"%{SPACE}gwMode\=\"%{WORD:gwmode}\"
I have written the whole grok command please check if this works. I have made an assumption that u would get all logs in this format.
Use this website to test ur grok pattern: https://grokconstructor.appspot.com/do/match#result
Existing grok pattern: https://grokdebug.herokuapp.com/patterns#

Related

Why is Gatling failing on a valid jsonpath?

I have the following .check on my returned body: (I changed the values for security reasons but the structure is the same)
.exec(http("Get ids")
.post("GetIds")
.body(ElFileBody("json/getIds.json")).asJson
.check(jsonPath("$...Types..[?(#.Type == 'web')].id").findAll.saveAs("IDLlist"))
But the transaction fails with "Gettting findAll.exists extraction crashed: end of input expected when trying to extract values from a returned body"
Gatling prints the body of the failed transaction, when I take the exact body that the transaction had just failed on to http://jsonpath.com/ and
evaluate the jsonpath that had just failed, I get good results with no issues. This means that the returned body is correct and that the jsonpath is also correct.
What is the issue then?
Thanks to Stephane from the Gatling forum, I found that $..Files[?(#.Format == 'DASH_Web')].URL is correct works instead of the variation that I had.
Since http://jsonpath.com/ was able to extract the correct path using my original syntax, I think its important to note that Gatling jsonpath is much more conservative in its syntax.
It seems your JSON path syntax is wrong --> "$...Types..[?(#.Type == 'web')].id"
Try using JSONPath Online Evaluator -- http://jsonpath.com/ to find correct json syntax

AWS CloudWatch Log Metric Filter with JSON key has character space

When creating an AWS CloudWatch Log Metric Filter, how would you match terms in JSON Log Events where the key has a character space in the name?
For example, let's assume there's a log line with JSON element like the following...
{"Event":"SparkListenerLogStart","Spark Version":"2.4.0-SNAPSHOT"}
How would you reference the "Spark Version"? $."Spark Version", $.Spark Version, $.Spark\ Version, and $.[Spark Version] don't work.
I couldn't find the answer in the AWS Filter and Pattern Syntax documentation.
At the time of writing, this is not possible. AWS will probably fix that at some point, but for now the only workaround would be to use the non-JSON syntax and search for the exact string. The following filter:
"\"Spark Version\":\"2.4.0-SNAPSHOT\""
will match:
{"Event":"SparkListenerLogStart","Spark Version":"2.4.0-SNAPSHOT"}

How to use OSRM's match service

As stated in the header: how can I use the match call?
I tried
http://router.project-osrm.org/match/v1/driving/8.610048,46.99917;8.530232,47.051?overview=full&radiuses=49;49
I am not sure, whether the list of radiuses is given correctly.
I can't get it work. I also tried [49;49] or {49;49} The command works with route:
http://router.project-osrm.org/route/v1/driving/8.610048,46.99917;8.530232,47.051?overview=full
For backround see here
Edit: If you look at the example here, itr seems, the timestamps are not needed /match/v1/{profile}/{coordinates}?steps={true|false}&geometries={polyline|polyline6|geojson}&overview={simplified|full|false}&annotations={true|false}
From the docs:
Large jumps in the timestamps (> 60s) or improbable transitions lead to trace splits if a complete matching could not be found.
I think that's the problem with your request. The two given points are more than 60s appart and OSRM cannot match them successfully. The radiuses are specified correctly.
The following query works for me:
http://router.project-osrm.org/match/v1/driving/8.610048,46.99917;8.620048,46.99917?overview=full&radiuses=49;49
This returns:
{"tracepoints":[{"location":[8.610971,46.998963],"name":"Alte Kantonstrasse","hint":"GKUFgJEhBwAAAAAAHQAAAAAAAAC5AAAAAAAAAB0AAAAAAAAAuQAAAPsCAACbZIMAsyXNAgBhgwCCJs0CAAAPABki8hY=","matchings_index":0,"waypoint_index":0,"alternatives_count":0},{"location":[8.620295,46.999681],"name":"Schönenbuchstrasse","hint":"nIEFAJ7IFIA3AAAAZAAAAAAAAADYAAAANwAAAGQAAAAAAAAA2AAAAPsCAAAHiYMAgSjNAhCIgwCCJs0CAAAPABki8hY=","matchings_index":0,"waypoint_index":1,"alternatives_count":5}],"matchings":[{"distance":922.3,"duration":114.1,"weight":114.1,"weight_name":"routability","geometry":"onz}Gqyps#Wg#S_#aCaFMUYo#c#w#OKOCWmAWs#aBiDsAsCMYH[HY\\_#h#ObBW^w#BQAUKu#ASF[ZaABOFYpAyIf#mD","confidence":0.000982,"legs":[{"distance":922.3,"duration":114.1,"weight":114.1,"summary":"","steps":[]}]}],"code":"Ok"}
So the two given input points 8.610048,46.99917 and 8.620048,46.99917 are matched to 8.610971,46.998963 and 8.620295,46.999681.
So as far as I can see, if you want to implement something like that, you need to give OSRM more input points on its way which are less than 60s apart.
See also here for an explanation about the differences between route and match service.

Grok filter for a time counter HH:MM

I'm quite new to ELK and Grok-filtering, and I'm struggling with parsing this particular pattern in my grok filter.
I've used the grok debugger to try and solve this, but although I like the tool, I just get confused by the custom patterns.
Eventually, I hope to parse lots of log files sent by filebeat to logstash, then send the parsed logs to elasticsearch and display with kibana or some similar visualization tool.
The lines that I need to parse follow the following pattern:
1310 2017-01-01 16:48:54 [325:51] [326:49] [359:57] Some log info text
The first four digits is a log type identifier, and will be used for grouping. I've called the field "LogLineID".
The date is formatted YYYY-MM-DD HH:MM:SS, and is parsed ok. I called the field "LogDate".
But now the problem begins. Within the square brackets, I have counters, formatted as MM:SS if you like. I cannot for the life of me find a way to sort these out, but I need to compare these times, hence I want to store them as minutes and seconds, not just numbers.
The first is a counter "TimeSpent",
the second is a counter "TimeStarted" and
the third is a counter "TimeSinceDown".
Then, last, comes the info text, which I've managed to grok with simply applying %{GREEDYDATA:LogInfo}.
I notice that the amount of minutes could be far higher than the standard 60 minutes within an hour, so I may be barking up the wrong tree here trying to parse it with date patterns such as TIMESTAMP_ISO8601, but then, I don't really know how else to do this.
So, I came this far:
%{NUMBER:LogLineID} %{TIMESTAMP_ISO8601:LogDate}
and were as mentioned able to (by cutting away the square bracket parts) to parse the log info text with
%{GREEDYDATA:LogInfo}
to create a field LogInfo.
But that's were I'm stuck. Could someone please help me figure out the rest?
Massive thanks in advance.
PS! I also found %{NUMBER:duration}, but it could as far as I could tell only parse timestamps with dot, not colon..
grok regex expression can help you solve the problem.
but first I wanna make sure that do you mean [325:51] [326:49] [359:57] are the three component that you wanna to fetch? And it will returns the result like :
TimeSpent: 325:51
TimeStarted: 326:49
TimeSinceDown: 359:57
were i get the point , you can use my ways in on of the following suggestions:
define your own custom pattern files and add the pattern in your file.
just use the expression in filter part of logstash conf file
hope it will helps you
Ah, there was a space.. Actually, I was misleading myself and everybody in my question, as it was not actually that log line that was causing problems. I just took the first one, not realizing where the problem really were, but the one causing problems had a space within the brackets as such: [ 42:31]. There are also some parts where there are two spaces, so the way I managed to solve this was to include a %{SPACE} between the \[ and the %{NUMBER}:
%{NUMBER:LogLineID} %{TIMESTAMP_ISO8601:LogDate} \[%{SPACE}%{NUMBER:TimeSpentMinutes}\:%{NUMBER:TimeSpentSeconds}\] \[%{SPACE}%{NUMBER:TimeStartedMinutes}\:%{NUMBER:TimeStartedSeconds}\] \[%{SPACE}%{NUMBER:TimeSinceDownMinutes}\:%{NUMBER:TimeSinceDownSeconds}\] %{GREEDYDATA:LogText}
I still haven't solved the merging of minutes and seconds, but this I can also handle in a later stage.
Thanks to Lin Don for showing an interest in my problem, and sorry for not replying sooner.
Hope the solution will help others (or even myself) if their stuck on the same kind of problem.
Note to myself: Read the logs more carefully before grok'ing.. :)

grok pattern match for aceess log event

I am new to ELK and grok pattern matching. I am trying to build grok pattern match for my access log event and I am getting grokparsefailure message.
Here is my event log:
111.22.333.44 2015-09-15 14:27:02 POST /test/service/testservice 200 359 0.016
Grok pattern (after soem reasrch I came up with this):
%{IP:client}%{DATESTAMP_EVENTLOG:logeventtime}%{WORD:method}%{URIPATHPARAM:request}%{NUMBER:HTTPStatus}%{NUMBER:bytes}%{NUMBER:duration}
I suspected the issue might be with date match above and I tried to remove the psace between the date and time and try pattern matching and that did not work either. I removed the date and time all together and tried for the remaning and that also was giving same error. I am at a loss to where the issue is. any inputs would be helpful. Thanks!
Start here: http://grokdebug.herokuapp.com/discover?#
%{HOST:client} %{TIMESTAMP_ISO8601:event_date_time} %{WORD:http_method} %{URIPATHPARAM} %{NUMBER:status} %{NUMBER:bytes} %{NUMBER:duration}