def nginx_access(line):
<EOL><INDENT>log = json.loads(line)<EOL>timestamp_iso = datetime.datetime.utcfromtimestamp(float(log['<STR_LIT>'])).isoformat()<EOL>log.update({'<STR_LIT>':timestamp_iso})<EOL>if '<STR_LIT:->' in log.get('<STR_LIT>'):<EOL><INDENT>log['<STR_LIT>'] = <NUM_LIT:0.0><EOL><DEDENT>log['<STR_LIT>'] = float(log['<STR_LIT>'])<EOL>log['<STR_LIT>'] = float(log['<STR_LIT>'])<EOL>log['<STR_LIT>'] = float(log['<STR_LIT>'])<EOL>return dict(<EOL>timestamp=log.get('<STR_LIT>','<STR_LIT:U+0020>'),<EOL>data=log,<EOL>type='<STR_LIT>',<EOL>event='<STR_LIT>',<EOL>)<EOL><DEDENT>
>>> import pprint
>>> input_line1 = '{ \
                "remote_addr": "127.0.0.1","remote_user": "-","timestamp": "1515144699.201", \
                "request": "GET / HTTP/1.1","status": "200","request_time": "0.000", \
                "body_bytes_sent": "396","http_referer": "-","http_user_agent": "python-requests/2.18.4", \
                "http_x_forwarded_for": "-","upstream_response_time": "-" \
                    }'
>>> output_line1 = nginx_access(input_line1)
>>> pprint.pprint(output_line1)
{'data': {u'body_bytes_sent': 396.0,
          u'http_referer': u'-',
          u'http_user_agent': u'python-requests/2.18.4',
          u'http_x_forwarded_for': u'-',
          u'remote_addr': u'127.0.0.1',
          u'remote_user': u'-',
          u'request': u'GET / HTTP/1.1',
          u'request_time': 0.0,
          u'status': u'200',
          u'timestamp': '2018-01-05T09:31:39.201000',
          u'upstream_response_time': 0.0},
 'event': 'nginx_event',
 'timestamp': '2018-01-05T09:31:39.201000',
 'type': 'metric'}

>>> input_line2 = '{ \
                "remote_addr": "192.158.0.51","remote_user": "-","timestamp": "1515143686.415", \
                "request": "POST /mpub?topic=heartbeat HTTP/1.1","status": "404","request_time": "0.000", \
                "body_bytes_sent": "152","http_referer": "-","http_user_agent": "python-requests/2.18.4", \
                "http_x_forwarded_for": "-","upstream_response_time": "-" \
                   }'
>>> output_line2 = nginx_access(input_line2)
>>> pprint.pprint(output_line2)
{'data': {u'body_bytes_sent': 152.0,
          u'http_referer': u'-',
          u'http_user_agent': u'python-requests/2.18.4',
          u'http_x_forwarded_for': u'-',
          u'remote_addr': u'192.158.0.51',
          u'remote_user': u'-',
          u'request': u'POST /mpub?topic=heartbeat HTTP/1.1',
          u'request_time': 0.0,
          u'status': u'404',
          u'timestamp': '2018-01-05T09:14:46.415000',
          u'upstream_response_time': 0.0},
 'event': 'nginx_event',
 'timestamp': '2018-01-05T09:14:46.415000',
 'type': 'metric'}