[Django] 03 - ELK (Elasticsearch + Logstash + Kibana)

ELK - [Elasticsearch + Logstash + Kibana]

 

 

docker-elk-tutorial

 

 

 

import logging
import logstash
import sys

host = 'localhost'

test_logger = logging.getLogger('python-logstash-logger')
test_logger.setLevel(logging.INFO)

# UDP # test_logger.addHandler(logstash.LogstashHandler(host, 12201, version=1)) # TCP test_logger.addHandler(logstash.TCPLogstashHandler(host, 5000, version=1))
test_logger.error(
'python-logstash: test logstash error message.') test_logger.info('python-logstash: test logstash info message.') test_logger.warning('python-logstash: test logstash warning message.') # add extra field to logstash message extra = { 'test_string': 'python version: ' + repr(sys.version_info), 'test_boolean': True, 'test_dict': {'a': 1, 'b': 'c'}, 'test_float': 1.23, 'test_integer': 123, 'test_list': [1, 2, '3'], } test_logger.info('python-logstash: test extra fields', extra=extra) print('done,please see kibana')

 

 

/* implement */

 

关于Kibana,可以考虑开专题。

https://juejin.cn/post/6844903765355544589

 

posted @ 2020-12-14 20:35  郝壹贰叁  阅读(406)  评论(0编辑  收藏  举报