Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tango
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LOFAR2.0
tango
Commits
e0ff9295
Commit
e0ff9295
authored
2 years ago
by
Stefano Di Frischia
Browse files
Options
Downloads
Patches
Plain Diff
L2SS-970
: replace ELK with Loki in lofar_logging
parent
21d14b35
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!447
Resolve L2SS-970 "Add loki instance"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tangostationcontrol/tangostationcontrol/common/lofar_logging.py
+8
-8
8 additions, 8 deletions
...tationcontrol/tangostationcontrol/common/lofar_logging.py
with
8 additions
and
8 deletions
tangostationcontrol/tangostationcontrol/common/lofar_logging.py
+
8
−
8
View file @
e0ff9295
...
@@ -56,7 +56,7 @@ class LogSuppressErrorSpam(logging.Formatter):
...
@@ -56,7 +56,7 @@ class LogSuppressErrorSpam(logging.Formatter):
self
.
error_suppress_interval
=
error_suppress_interval
self
.
error_suppress_interval
=
error_suppress_interval
def
is_error_to_suppress
(
self
,
record
):
def
is_error_to_suppress
(
self
,
record
):
# Errors occuring by not being able to connect to the
ELK stack
, f.e. because it is down.
# Errors occuring by not being able to connect to the
log processing container
, f.e. because it is down.
return
record
.
name
==
"
LogProcessingWorker
"
and
record
.
msg
==
"
An error occurred while sending events: %s
"
return
record
.
name
==
"
LogProcessingWorker
"
and
record
.
msg
==
"
An error occurred while sending events: %s
"
def
filter
(
self
,
record
):
def
filter
(
self
,
record
):
...
@@ -105,7 +105,7 @@ class LogAnnotator(logging.Formatter):
...
@@ -105,7 +105,7 @@ class LogAnnotator(logging.Formatter):
def
configure_logger
(
logger
:
logging
.
Logger
=
None
,
log_extra
=
None
,
debug
=
False
):
def
configure_logger
(
logger
:
logging
.
Logger
=
None
,
log_extra
=
None
,
debug
=
False
):
"""
"""
Configure the given logger (or root if None) to:
Configure the given logger (or root if None) to:
- send logs to
the ELK
sta
ck
- send logs to
Loki through Log
sta
sh
- send logs to Tango
- send logs to Tango
- send logs to stdout
- send logs to stdout
"""
"""
...
@@ -128,7 +128,7 @@ def configure_logger(logger: logging.Logger=None, log_extra=None, debug=False):
...
@@ -128,7 +128,7 @@ def configure_logger(logger: logging.Logger=None, log_extra=None, debug=False):
# don't spam debug messages when fetching URLs
# don't spam debug messages when fetching URLs
logging
.
getLogger
(
"
urllib3
"
).
setLevel
(
logging
.
INFO
)
logging
.
getLogger
(
"
urllib3
"
).
setLevel
(
logging
.
INFO
)
# don't spam error messages when having
trouble connecting to ELK
# don't spam error messages when having
connection troubles
logging
.
getLogger
(
"
LogProcessingWorker
"
).
setLevel
(
logging
.
CRITICAL
)
logging
.
getLogger
(
"
LogProcessingWorker
"
).
setLevel
(
logging
.
CRITICAL
)
# for now, also log to stderr
# for now, also log to stderr
...
@@ -151,12 +151,12 @@ def configure_logger(logger: logging.Logger=None, log_extra=None, debug=False):
...
@@ -151,12 +151,12 @@ def configure_logger(logger: logging.Logger=None, log_extra=None, debug=False):
if
debug
:
if
debug
:
return
logger
return
logger
# Log to
ELK stack
# Log to
Logstash-Loki
try
:
try
:
from
logstash_async.handler
import
AsynchronousLogstashHandler
,
LogstashFormatter
from
logstash_async.handler
import
AsynchronousLogstashHandler
,
LogstashFormatter
# log to the tcp_input of logstash in our
ELK stack
# log to the tcp_input of logstash in our
logstash-loki container
handler
=
AsynchronousLogstashHandler
(
"
elk
"
,
5959
,
database_path
=
'
/tmp/lofar_pending_log_messages.db
'
)
handler
=
AsynchronousLogstashHandler
(
"
logstash-loki
"
,
5959
,
database_path
=
'
/tmp/lofar_pending_log_messages.db
'
)
# configure log messages
# configure log messages
formatter
=
LogstashFormatter
(
extra
=
log_extra
,
tags
=
[
"
python
"
,
"
lofar
"
])
formatter
=
LogstashFormatter
(
extra
=
log_extra
,
tags
=
[
"
python
"
,
"
lofar
"
])
...
@@ -167,9 +167,9 @@ def configure_logger(logger: logging.Logger=None, log_extra=None, debug=False):
...
@@ -167,9 +167,9 @@ def configure_logger(logger: logging.Logger=None, log_extra=None, debug=False):
# install the handler
# install the handler
logger
.
addHandler
(
handler
)
logger
.
addHandler
(
handler
)
except
ImportError
:
except
ImportError
:
logger
.
exception
(
"
Cannot forward logs to
ELK
: logstash_async module not found.
"
)
logger
.
exception
(
"
Cannot forward logs to
Logstash-Loki
: logstash_async module not found.
"
)
except
Exception
:
except
Exception
:
logger
.
exception
(
"
Cannot forward logs to
ELK
.
"
)
logger
.
exception
(
"
Cannot forward logs to
Logstash-Loki
.
"
)
# Don't log to Tango to reduce log spam
# Don't log to Tango to reduce log spam
"""
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment