{
"cluster_name" : "c",
"definition_name" : "hive_metastore_process",
"firmness" : "HARD",
"latest_timestamp" : 1498716914911,
"maintenance_state" : "OFF",
"original_timestamp" : 1498416757291,
"service_name" : "HIVE",
"state" : "CRITICAL",
}
--
: {
"cluster_name" : "c",
"definition_name" : "hive_server_process",
"firmness" : "HARD",
"latest_timestamp" : 1498716912904,
"maintenance_state" : "OFF",
"original_timestamp" : 1498419634610,
"service_name" : "HIVE",
"state" : "CRITICAL",
}
我想将original_timestamp更新为日期格式?在unix中怎么做
答案 0 :(得分:1)
为了在命令行上处理json,jq
是你的朋友。
% jq '.original_timestamp |= (. / 1000 | floor | todate)' <<EOJ
{
"cluster_name": "c",
"definition_name": "hive_metastore_process",
"firmness": "HARD",
"latest_timestamp": 1498716914911,
"maintenance_state": "OFF",
"original_timestamp": 1498716914911,
"service_name": "HIVE",
"state": "CRITICAL"
}
EOJ
{
"cluster_name": "c",
"definition_name": "hive_metastore_process",
"firmness": "HARD",
"latest_timestamp": 1498716914911,
"maintenance_state": "OFF",
"original_timestamp": "2017-06-29T06:15:14Z",
"service_name": "HIVE",
"state": "CRITICAL"
}
%