gpt4 book ai didi

json - Hive为Fluentd Apache日志数据创建表语句

转载 作者:行者123 更新时间:2023-12-02 21:41:59 28 4
gpt4 key购买 nike

我正在使用Fluentd捕获和合并HDFS中的Apache日志数据。我将代理配置为将数据写入HDFS,即/etc/td-agent/td-agent.conf文件包含:

<source>
type tail
path /var/log/httpd/access_log
pos_file /var/log/td-agent/httpd-access.log.pos
tag apache.access
format apache2
</source>

<match apache.access>
type webhdfs
host fqdn.of.name.node
port 50070
path /data/access_logs/access.log.%Y%m%d_%H.${hostname}.log
flush_interval 10s
</match>

我为 Fluentd documentation启用了HDFS附加。数据流完美地跨越。在过去的几周中,它一直在无故障地流式传输数百万笔交易。

数据存储在包含以下行的文件中:
2015-01-10T17:00:00Z    apache.access   {"host":"155.96.21.4","user":null,"method":"GET","path":"/somepage/index.html","code":200,"size":8192,"referer":null,"agent":"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET4.0C; .NET4.0E)"}

每行包含三个制表符分隔的元素:
  • 时间戳
  • 标识标签
  • JSON,其中包含Apache日志
  • 中各列的键/值对

    我正在尝试创建一个Hive表,但不确定如何处理它是由制表符分隔的字符串和每行JSON混合而成的事实。我知道Hive有一个JSON解串器,但是我认为这行不通,因为记录不是纯JSON。

    有人对如何为此数据编写创建表语句有建议吗?

    最佳答案

    尝试将以下参数添加到out_wedhdfs配置中:

    output_data_type json

    这应该记录在案。我将尽快更新文档。

    关于json - Hive为Fluentd Apache日志数据创建表语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28076949/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com