Hello,
How do i parse the values from the raw log which is viewed in a JSON format into a code snippet whether the value is a top level or nested?
In the example -
{
"textPayload": " customer: 12345,",
"insertId": "avhvhjmk",
"resource": {
"type": "k8s_container",
"labels": {
"cluster_name": "test-gke",
"project_id": "project-gke",
"location": "me-west1",
"container_name": "test-container",
"namespace_name": "default",
"pod_name": ”test-pod"
}
},
"timestamp": "2025-01-07T13:29:46.060650557Z",
"severity": "INFO",
"labels": {
"k8s-pod/app": "test-app",
"k8s-pod/pod-template-hash": "513gvhcd",
"compute.googleapis.com/resource_name": "test-gke-pool"
},
"logName": "projects/project-gke/logs/stdout",
"receiveTimestamp": "2025-01-07T13:29:46.193718123Z"
}
I’d like to convert the “location” field into the udm.target.location.name value, “severity” field into the udm.principal.security_result.severity_details value, and the “k8s-pod/app” field into the udm.principal.application value.
How can I do this?
Thank you!
Hi,
I'd recommend taking a look at a recent blog I did related to parsing JSON logs to UDM. It should contain all the example to do what you're looking for: https://medium.com/@cloudymike/parsing-netflow-data-in-google-secops-2f1b0f58ea49
-mike
Hi @Roni ,
Please use the below mentioned snippet it will successfully parse the fields which you have mentioned. Using "gsub" function i have converted the embedded Json into KV format.
I tried this code but I got an error -
Error: generic::unimplemented: failed to create augmentor pipeline: failed to extract filters: failed to create filter from agent 17: filter factory failed for "statedump": line 81, col 9: no filter implemented for "statedump" label
Thanks
Hi @Roni ,
Statedump is just for debugging, while validating the parser please comment it out. The parser will be working as expected.