@@ -41,7 +41,7 @@ class Settings(BaseSettings):
4141rooms_sid = {}
4242names_sid = {}
4343
44- ### elasticsearch
44+ ### elk, kibana
4545es = Elasticsearch (f'{ ES_IP } :{ ES_PORT } ' ) ## 변경
4646es .info ()
4747
@@ -82,12 +82,11 @@ def on_create_room(data):
8282
8383 emit ("join-request" )
8484
85- # elasticsearch
85+ # elk
8686 room_id = data ["roomName" ]
87- user_nickname = data ["userNickname" ]
8887 date = datetime .datetime .now ()
8988 now = date .strftime ('%m/%d/%y %H:%M:%S' )
90- doc_create = {"des" : "create room" , "room_id" : room_id ,"user_nickname" : user_nickname , "@timestamp" : utc_time ()}
89+ doc_create = {"des" : "create room" , "room_id" : room_id , "@timestamp" : utc_time ()}
9190 es .index (index = index_name , doc_type = "log" , body = doc_create )
9291
9392@socketio .on ("join-room" )
@@ -113,11 +112,10 @@ def on_join_room(data):
113112 # broadcast to others in the room
114113 print ("[{}] New member joined: {}<{}>" .format (room_id , display_name , sid ))
115114
116- ### elasticsearch
115+ ### elk
117116 date = datetime .datetime .now ()
118- user_nickname = data ["userNickname" ]
119117 now = date .strftime ('%m/%d/%y %H:%M:%S' )
120- doc_join = {"des" : "New member joined" , "room_id" : room_id , "sid" : sid ,"user_nickname" : user_nickname , "@timestamp" : utc_time ()}
118+ doc_join = {"des" : "New member joined" , "room_id" : room_id , "sid" : sid , "@timestamp" : utc_time ()}
121119 es .index (index = index_name , doc_type = "log" , body = doc_join )
122120 emit ("user-connect" , {"sid" : sid , "name" : display_name }, broadcast = True , include_self = False , room = room_id )
123121
@@ -169,11 +167,10 @@ def on_disconnect():
169167 room_id = rooms_sid [sid ]
170168 display_name = names_sid [sid ]
171169
172- ### efk
170+ ### elk
173171 now = datetime .datetime .now ()
174- user_nickname = data ["userNickname" ]
175172 now = now .strftime ('%m/%d/%y %H:%M:%S' )
176- doc_disconnect = {"des" : "user-disconnect" , "room_id" : room_id , "sid" : sid ,"user_nickname" : user_nickname , "@timestamp" : utc_time ()}
173+ doc_disconnect = {"des" : "user-disconnect" , "room_id" : room_id , "sid" : sid , "@timestamp" : utc_time ()}
177174 es .index (index = index_name , doc_type = "log" , body = doc_disconnect )
178175
179176 print ("[{}] Member left: {}<{}>" .format (room_id , display_name , sid ))
@@ -219,17 +216,16 @@ def send_message(message):
219216 text = message ["text" ]
220217 room_id = message ["room_id" ]
221218
222- ### elasticsearch
219+ ### elk
223220
224221 # date = datetime.datetime.now()
225222 # now = date.strftime('%m/%d/%y %H:%M:%S')
226223 # doc_chatting= {"des" : "chatting", "room_id" : room_id, "chatting message" : text,"@timestamp": utc_time()}
227224 # es.index(index=index_name, doc_type="log", body=doc_chatting)
228225
229- user_nickname = data ["userNickname" ]
230226 date = datetime .datetime .now ()
231227 now = date .strftime ('%m/%d/%y %H:%M:%S' )
232- doc_chatting = {"des" : "chatting" , "room_id" : room_id , "user_nickname" : user_nickname , " chatting message" : text , "@timestamp" : utc_time ()}
228+ doc_chatting = {"des" : "chatting" , "room_id" : room_id , "chatting message" : text , "@timestamp" : utc_time ()}
233229 es .index (index = index_name , doc_type = "log" , body = doc_chatting )
234230
235231 data = {
0 commit comments