[cisco_ios] Improve hostname parsing #13816
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed commit message
Improves parsing of hostnames, to allow hostnames that begin with digits. This is not strictly allowed by the Cisco IOS specification, but it is commonly allowed on systems. So support for it should be added.
Due to the limitations of the grok parser's regex support, and the many possible formats of Cisco IOS logs, this required using a script to do some additional processing. With leading digits allowed in hostnames, they can appear to be sequence numbers, which can appear in the exact same location in the logs as hostname, and are also all digits. Forward look-ahead to check that there's any letter in the hostname pattern doesn't work to solve this, since the look-ahead cannot be contained to groups. Instead the script used to find this case, after grok.
Additionally there is another log format, when using year-first date stamps, the year can be mistaken sequence number. This also removes sequence number, if it appears that it was mistakenly taken from a timestamp.
Checklist
changelog.yml
file.