Filter /monitoring/status werkzeug logs

With healtchecks, they constitute 95% of our logs. Let's stop wasting
resources and shut them up.
This commit is contained in:
Guewen Baconnier
2019-07-12 16:25:51 +02:00
parent c8936964a8
commit eb0ced89fc
+16
View File
@@ -2,6 +2,7 @@
# Copyright 2016 Camptocamp SA # Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
import logging
import json import json
import werkzeug import werkzeug
@@ -10,6 +11,21 @@ from odoo import http
from odoo.addons.web.controllers.main import ensure_db from odoo.addons.web.controllers.main import ensure_db
class HealthCheckFilter(logging.Filter):
def __init__(self, path, name=''):
super().__init__(name)
self.path = path
def filter(self, record):
return self.path not in record.getMessage()
logging.getLogger('werkzeug').addFilter(
HealthCheckFilter('"GET /monitoring/status HTTP/1.1"')
)
class Monitoring(http.Controller): class Monitoring(http.Controller):
@http.route('/monitoring/status', type='http', auth='none') @http.route('/monitoring/status', type='http', auth='none')