A regular expression (regex) is a sequence of characters that define a search pattern. CloudAdvisor uses regex patterns to match strings in the files contained in the monitored VMs in the CloudAdvisor inventory.
When creating regular expressions, keep the following in mind:
CloudAdvisor uses the Google RE2 open source regex engine. For the complete RE2 syntax, go to https://github.com/google/re2/wiki/Syntax. For your convenience, we have included a list of the basic regex operators in this guide, but you can use any operator supported by Google RE2. For more information, see Basic Regex Operators.
Note: | The Google RE2 open source regex engine supports Unicode character classes (among others). For examples that use Unicode character classes, see the CloudAdvisor predefined example tags. For brief descriptions of the available tags, see Predefined Tags. |
CloudAdvisor can use regex groups to delimit tags by specifying text that is not part of the tag match but which must exist before or after the tag match (for example, a whitespace character). If you look at the built-in tags, typically their regex consists of 3 groups. The first and last group specify the left and right delimiters (). The middle group is the capture group that actually matches the tag. If no groups are specified, CloudAdvisor treats the entire regex pattern as the capture group.
For example, \d{10}
is a regex without groups that will match a 10-digit number anywhere, even in the middle of a longer sequence of numbers. (?:\s)(\d{10})(?:\s)
contains three groups and will only match only a 10-digit number delimited by whitespace. For details, see Capture Groups.