Parsing mongo logs to find the client IP from the context

2020-09-21T21:21:37.672+0000 I WRITE [conn15303751] update test.postInsightsContext query: { _id: “225264” } planSummary: IDHACK update: { _id: “225264”, accountId: 322, contextInfo: { tester: true }, _class: “com.spr.beans.d” } keysExamined:1 docsExamined:1 nMatched:1 nModified:0 numYields:0 locks:{ Global: { acquireCount: { r: 1, w: 1 } }, Database: { acquireCount: { w: 1 } }, Collection: { acquireCount: { w: 1 } } } 0ms

So in above query context : conn15303751, when i want to know the actual client ip for this context, i need to parse the logs again to find something like this

2020-09-21T21:21:37.184+0000 I NETWORK [conn15303751] received client metadata from 10.0.5.2:50692 conn15303751: { driver: { name: “mongo-java-driver|legacy”, version: “871df02c6e00ce83812cf2cdeb6d80e928ee794f” }, os: { type: “Linux”, name: “Linux”, architecture: “amd64”, version: “3.10.0-1127.el7.x86_64” }, platform: “Java/Oracle Corporation/1.8.0_131-b11” }

So this is how i will be able to map conn15303751 with 10.0.5.2:50692.
But when i want to find client IP for each query in logs, it becomes tough.
So is there any other way to do this? also any specific reason as to why mongo doesnt put IP in context instead of string representation of thread?

I think you can use jq utility on Unix servers

https://docs.mongodb.com/manual/reference/log-messages/#parsing-structured-log-messages

or from shell

db.currentOp(true).inprog.forEach(function(d){if(d.client)print(d.client, d.connectionId)})
127.0.0.1:59630 2

Actually jq can be used when you trying to parse it manually from the logs. correct?
But suppose you are parsing logs from logstash on mongo box and sending it to some other place for visualization, there when you see queries they will have context in them, so here i need to map each context with a client IP.