Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]
Created 06-07-2017 11:04 AM
Hi, we need to add a default key:value with actual timestamp to the following json input structure:
[ {
"host" : "DUSTSADMIN.ads.xyz.de",
"host_icons" : "menu",
"host_state" : "UP",
"num_services_crit" : "0",
"num_services_ok" : "28",
"num_services_pending" : "0",
"num_services_unknown" : "0",
"num_services_warn" : "0"
}, {
"host" : "DUSTSVMDC01.ads.xyz.de",
"host_icons" : "menu",
"host_state" : "UP",
"num_services_crit" : "0",
"num_services_ok" : "34",
"num_services_pending" : "0",
"num_services_unknown" : "0",
"num_services_warn" : "0"
}, {
"host" : "DUSTSVMDC02.ads.xyz.de",
"host_icons" : "menu",
"host_state" : "UP",
"num_services_crit" : "0",
"num_services_ok" : "34",
"num_services_pending" : "0",
"num_services_unknown" : "0",
"num_services_warn" : "0"
} ]
needed output:
[ { "ctime" : "Current_timestamp",
"host" : "DUSTSADMIN.ads.xyz.de",
"host_icons" : "menu",
"host_state" : "UP",
"num_services_crit" : "0",
"num_services_ok" : "28",
"num_services_pending" : "0",
"num_services_unknown" : "0",
"num_services_warn" : "0"
}, {"ctime" : "Current_timestamp",
"host" : "DUSTSVMDC01.ads.xyz.de",
"host_icons" : "menu",
"host_state" : "UP",
"num_services_crit" : "0",
"num_services_ok" : "34",
"num_services_pending" : "0",
"num_services_unknown" : "0",
"num_services_warn" : "0"
}, {"ctime" : "Current_timestamp",
"host" : "DUSTSVMDC02.ads.xyz.de",
"host_icons" : "menu",
"host_state" : "UP",
"num_services_crit" : "0",
"num_services_ok" : "34",
"num_services_pending" : "0",
"num_services_unknown" : "0",
"num_services_warn" : "0"
} ]
Created 06-07-2017 01:10 PM
As of NiFi 1.2.0, you can use Expression Language in JOLT specifications (NIFI-3010). The following Chain spec adds the ctime field to your input with the current timestamp:
[{
"operation": "default",
"spec": {
"*": {
"ctime": "${now()}"
}
}
}]If you want ctime you have an integer rather than a string, you can use the following EL expression:
${now():toNumber()}
Created 06-07-2017 01:10 PM
As of NiFi 1.2.0, you can use Expression Language in JOLT specifications (NIFI-3010). The following Chain spec adds the ctime field to your input with the current timestamp:
[{
"operation": "default",
"spec": {
"*": {
"ctime": "${now()}"
}
}
}]If you want ctime you have an integer rather than a string, you can use the following EL expression:
${now():toNumber()}
Created 06-07-2017 01:57 PM
Hi Matt,
now i got only this output :
[{
"ctime":"${now()}",
"host":"DUSTSADMIN.ads.xyz.de",
"host_icons":"menu",
"host_state":"UP",
"num_services_crit":"0",
"num_services_ok":"28",
"num_services_pending":"0",
"num_services_unknown":"0",
"num_services_warn":"0"
},
"ctime":"${now()}",
"host":"DUSTSVMDC01.ads.xyz.de",
"host_icons":"menu",
"host_state":"UP",
"num_services_crit":"0",
"num_services_ok":"34",
"num_services_pending":"0",
"num_services_unknown":"0",
"num_services_warn":"0"
},{"ctime":"${now()}",
"host":"DUSTSVMDC02.ads.xyz.de",
"host_icons":"menu",
"host_state":"UP",
"num_services_crit":"0",
"num_services_ok":"34",
"num_services_pending":"0",
"num_services_unknown":"0",
"num_services_warn":"0"
}]
maybe there ist something wrong with ""?
regards Timo
Created 06-07-2017 02:33 PM
I think my problem my version is : nifi-1.1.2
Created 06-07-2017 03:15 PM
Hi Matt,
after upgrading to nifi 1.2 all works fine !!!
Great work! Thanks
Created 06-07-2017 01:55 PM
Hi Matt,
now i got only this output :
[{
"ctime":"${now()}",
"host":"DUSTSADMIN.ads.xyz.de",
"host_icons":"menu",
"host_state":"UP",
"num_services_crit":"0",
"num_services_ok":"28",
"num_services_pending":"0",
"num_services_unknown":"0",
"num_services_warn":"0"
},
"ctime":"${now()}",
"host":"DUSTSVMDC01.ads.xyz.de",
"host_icons":"menu",
"host_state":"UP",
"num_services_crit":"0",
"num_services_ok":"34",
"num_services_pending":"0",
"num_services_unknown":"0",
"num_services_warn":"0"
},{"ctime":"${now()}",
"host":"DUSTSVMDC02.ads.xyz.de",
"host_icons":"menu",
"host_state":"UP",
"num_services_crit":"0",
"num_services_ok":"34",
"num_services_pending":"0",
"num_services_unknown":"0",
"num_services_warn":"0"
}]
maybe there ist something wrong with ""?
regards Timo