Hey everyone hope you all are doing well I am in trouble can someone please help me :
-
we’re fetching logs from promtail into loki.
-
we’ve the following log entry from which we need to pull out status code, requestdatetime and requestresponsetime.
-
however, as the log line is huge we are unable to create a regex out of it for labeling purposes - so, we need an assistance/guidance w.r.t. how to parse the log to pull out needful data
-
Sample; below example we can work out - but as our line is huge - how can we create similar regex for it
-
127.0.0.1 - - [01/Jan/2023:21:33:40 +0100] “GET /grafana_local/api/search?dashboardUIDs=alP6m1c4k&limit=30 HTTP/1.1” 200 525 “http://localhost/grafana_local/?orgId=1” “Mozilla/5.0 (X11; Linux x86_64; rv:108.0) Gecko/20100101 Firefox/108.0”
-
{job=“apache”} | pattern
<ip> - - [<dttm>] “<method> <resource> <protocol>” <status> <object_size> “<referer>” “<user_agent>“
-
job=“apache”} | pattern
<ip> - - [<_>] “<_> <_> <_>” <_> <_> “<_>” “<_>“
2023-05-29T12:46:57.437Z 0123abcd-xz12-9kjh INFO { type: ‘LOGS RESPONSE’, information: ‘{“channel”:“myapplication”,“principalId”:“abcd142s”,“statusCode”:200,“headers”:{“OperationName”:“GetDetails”,“MessageId”:“0123abcd-xz12-9kjh”,“RequestDateTime”:“2023-05-29T20:46:57.424”,“ResponseDateTime”:“2023-05-29T20:46:57.437”,“X-Frame-Options”:“deny”,“X-XSS-Protection”:“1; mode=block”,“X-Content-Type-Options”:“nosniff”,“Strict-Transport-Security”:“max-age=31536000 always; includeSubDomains”},“body”:“{\“result\”:[{\“number\”:\“123456\”,\“alias\”:\“alpha\”,\“age\”:\“10\”,\“channel\”:[\“myapplication\”],\“isLinked\”:false,\“position\”:0,\“Detail\”:\”\“,\“quickAction\”:[\”|SecondaryDefault|1\“,\”|SecondaryDefault|2\“,\”|SecondaryDefault|3\“,\”|SecondaryDefault|4\“,\”|SecondaryDefault|5\“,\”|SecondaryDefault|6\“,\”|SecondaryDefault|7\“]}]}”}’ }