मैं एक regex कि एक को खिलाया जा सकता रहा हूँहाइव RegexSerDe बहुपंक्ति लॉग मिलान
"input.regex"="the regex goes here"
हालत के रूप में हाइव QL के बयान "बाहरी तालिका बनाने के" है कि फाइलों में लॉग RegexSerDe पढ़ने होना चाहिए निम्न रूप में कर रहे हैं:
2013-02-12 12:03:22,323 [DEBUG] 2636hd3e-432g-dfg3-dwq3-y4dsfq3ew91b Some message that can contain any special character, including linebreaks. This one does not have a linebreak. It just has spaces on the same line.
2013-02-12 12:03:24,527 [DEBUG] 265y7d3e-432g-dfg3-dwq3-y4dsfq3ew91b Some other message that can contain any special character, including linebreaks. This one does not have one either. It just has spaces on the same line.
2013-02-12 12:03:24,946 [ERROR] 261rtd3e-432g-dfg3-dwq3-y4dsfq3ew91b Some message that can contain any special character, including linebreaks.
This is a special one.
This has a message that is multi-lined.
This is line number 4 of the same log.
Line 5.
2013-02-12 12:03:24,988 [INFO] 2632323e-432g-dfg3-dwq3-y4dsfq3ew91b Another 1-line log
2013-02-12 12:03:25,121 [DEBUG] 263tgd3e-432g-dfg3-dwq3-y4dsfq3ew91b Yet another one line log.
मैं निम्नलिखित बनाने के बाहरी तालिका कोड का उपयोग कर रहा:
CREATE EXTERNAL TABLE applogs (logdatetime STRING, logtype STRING, requestid STRING, verbosedata STRING)
ROW FORMAT SERDE 'org.apache.hadoop.hive.contrib.serde2.RegexSerDe'
WITH SERDEPROPERTIES
(
"input.regex" = "(\\A[[0-9:-] ]{19},[0-9]{3}) (\\[[A-Z]*\\]) ([0-9a-z-]*) (.*)?(?=(?:\\A[[0-9:-] ]{19},[0-9]|\\z))",
"output.format.string" = "%1$s \\[%2$s\\] %3$s %4$s"
)
STORED AS TEXTFILE
LOCATION 'hdfs:///logs-application';
यहां बात है:
यह प्रत्येक लॉग की सभी पहली पंक्तियों को खींचने में सक्षम है। लेकिन लॉग की अन्य पंक्तियां जिनमें एक से अधिक पंक्तियां नहीं हैं। मैंने सभी लिंकों की कोशिश की, \z
को \Z
के साथ \A
^
और \Z
या \z
$
के साथ प्रतिस्थापित किया, कुछ भी काम नहीं किया। क्या मुझे output.format.string के %4$s
में कुछ याद आ रहा है? या मैं regex ठीक से उपयोग नहीं कर रहा हूँ?
क्या regex करता है:
यह टाइमस्टैम्प पहले लॉग प्रकार (DEBUG
या INFO
या जो कुछ भी) के द्वारा पीछा किया, तो ID
किसी से भी पीछा (लोअर केस अक्षर, संख्या और हाइफ़न का मिश्रण) से मेल खाता है, जब तक अगला टाइमस्टैम्प नहीं मिलता है, या इनपुट के अंत तक अंतिम लॉग प्रविष्टि से मेल खाने के लिए मिलता है। मैंने अंत में /m
जोड़ने का भी प्रयास किया, इस मामले में, उत्पन्न तालिका में सभी नल मान हैं।
आप उस बच्चे को क्यों सरणी नहीं देते? (lol यह एक क्रिया भी नहीं है, लेकिन stil ... आप उनमें से प्रत्येक को सरणी में सेट नहीं कर सका? तो पहली पंक्ति कुंजी 0 होगी, दूसरा मल्टीलाइन आइटम 1 में होगा, दूसरा दो 2 और 3 में होगा और आप उन्हें अपनी पसंद के अनुसार कॉल कर सकते हैं) – user1576978