-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
rfaircloth-splunk
committed
May 28, 2020
1 parent
789650b
commit 3132063
Showing
4 changed files
with
136 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| python { | ||
|
|
||
| """ | ||
| simple syslog-ng Python parser example | ||
| resolves IP to hostname | ||
| value pair names are hard-coded | ||
| """ | ||
| import re | ||
| import socket | ||
|
|
||
| class FixHostResolver(object): | ||
|
|
||
| def parse(self, log_message): | ||
| """ | ||
| Resolves IP to hostname | ||
| """ | ||
|
|
||
|
|
||
| # try to resolve the IP address | ||
| try: | ||
| ipaddr = log_message['HOST'].decode('utf-8') | ||
|
|
||
| resolved = socket.gethostbyaddr(ipaddr) | ||
| hostname = resolved[0] | ||
| log_message['HOST'] = hostname | ||
| except: | ||
| pass | ||
|
|
||
| # return True, other way message is dropped | ||
| return True | ||
|
|
||
| }; | ||
|
|
||
|
|
||
| parser p_fix_host_resolver { | ||
| python( | ||
| class("FixHostResolver") | ||
| ); | ||
| }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters