Grok pattern with this log line - regex

basically I need to filter out Date - SEVERITY - JAVACLASSNAME - ERROR MESSAGE.
This is working for me..But its just half done.
(?[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2},[0-9]{3}) %{WORD:Severity}(?:%{GREEDYDATA:msg})
It doesnt show Javaclass..!
Here is the output I get
{
"Timestamp": [
[
"2015-03-03 03:12:16,978"
]
],
"Severity": [
[
"INFO"
]
],
"Error_Message": [
[
" [http-bio-16006-exec-71] [XYZ.ABC.JLM.app.task.ERT] [app:/saas reqid:23121221 jsid:* aid:* uid: org: vorg: un:] - Received to update queued for monitorId=54213213JBNJBSJBSJBS, worklow=8u298u2189u312, session=21684216814321"
]
]
}
LOGLINE
2015-03-03 03:12:16,978 INFO [http-bio-16006-exec-71] [XYZ.ABC.JLM.app.task.ERT] [app:/saas reqid:23121221 jsid:* aid:* uid: org: vorg: un:] - Received to update queued for monitorId=54213213JBNJBSJBSJBS, worklow=8u298u2189u312, session=21684216814321

This should work:
filter {
grok {
match => [
"message",
"%{TIMESTAMP_ISO8601:timestamp} %{LOGLEVEL:severity} \[(?<threadname>[^\]]+)\] \[(?<classname>[^\]]+)\] %{GREEDYDATA:message}"
]
overwrite => ["message"]
}
}

Related

Split log message on space for grok pattern

I am two days new to grok and ELK.
I am struggling with breaking up the log messages based on space and make them appear as different fields in the logstash.
My input pattern is:
2022-02-11 11:57:49 - app - INFO - function_name=add elapsed_time=0.0296 input_params=6_3
I would like to see different fields in the logstash/kibana for function_name, elapsed_time and input_params.
At the moment, I have a following .conf
input{
file{
path => "/path/to/log/file"
start_position => "beginning"
}
}
filter{
grok{
match => {"message" => "%{TIMESTAMP_ISO8601:timestamp} %{LOGLEVEL:log-level} %{(?<function_name>[^.]*)\.(?<elapsed_time>[^.]*)\.(?<input>[^.]*)}"}
}
date {
match => ["timestamp", "ISO8601"]
}
function_name {
match => ["function_name", "DATA"]
}
elapsed_time {
match => ["elapsed_time", "BASE16FLOAT"]
}
input {
match => ["input", "DATA"]
}
}
output{
elasticsearch{
hosts => ["localhost:9200"]
index => "math_apis"
}
stdout{codec => rubydebug}
}
But this only produces a following message in logstash
{
"host" => "hostname",
"#timestamp" => 2022-02-11T06:27:49.404Z,
"message" => "2022-02-11 11:57:49 - app - INFO - function_name=add elapsed_time=0.0296 input_params=6_3",
"path" => "path/to/log/file",
"#version" => "1",
"tags" => [
[0] "_grokparsefailure"
]
}
You can use the following pattern:
%{TIMESTAMP_ISO8601:timestamp} - \S+ - %{LOGLEVEL:log_level} - function_name=%{NOTSPACE:function_name} elapsed_time=%{NOTSPACE:elapsed_time} input_params=%{NOTSPACE:input}
Details:
%{TIMESTAMP_ISO8601:timestamp} - timestamp field
- - a literal string
\S+ - any one or more non-whitespace chars
- - a literal string
%{LOGLEVEL:log_level} - LOGLEVEL pattern
- function_name= - a literal string
%{NOTSPACE:function_name} - function_name field of one or more non-whitespace chars
elapsed_time= - space and elapsed_time= string
%{NOTSPACE:elapsed_time} - elapsed_time field of one or more non-whitespace chars
input_params= - literal string
%{NOTSPACE:input} - input field of one or more non-whitespace chars.
See more about Grok patterns here.
Test output:
{
"timestamp": [
[
"2022-02-11 11:57:49"
]
],
"YEAR": [
[
"2022"
]
],
"MONTHNUM": [
[
"02"
]
],
"MONTHDAY": [
[
"11"
]
],
"HOUR": [
[
"11",
null
]
],
"MINUTE": [
[
"57",
null
]
],
"SECOND": [
[
"49"
]
],
"ISO8601_TIMEZONE": [
[
null
]
],
"log_level": [
[
"INFO"
]
],
"function_name": [
[
"add"
]
],
"elapsed_time": [
[
"0.0296"
]
],
"input": [
[
"6_3"
]
]
}

How to pay a specific invoice in netsuite? using customerPayment

I am trying to pay a specific invoice using the customerpaymet endpoint, I made the JSON structure using the documentation from https://system.netsuite.com/help/helpcenter/en_US/APIs/REST_API_Browser/record/v1/2021.1/index.html#/definitions/customerPayment-applyCollection
This is my JSON:
{
"aracct": {
"id": "259"
},
"autoApply": false,
"apply": {
"items": [
{
"amount": 12.06,
"apply": true,
"doc": {
"id": 5517
}
}
]
},
"tranDate": "2021-10-13 3:34:01 PM",
"customForm": {
"id": "70"
},
"customer": {
"id": "3645"
},
"payment": 12.06,
"subsidiary": {
"id": "3"
}
}
This is the error:
{
"detail": "Error while accessing a resource. You have attempted an invalid sublist or line item operation. You are either trying to access a field on a non-existent line or you are trying to add or remove lines from a static sublist.",
"o:errorPath": "apply",
"o:errorCode": "USER_ERROR"
}
I would appreciate any help!
This is how i do it in PHP, you can look at it for ideas on what you can try changing.
$request = [
'record_data' => [
[
'internalid' => $nsOrder['internalId'],
'source_type' => 'invoice',
'result_type' => 'customerpayment',
'transform_values' => '',
'literal_fields'=> [
'undepfunds' => 'F',
'account' => '123',
'customer' => $nsOrder['entity']['internalId'],
'paymentmethod' => '8',//cc
'memo' => $message,
],
'sublists'=> [
['name'=>'apply',
'update' => [
[
'match'=> 'internalid',
'data'=>[
'internalid'=>$nsOrder['internalId'],
'apply'=>'T',
'amount' => $nsOrder['amountRemaining']
]
]
]
]
]
]
]
];
$result = $this->curl->transform($request);
The answer is that you need to select a combination of Undep Funds | PaymentMethod and Account in order for this to succeed. The documentation for this exists here

I am getting a parse error while using jq in the below json output

Error: parse error: ':' not as part of an object at line 2, column 13
Dont know where i am doing wrong can someone help me.
[
"Events": [
{
"InstanceEventId": "instance-event-0d59937288b749b32",
"Code": "system-reboot",
"Description": "The instance is scheduled for a reboot",
"NotAfter": "2019-03-15T22:00:00.000Z",
"NotBefore": "2019-03-14T20:00:00.000Z",
"NotBeforeDeadline": "2019-04-05T11:00:00.000Z"
}
]
]
this is not a valid JSON remove the named array "events"
[
[
{
"InstanceEventId": "instance-event-0d59937288b749b32",
"Code": "system-reboot",
"Description": "The instance is scheduled for a reboot",
"NotAfter": "2019-03-15T22:00:00.000Z",
"NotBefore": "2019-03-14T20:00:00.000Z",
"NotBeforeDeadline": "2019-04-05T11:00:00.000Z"
}
]
]
or remove the outer array
{
"Events": [
{
"InstanceEventId": "instance-event-0d59937288b749b32",
"Code": "system-reboot",
"Description": "The instance is scheduled for a reboot",
"NotAfter": "2019-03-15T22:00:00.000Z",
"NotBefore": "2019-03-14T20:00:00.000Z",
"NotBeforeDeadline": "2019-04-05T11:00:00.000Z"
}
]
}

unable to filter or search the data in different languages in django

I have posted data(ex:title field) in different languages, when i try to filter the data in get request it is giving empty result
GET /rails:
My get request result is :
[
{
"id": 1,
"type": "channel",
"filter": [
1
],
"data": [
1
],
"status": 0,
"rows": 0,
"title": "string"
},
{
"id": 2,
"type": "appgg",
"filter": [
2
],
"data": [
2
],
"status": 1,
"rows": 2,
"title": "ಚಲನಚಿತ್ರ"
}
]
GET /rails?title=string
it is giving proper result:
[
{
"id": 1,
"type": "channel",
"filter": [
1
],
"data": [
1
],
"status": 0,
"rows": 0,
"title": "string"
}
]
when i try to filter title data other than english i am getting empty result
GET /rails?title=ಚಲನಚಿತ್ರ:
expected result :
[
{
"id": 2,
"type": "appgg",
"filter": [
2
],
"data": [
2
],
"status": 1,
"rows": 2,
"title": "ಚಲನಚಿತ್ರ"
}
]
Actual result:
[]
when I try to print request params in my django views like below:
title = self.request.query_params.getlist('title',None)
print(title)
I am getting the following log:
title filter �²¨�¿¤Í°
Django is unable to identify the language I am passing, How can I add multi-language support in Django?
Thanks

To split a json file.. Extracting data between curly braces

I have a json file. I want to split that file into different parts..
Following is my file's content.
I want to split the content based on the curly brackets {},
"1010320": {
"abc": [
"1012220",
"hiiiiiiiii."
],
"xyz": "Describe"
},
"1012757": {
"pqr": [
"1013757",
"x"
]
},
"1014220": {
"abc": [
"1018420",
"sooooo"
],
"answer": "4th"
},
"1019660": {
"abc": [
"1031920",
"welcome"
],
"xyz": "Describing&Interpreting"
},
"1034280": {
"abc": [
"1040560",
"Ok..."
],
"nop": "Student Question"
},
The output should be:
1) "abc": [
"1012220",
"hiiiiiiiii."
],
"xyz": "Describe"
2) "pqr": [
"1013757",
"x"
]
3) "abc": [
"1018420",
"sooooo"
],
"answer": "4th"
plz.. help..
i think this will be useful for you
(?<=\{)\n\s+((?:[\n]+|.*)+?)\n\}
regex demo here : http://regex101.com/r/rS3wI5