cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Regular Expressions and Auto Tags

bill_scheuernst
DynaMight
DynaMight

I am working on an Auto Tag rule for custom devices using a regular expression statement which for the most part is successful.  I am seeing though where the tag key gets duplicated, with either no value, or a value which was to be excluded from the result.

Example #1 - 

{CustomDevice:Name/^([A-Za-z][A-Za-z][A-Za-z])}

Using CMHLEAF123.test.com as the entity name, the results are - 

bill_scheuernst_0-1758134463376.png

The rule correctly captures the three letter code used for the tag key, as seen in the "Site Code:CMH" tag, however I'm not exactly sure how the tag, "Site Code", with no value assigned, is applied.  I have no rule which suggests this.

Example #2 - 

{CustomDevice:Name/(?:Cisco network device) ([A-Za-z][A-Za-z][A-Za-z])}

Using Cisco network device CMHLEAF123.test.com as the entity name, the results are - 

Auto Tags_Regex_Ex2.png

In this example, the rule correctly captures the three letter code used for the tag value, as seen in the "Site Code:CMH" tag, however I'm not exactly sure how the tag, "Site Code:CIS" is created especially since I've specifically excluded the additional text in the regular expression statement.

The first example occurs not just for the Site Code tag, but for other tags as well, as seen with the "Host group" tag.

I am looking for suggestions from the community on this.  

  1. Is there a better way of doing this using RegEx?
  2. Is there a better way to exclude all of the text at the beginning, and still capture the three letters of a host name?
  3. What causes the duplicate tag key, either with no value or one which is explicitly excluded?
0 REPLIES 0

Featured Posts