Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
http-request-component
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dasharatha.vamshi
http-request-component
Commits
87dda6dd
Commit
87dda6dd
authored
Feb 23, 2021
by
dasharatha.vamshi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
logstash
parent
cb28f6eb
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
10 deletions
+18
-10
conf/configuration.yml
conf/configuration.yml
+3
-0
requirements.txt
requirements.txt
+2
-1
scripts/common/config_parser.py
scripts/common/config_parser.py
+8
-8
scripts/common/logsetup.py
scripts/common/logsetup.py
+5
-1
No files found.
conf/configuration.yml
View file @
87dda6dd
...
...
@@ -2,3 +2,6 @@
SERVICE_CONFIG
:
LOG_LEVEL
:
info
LOG_HANDLER_NAME
:
HttpRequestComponent
LOGSTASH_HOST
:
192.168.1.47
LOGSTASH_PORT
:
5000
requirements.txt
View file @
87dda6dd
requests
pyyaml
python-logstash-async
\ No newline at end of file
scripts/common/config_parser.py
View file @
87dda6dd
...
...
@@ -22,14 +22,14 @@ if not os.path.exists(os.path.join(os.getcwd(), 'logs')):
LOG_LEVEL
=
os
.
environ
.
get
(
"LOG_LEVEL"
,
_config
.
get
(
'SERVICE_CONFIG'
,
{})
.
get
(
"LOG_LEVEL"
,
"INFO"
))
.
upper
()
LOG_HANDLER_NAME
=
_config
.
get
(
'SERVICE_CONFIG'
,
{})
.
get
(
"LOG_HANDLER_NAME"
,
"HttpRequestComponent"
)
# os.environ['shared_volume'] = 'test'
# os.environ['method'] = 'GET'
# os.environ[
# 'url'] = 'https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/aluva?unitGroup=metric&key=QMCRVJEPKK8YD7BP83BZTMZ7A'
# os.environ['
headers'] = '{}'
#
os.environ['payload'] = '{}'
#
os.environ['max_retries'] = '1'
# os.environ['authentication'] = '{"username":"vamshi","password":"sai"}'
ENABLE_LOGSTASH_LOG
=
os
.
environ
.
get
(
"ENABLE_LOGSTASH_LOG"
,
'False'
)
.
lower
()
LOGSTASH_HOST
=
_config
.
get
(
'SERVICE_CONFIG'
,
{})
.
get
(
'LOGSTASH_HOST'
)
LOGSTASH_PORT
=
str
(
_config
.
get
(
'SERVICE_CONFIG'
,
{})
.
get
(
'LOGSTASH_PORT'
))
# os.environ['
shared_volume'] = 'test' os.environ['method'] = 'GET' os.environ[ 'url'] =
#
'https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/aluva?unitGroup=metric&key
#
=QMCRVJEPKK8YD7BP83BZTMZ7A' os.environ['headers'] = '{"content-type":"application/json"}' os.environ['payload'] =
#
'{}' os.environ['max_retries'] = '1'
os.environ['authentication'] = '{"username":"vamshi","password":"sai"}'
config
=
{
"shared_volume"
:
os
.
environ
.
get
(
"shared_volume"
),
"method"
:
os
.
environ
.
get
(
"method"
),
...
...
scripts/common/logsetup.py
View file @
87dda6dd
import
os
import
logging
from
logging.handlers
import
RotatingFileHandler
from
logstash_async.handler
import
AsynchronousLogstashHandler
from
scripts.common.config_parser
import
LOG_LEVEL
,
LOG_HANDLER_NAME
,
BASE_LOG_PATH
from
scripts.common.config_parser
import
LOG_LEVEL
,
LOG_HANDLER_NAME
,
BASE_LOG_PATH
,
LOGSTASH_HOST
,
LOGSTASH_PORT
,
ENABLE_LOGSTASH_LOG
DEFAULT_FORMAT
=
'
%(asctime)
s
%(levelname)5
s
%(name)
s
%(message)
s'
DEBUG_FORMAT
=
'
%(asctime)
s
%(levelname)5
s
%(name)
s [
%(threadName)5
s:
%(filename)5
s:
%(funcName)5
s():
%(lineno)
s]
%
('
\
...
...
@@ -43,6 +44,9 @@ def get_logger(log_handler_name):
handler
.
setFormatter
(
formatter
)
_logger
.
addHandler
(
log_handler
)
_logger
.
addHandler
(
handler
)
if
ENABLE_LOGSTASH_LOG
==
'true'
and
LOGSTASH_PORT
is
not
None
and
LOGSTASH_HOST
is
not
None
and
LOGSTASH_PORT
.
isdigit
():
_logger
.
addHandler
(
AsynchronousLogstashHandler
(
LOGSTASH_HOST
,
int
(
LOGSTASH_PORT
),
database_path
=
None
))
return
_logger
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment