Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ public class BrainLogParser {
"(\\d{4}-\\d{2}-\\d{2})[T"
+ " ]?(\\d{2}:\\d{2}:\\d{2})(\\.\\d{3})?(Z|([+-]\\d{2}:?\\d{2}))?"),
"<*DATETIME*>");
// UUID
DEFAULT_FILTER_PATTERN_VARIABLE_MAP.put(
Pattern.compile(
"\\b[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\\b"),
"<*UUID*>");
// Hex Decimal, letters followed by digits, float numbers
DEFAULT_FILTER_PATTERN_VARIABLE_MAP.put(
Pattern.compile(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,22 @@ public void testPreprocess() {
assertEquals(expectedResult, result);
}

@Test
public void testPreprocessWithUUID() {
String logMessage = "127.0.0.1 - 1234 something, user_id:c78ac970-f0c3-4954-8cf8-352a8458d01c";
String logId = "log1";
List<String> expectedResult =
Arrays.asList("<*IP*>", "-", "<*>", "something", "user_id:<*UUID*>", "log1");
List<String> result = parser.preprocess(logMessage, logId);
assertEquals(expectedResult, result);
// Test with different delimiter
logMessage = "127.0.0.1=1234 something, user_id:c78ac970-f0c3-4954-8cf8-352a8458d01c";
logId = "log2";
expectedResult = Arrays.asList("<*IP*>=<*>", "something", "user_id:<*UUID*>", "log2");
result = parser.preprocess(logMessage, logId);
assertEquals(expectedResult, result);
}

@Test
public void testPreprocessWithIllegalInput() {
String logMessage = "127.0.0.1 - 1234 something";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,21 @@ public void testBrainAggregationModeWithGroupByClause() throws IOException {
ImmutableMap.of(
"<token1>", ImmutableList.of("6996194389878584395", "-1547954353065580372"))));
}

@Test
public void testBrainParseWithUUID() throws IOException {
JSONObject result =
executeQuery(
String.format(
"source=%s | eval body = '[PlaceOrder] user_id=d664d7be-77d8-11f0-8880-0242f00b101d"
+ " user_currency=USD' | head 1 | patterns body method=BRAIN mode=label |"
+ " fields patterns_field, tokens",
Index.WEBLOG.getName()));
verifySchema(result, schema("patterns_field", "string"), schema("tokens", "struct"));
verifyDataRows(
result,
rows(
"[PlaceOrder] user_id=<token1> user_currency=USD",
ImmutableMap.of("<token1>", ImmutableList.of("d664d7be-77d8-11f0-8880-0242f00b101d"))));
}
}
Loading