FAQ » History » Version 3
Luke Murphey, 10/29/2015 06:05 PM
1 | 1 | Luke Murphey | h1. FAQ |
---|---|---|---|
2 | 1 | Luke Murphey | |
3 | 1 | Luke Murphey | h2. Can I specify more than one selector (to match different things on a single page) |
4 | 1 | Luke Murphey | |
5 | 1 | Luke Murphey | Yes, enter multiple selectors separated by commas. To match both span and div tags, you would enter a selector of "span,div". |
6 | 1 | Luke Murphey | |
7 | 1 | Luke Murphey | h2. Can I use attributes to set the field names? |
8 | 1 | Luke Murphey | |
9 | 1 | Luke Murphey | You can use the "Name Attributes" option on the Output section to tell the app to use attribute values as the field name. |
10 | 1 | Luke Murphey | |
11 | 1 | Luke Murphey | For example, consider the following HTML: |
12 | 1 | Luke Murphey | |
13 | 1 | Luke Murphey | <pre> |
14 | 1 | Luke Murphey | <div id="model">Focus</div> |
15 | 1 | Luke Murphey | <div name="submodel">ST</div> |
16 | 1 | Luke Murphey | <div name="make" id="car">Ford</div> |
17 | 1 | Luke Murphey | </pre> |
18 | 1 | Luke Murphey | |
19 | 2 | Luke Murphey | Assuming you have the CSS selector set such that it matches all "div" tags, you would get the following output: |
20 | 1 | Luke Murphey | |
21 | 2 | Luke Murphey | match=Focus match=ST match=Ford |
22 | 2 | Luke Murphey | |
23 | 2 | Luke Murphey | The matches do not distinguish which div tag was set (cannot tell which field is the model, submodel or make). If the setting of the name attributes is "name", then the app would look for the "name" attribute and use that as the name. This results in: |
24 | 2 | Luke Murphey | |
25 | 2 | Luke Murphey | match=Focus submodel=ST make=Ford |
26 | 2 | Luke Murphey | |
27 | 2 | Luke Murphey | You can use multiple names too. In the example above, it makes sense to use "id" too. This can be done by setting the name attributes to "name,id", This would cause the following output with the example above: |
28 | 2 | Luke Murphey | |
29 | 2 | Luke Murphey | model=Focus submodel=ST make=Ford |
30 | 2 | Luke Murphey | |
31 | 2 | Luke Murphey | Now, the fields have names that distinguish what they are. |
32 | 2 | Luke Murphey | |
33 | 2 | Luke Murphey | Note that it uses the first match it finds. That means it will look for "name" first and then "id" when the setting is "name,id". |
34 | 3 | Luke Murphey | |
35 | 3 | Luke Murphey | h2. I changed the sourcetype and now the match field is no longer a multi-value field; what do I do? |
36 | 3 | Luke Murphey | |
37 | 3 | Luke Murphey | You can use rex to parse out the content into a field of your choice. In the example below, the matches are being parsed into a field called "file". |
38 | 3 | Luke Murphey | <pre> |
39 | 3 | Luke Murphey | sourcetype="downloads" | rex field=_raw "match=(?<file>[.a-zA-Z0-9_]+)" max_match=50 | mvexpand file |
40 | 3 | Luke Murphey | </pre> |