@@ -41,7 +41,7 @@ class Settings(BaseSettings):
4141rooms_sid = {}
4242names_sid = {}
4343
44- ### elk, kibana
44+ ### elasticsearch
4545es = Elasticsearch (f'{ ES_IP } :{ ES_PORT } ' ) ## 변경
4646es .info ()
4747
@@ -82,11 +82,12 @@ def on_create_room(data):
8282
8383 emit ("join-request" )
8484
85- # elk
85+ # elasticsearch
8686 room_id = data ["roomName" ]
87+ user_nickname = data ["userNickname" ]
8788 date = datetime .datetime .now ()
8889 now = date .strftime ('%m/%d/%y %H:%M:%S' )
89- doc_create = {"des" : "create room" , "room_id" : room_id , "@timestamp" : utc_time ()}
90+ doc_create = {"des" : "create room" , "room_id" : room_id ,"user_nickname" : user_nickname , "@timestamp" : utc_time ()}
9091 es .index (index = index_name , doc_type = "log" , body = doc_create )
9192
9293@socketio .on ("join-room" )
@@ -112,10 +113,11 @@ def on_join_room(data):
112113 # broadcast to others in the room
113114 print ("[{}] New member joined: {}<{}>" .format (room_id , display_name , sid ))
114115
115- ### elk
116+ ### elasticsearch
116117 date = datetime .datetime .now ()
118+ user_nickname = data ["userNickname" ]
117119 now = date .strftime ('%m/%d/%y %H:%M:%S' )
118- doc_join = {"des" : "New member joined" , "room_id" : room_id , "sid" : sid , "@timestamp" : utc_time ()}
120+ doc_join = {"des" : "New member joined" , "room_id" : room_id , "sid" : sid ,"user_nickname" : user_nickname , "@timestamp" : utc_time ()}
119121 es .index (index = index_name , doc_type = "log" , body = doc_join )
120122 emit ("user-connect" , {"sid" : sid , "name" : display_name }, broadcast = True , include_self = False , room = room_id )
121123
@@ -167,10 +169,11 @@ def on_disconnect():
167169 room_id = rooms_sid [sid ]
168170 display_name = names_sid [sid ]
169171
170- ### elk
172+ ### efk
171173 now = datetime .datetime .now ()
174+ user_nickname = data ["userNickname" ]
172175 now = now .strftime ('%m/%d/%y %H:%M:%S' )
173- doc_disconnect = {"des" : "user-disconnect" , "room_id" : room_id , "sid" : sid , "@timestamp" : utc_time ()}
176+ doc_disconnect = {"des" : "user-disconnect" , "room_id" : room_id , "sid" : sid ,"user_nickname" : user_nickname , "@timestamp" : utc_time ()}
174177 es .index (index = index_name , doc_type = "log" , body = doc_disconnect )
175178
176179 print ("[{}] Member left: {}<{}>" .format (room_id , display_name , sid ))
@@ -216,16 +219,17 @@ def send_message(message):
216219 text = message ["text" ]
217220 room_id = message ["room_id" ]
218221
219- ### elk
222+ ### elasticsearch
220223
221224 # date = datetime.datetime.now()
222225 # now = date.strftime('%m/%d/%y %H:%M:%S')
223226 # doc_chatting= {"des" : "chatting", "room_id" : room_id, "chatting message" : text,"@timestamp": utc_time()}
224227 # es.index(index=index_name, doc_type="log", body=doc_chatting)
225228
229+ user_nickname = data ["userNickname" ]
226230 date = datetime .datetime .now ()
227231 now = date .strftime ('%m/%d/%y %H:%M:%S' )
228- doc_chatting = {"des" : "chatting" , "room_id" : room_id , "chatting message" : text , "@timestamp" : utc_time ()}
232+ doc_chatting = {"des" : "chatting" , "room_id" : room_id , "user_nickname" : user_nickname , " chatting message" : text , "@timestamp" : utc_time ()}
229233 es .index (index = index_name , doc_type = "log" , body = doc_chatting )
230234
231235 data = {
0 commit comments