Logstash convert number to string in array of objects

Hello,
I have 2 logstash flows writing to the same index. For first flow value for "code" is number and for second flow its string. Please find the sample below

"Response": {
			"ResponsePayLoad": {
				"name": "OK",
				"statusDetails": [
					{
						"message": "OK",
						"code": 200
					}
				]
			}
}
"Response": {
			"ResponsePayLoad": {
				"name": "OK",
				"statusDetails": [
					{
						"message": "OK",
						"code": "422-01"
					}
				]
			}
}

I am getting parsingException for second flow while trying to convert to number.
I want to convert code value in first flow from number to string in order to handle both flows.
I tried below config, but its not working.

mutate {
        convert => {
          "message.Response.ResponsePayLoad.statusDetails.code" => "string"
        }
mutate {
        convert => {
          "message.Response.ResponsePayLoad.statusDetails[0].code" => "string"
        }
    }

That should be

[Response][ResponsePayLoad][statusDetails][0][code]

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.