Created
March 5, 2015 11:54
-
-
Save adamwitko/337e36913717c13f4f5f to your computer and use it in GitHub Desktop.
Example Datadog iis test parser
This file contains hidden or 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
def test(): | |
import logging | |
from iis import parse_iis | |
logging.basicConfig(level=logging.DEBUG) | |
test_input="2015-03-05 08:39:06 ::1 GET / - 89 - ::1 Mozilla/5.0+(Windows+NT+6.3;+WOW64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/40.0.2214.115+Safari/537.36 - 403 14 0 7" | |
expected = ( | |
"iis.test", | |
1425544746.0, | |
1.0, | |
{ | |
'server.ip': '::1', | |
'server.port': '89', | |
'client.ip': '::1', | |
'client_to_server.method': 'GET', | |
'client_to_server.uri_stem': '/', | |
'client_to_server.uri_query': '-', | |
'client_to_server.username': '-', | |
'client_to_server.user_agent': 'Mozilla/5.0+(Windows+NT+6.3;+WOW64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/40.0.2214.115+Safari/537.36', | |
'client_to_server.referer': '-', | |
'server_to_client.status_code' : 403, | |
'server_to_client.sub_status_code': 14, | |
'server_to_client.win32_status_code': 0, | |
'time_taken': 7 | |
} | |
) | |
actual = parse_iis(logging, test_input) | |
assert expected == actual, "%s != %s" % (expected, actual) | |
print("Pass") | |
if __name__ == '__main__': | |
test() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment