I have to do following transformation. In this a single record has to be split in 3 parts. cpu, user and nice. However need to have value of host and timestamp in all split as per they belong to particular cpu,user and nice
Input
[
{
"timestamp": "2021-10-29T18:13:31",
"host": "bbtpnj33",
"cpu": "1",
"user": "5.34",
"nice": "0"
},
{
"timestamp": "2021-10-29T18:13:32",
"host": "bbtpnj34",
"cpu": "2",
"user": "10",
"nice": "5"
}
]
Expected Output
[
{
"timestamp": "2021-10-29T18:13:31",
"host": "bbtpnj33",
"cpu": "1"
},
{
"timestamp": "2021-10-29T18:13:31",
"host": "bbtpnj33",
"user": "5.34"
},
{
"timestamp": "2021-10-29T18:13:31",
"host": "bbtpnj33",
"nice": "0"
},
{
"timestamp": "2021-10-29T18:13:32",
"host": "bbtpnj34",
"cpu": "2"
},
{
"timestamp": "2021-10-29T18:13:32",
"host": "bbtpnj34",
"user": "10"
},
{
"timestamp": "2021-10-29T18:13:32",
"host": "bbtpnj34",
"nice": "5"
}
]
I have to use NIFI JoltJsonTransformation for that need the JoltSpec. I did try many of them but not getting valid answer. I am new to Jolt, please help
My JOLT Expression
[
{
"operation": "shift",
"spec": {
"*": {
"cpu": "[&1][#1].cpu",
"user": "[&1][#1].user",
"nice": "[&1][#1].nice"
}
}
}
]
