Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnicodeEncodeError in DEBUG LOG #583

Closed
y-mori0110 opened this issue Jul 27, 2018 · 2 comments
Closed

UnicodeEncodeError in DEBUG LOG #583

y-mori0110 opened this issue Jul 27, 2018 · 2 comments
Labels
bug Something isn't working

Comments

@y-mori0110
Copy link
Contributor

y-mori0110 commented Jul 27, 2018

If I send a notification containing UTF-8 character string to the server, an error will occur.
This error occurs when the debug log is enabled.

  • alerta server 5.2.6
  • PostgreSQL 9.6
 --- Logging error ---
 Traceback (most recent call last):
   File "/usr/lib64/python3.5/logging/__init__.py", line 988, in emit
     stream.write(msg)
 UnicodeEncodeError: 'ascii' codec can't encode character '\\u5e74' in position 1710: ordinal not in range(128)
 Call stack:
   File "/usr/lib/python3.5/site-packages/flask/app.py", line 2309, in __call__
     return self.wsgi_app(environ, start_response)
   File "/usr/lib/python3.5/site-packages/flask/app.py", line 2292, in wsgi_app
     response = self.full_dispatch_request()
   File "/usr/lib/python3.5/site-packages/flask/app.py", line 1813, in full_dispatch_request
     rv = self.dispatch_request()
   File "/usr/lib/python3.5/site-packages/flask/app.py", line 1799, in dispatch_request
     return self.view_functions[rule.endpoint](**req.view_args)
   File "/usr/lib/python3.5/site-packages/flask_cors/decorator.py", line 128, in wrapped_function
     resp = make_response(f(*args, **kwargs))
   File "/usr/lib/python3.5/site-packages/alerta/auth/utils.py", line 123, in wrapped
     return f(*args, **kwargs)
   File "/usr/lib/python3.5/site-packages/alerta/models/metrics.py", line 259, in wrapped
     response = f(*args, **kwargs)
   File "/usr/lib/python3.5/site-packages/alerta/utils/api.py", line 32, in decorated
     return func(*args, **kwargs)
   File "/usr/lib/python3.5/site-packages/alerta/views/alerts.py", line 42, in receive
     alert = process_alert(incomingAlert)
   File "/usr/lib/python3.5/site-packages/alerta/utils/api.py", line 103, in process_alert
     updated = plugin.post_receive(alert)
   File "/usr/lib/python3.5/site-packages/alerta_amqp.py", line 52, in post_receive
     LOG.debug('Message: %s', body)
 Message: 'Message: %s'
 Arguments: {'createTime': '2018-07-26T06:39:04.653Z', 'duplicateCount': 2, 'type': 'zabbixAlert', 'repeat': True, 'severity': 'major', 'correlate': [], 'text': 'PROBLEM: log trigger zbx.log', 'history': [{'text': 'PROBLEM: log trigger zbx.log', 'type': 'severity', 'status': None, 'value': 'hogehoge', 'event': 'log[/tmp/zbx.log]', 'severity': 'major', 'updateTime': datetime.datetime(2018, 7, 26, 6, 39, 4, 653000), 'href': 'http://dhcp-175-92/alert/3013a7bb-1213-47fa-9135-8845908abd1a', 'id': '3013a7bb-1213-47fa-9135-8845908abd1a'}, {'text': 'new alert status change', 'type': 'status', 'status': 'open', 'value': None, 'event': 'log[/tmp/zbx.log]', 'severity': None, 'updateTime': datetime.datetime(2018, 7, 26, 6, 39, 4, 676000), 'href': 'http://dhcp-175-92/alert/3013a7bb-1213-47fa-9135-8845908abd1a', 'id': '3013a7bb-1213-47fa-9135-8845908abd1a'}, {'text': 'duplicate alert with value change', 'type': 'value', 'status': None, 'value': 'hogehoge1', 'event': 'log[/tmp/zbx.log]', 'severity': None, 'updateTime': datetime.datetime(2018, 7, 26, 6, 39, 54, 592000), 'href': 'http://dhcp-175-92/alert/5376a8d9-29ee-4313-9cab-cb6b9b5998c5', 'id': '5376a8d9-29ee-4313-9cab-cb6b9b5998c5'}, {'text': 'status change via console by Yoshiharu Mori (acknowledged in Zabbix)', 'type': 'action', 'status': 'ack', 'value': None, 'event': 'log[/tmp/zbx.log]', 'severity': 'major', 'updateTime': datetime.datetime(2018, 7, 26, 6, 44, 36, 456000), 'href': 'http://dhcp-175-92/alert/3013a7bb-1213-47fa-9135-8845908abd1a', 'id': '3013a7bb-1213-47fa-9135-8845908abd1a'}, {'text': 'duplicate alert with value change', 'type': 'value', 'status': None, 'value': '2018\xe5\xb9\xb4 7\xe6\x9c\x88 27\xe6\x97\xa5 \xe9\x87\x91\xe6\x9b\x9c\xe6\x97\xa5 16:48:49 JST hogehoge', 'event': 'log[/tmp/zbx.log]', 'severity': None, 'updateTime': datetime.datetime(2018, 7, 27, 7, 49, 10, 102000), 'href': 'http://dhcp-175-92/alert/8a5fdc71-90ab-4439-967a-ca34ede2bafb', 'id': '8a5fdc71-90ab-4439-967a-ca34ede2bafb'}], 'customer': None, 'status': 'ack', 'value': '2018\xe5\xb9\xb4 7\xe6\x9c\x88 27\xe6\x97\xa5 \xe9\x87\x91\xe6\x9b\x9c\xe6\x97\xa5 16:48:49 JST hogehoge', 'event': 'log[/tmp/zbx.log]', 'attributes': {'triggerID': '13563', 'eventId': '981', 'thresholdInfo': '*UNKNOWN*: {Zabbix server:log[/tmp/zbx.log].strlen()}>0', 'ip': '133.137.175.143'}, 'previousSeverity': 'indeterminate', 'timeout': 86400, 'resource': 'Zabbix server', 'lastReceiveId': '8a5fdc71-90ab-4439-967a-ca34ede2bafb', 'trendIndication': 'moreSevere', 'tags': ['{EVENT.TAGS}'], 'receiveTime': '2018-07-26T06:39:04.676Z', 'group': 'Zabbix', 'id': '3013a7bb-1213-47fa-9135-8845908abd1a', 'service': ['Zabbix servers'], 'href': 'http://dhcp-175-92/alert/3013a7bb-1213-47fa-9135-8845908abd1a', 'lastReceiveTime': '2018-07-27T07:49:10.102Z', 'environment': 'Zabbix 1st', 'rawData': None, 'origin': 'zabbix/dhcp-175-143'}
@satterly
Copy link
Member

Can you try this again using python 3.6 and let me know if you get the same error? Thanks.

@satterly satterly added the bug Something isn't working label Jul 27, 2018
@y-mori0110
Copy link
Contributor Author

y-mori0110 commented Jul 27, 2018

I update python to 3.6, but error was occured.

 --- Logging error ---
 Traceback (most recent call last):
   File "/usr/lib64/python3.6/logging/__init__.py", line 994, in emit
     stream.write(msg)
 UnicodeEncodeError: 'ascii' codec can't encode character '\\u5e74' in position 163: ordinal not in range(128)
 Call stack:
   File "/usr/lib/python3.6/site-packages/flask/app.py", line 2309, in __call__
     return self.wsgi_app(environ, start_response)
   File "/usr/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app
     response = self.full_dispatch_request()
   File "/usr/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request
     rv = self.dispatch_request()
   File "/usr/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request
     return self.view_functions[rule.endpoint](**req.view_args)
   File "/usr/lib/python3.6/site-packages/flask_cors/decorator.py", line 128, in wrapped_function
     resp = make_response(f(*args, **kwargs))
   File "/usr/lib/python3.6/site-packages/alerta/auth/utils.py", line 123, in wrapped
     return f(*args, **kwargs)
   File "/usr/lib/python3.6/site-packages/alerta/models/metrics.py", line 259, in wrapped
     response = f(*args, **kwargs)
   File "/usr/lib/python3.6/site-packages/alerta/utils/api.py", line 32, in decorated
    return func(*args, **kwargs)
   File "/usr/lib/python3.6/site-packages/alerta/views/alerts.py", line 42, in receive
     alert = process_alert(incomingAlert)
   File "/usr/lib/python3.6/site-packages/alerta/utils/api.py", line 90, in process_alert
     alert = alert.deduplicate()
   File "/usr/lib/python3.6/site-packages/alerta/models/alert.py", line 262, in deduplicate
     return Alert.from_db(db.dedup_alert(self, history))
   File "/usr/lib/python3.6/site-packages/alerta/database/backends/postgres/base.py", line 217, in dedup_alert
     return self._update(update, vars(alert), returning=True)
   File "/usr/lib/python3.6/site-packages/alerta/database/backends/postgres/base.py", line 941, in _update
    self._log(cursor, query, vars)
   File "/usr/lib/python3.6/site-packages/alerta/database/backends/postgres/base.py", line 964, in _log
    LOG.debug('{stars}\\n{query}\\n{stars}'.format(stars='*'*40, query=cursor.mogrify(query, vars).decode('utf-8')))
 Message: '****************************************
--cut--

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants