Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ingest node - user agent, move device to an object (#38115) #38121

Merged
merged 1 commit into from
Jan 31, 2019
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
4 changes: 3 additions & 1 deletion docs/reference/ingest/processors/user-agent.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ Which returns
"version": "10.10.5",
"full": "Mac OS X 10.10.5"
},
"device": "Other"
"device" : {
"name" : "Other"
},
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,13 @@ public IngestDocument execute(IngestDocument ingestDocument) {
}
break;
case DEVICE:
Map<String, String> deviceDetails = new HashMap<>(1);
if (uaClient.device != null && uaClient.device.name != null) {
uaDetails.put("device", uaClient.device.name);
deviceDetails.put("name", uaClient.device.name);
} else {
uaDetails.put("device", "Other");
deviceDetails.put("name", "Other");
}
uaDetails.put("device", deviceDetails);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ public void testCommonBrowser() throws Exception {
os.put("version", "10.9.2");
os.put("full", "Mac OS X 10.9.2");
assertThat(target.get("os"), is(os));
assertThat(target.get("device"), is("Other"));
Map<String, String> device = new HashMap<>();
device.put("name", "Other");
assertThat(target.get("device"), is(device));
}

@SuppressWarnings("unchecked")
Expand All @@ -136,7 +138,9 @@ public void testUncommonDevice() throws Exception {
os.put("full", "Android 3.0");
assertThat(target.get("os"), is(os));

assertThat(target.get("device"), is("Motorola Xoom"));
Map<String, String> device = new HashMap<>();
device.put("name", "Motorola Xoom");
assertThat(target.get("device"), is(device));
}

@SuppressWarnings("unchecked")
Expand All @@ -157,7 +161,9 @@ public void testSpider() throws Exception {
assertNull(target.get("version"));
assertNull(target.get("os"));

assertThat(target.get("device"), is("Spider"));
Map<String, String> device = new HashMap<>();
device.put("name", "Spider");
assertThat(target.get("device"), is(device));
}

@SuppressWarnings("unchecked")
Expand All @@ -181,6 +187,8 @@ public void testUnknown() throws Exception {

assertNull(target.get("os"));

assertThat(target.get("device"), is("Other"));
Map<String, String> device = new HashMap<>();
device.put("name", "Other");
assertThat(target.get("device"), is(device));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
- match: { _source.user_agent.original: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.149 Safari/537.36" }
- match: { _source.user_agent.os: {"name":"Mac OS X", "version":"10.9.2", "full":"Mac OS X 10.9.2"} }
- match: { _source.user_agent.version: "33.0.1750" }
- match: { _source.user_agent.device: "Other" }
- match: { _source.user_agent.device: {"name": "Other" }}

---
"Test user agent processor with parameters":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
id: 1
- match: { _source.field1: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.149 Safari/537.36" }
- match: { _source.user_agent.name: "Test" }
- match: { _source.user_agent.device: "Other" }
- match: { _source.user_agent.device: {"name": "Other" }}
- is_false: _source.user_agent.os
- is_false: _source.user_agent.version