HIVE:如何在JSON日志消息中解析/忽略SLF4J标头

时间:2013-09-04 13:38:08

标签: json hadoop log4j hive

我正在开发一个Hive演示,我想对包含JSON消息的文件执行和聚合查询,在每个日志行的开头用log4j样式消息开头:

20:49:07.962 [main] INFO com.example.application - {"DocId":"ABC","User":{"Id":1236,"Username":"larry1234","Name":"Larry","ShippingAddress":{"Address1":"789 Main St.","Address2":"","City":"Durham","State":"NC","PostalCode":"27713"},"Orders":[{"ItemId":1111,"OrderDate":"11/11/2012"},{"ItemId":2222,"OrderDate":"12/12/2012"}]}} 

我有大量此类记录,正在进行Hive演示。我知道Hive-JSON-Serde。但是我怎么告诉Hive忽略log4j前导码?

1 个答案:

答案 0 :(得分:0)

您可以使用get_json_object函数从记录中提取json数据并从其中构建。这个博客可以提供帮助。 http://thornydev.blogspot.in/2013/07/querying-json-records-via-hive.html