@@ -53,14 +53,14 @@ def _ensure_connection(self):
5353 self .host ,
5454 self .port )
5555 client = MongoClient (url , serverSelectionTimeoutMS = self .SERVER_SELECTION_TIMEOUT )
56- self .log .info ('MongoDB_server_connection_established ' , host = self .host )
56+ self .log .info ('mongodb_server_connection_established ' , host = self .host )
5757 self .database = client [self .db_name ]
58- self .log .info ('MongoDB_database_created ' , db = self .db_name )
58+ self .log .info ('mongodb_database_created ' , db = self .db_name )
5959 self .collection = self .database [self .coll ]
60- self .log .info ('MongoDB_collection_created ' ,
60+ self .log .info ('mongodb_collection_created ' ,
6161 collection = self .collection , db = self .db_name )
6262
63- def _parse_msg_for_mongoDB (self , msgs ):
63+ def _parse_msg_for_mongodb (self , msgs ):
6464 msgs_list = []
6565 #TODO: We need to do this by using iteration object.
6666 for msg in msgs :
@@ -75,19 +75,19 @@ def _insert_1by1(self, records):
7575 try :
7676 self .collection .insert_one (r , ordered = False )
7777 except pymongo .errors .OperationFailure as opfail :
78- self .log .exception ('failed_to_insert_record_in_mongoDB ' ,
78+ self .log .exception ('failed_to_insert_record_in_mongodb ' ,
7979 record = msg , tb = opfail .details )
8080
8181 def handle_logs (self , msgs ):
82- msgs_list = self ._parse_msg_for_mongoDB (msgs )
82+ msgs_list = self ._parse_msg_for_mongodb (msgs )
8383 try :
8484 self .log .debug ('inserting_msgs_mongodb' )
8585 self .collection .insert_many ([msg for msg in msgs_list ], ordered = False )
8686 self .log .info ('logs_inserted_into_mongodb' , num_msgs = len (msgs ), type = 'metric' )
87- except pymongo .errors .AutoReconnect (message = 'connection_to_mongoDB_failed ' ):
87+ except pymongo .errors .AutoReconnect (message = 'connection_to_mongodb_failed ' ):
8888 self ._ensure_connection ()
8989 except pymongo .errors .BulkWriteError as bwe :
90- self .log .exception ('bulk_write_to_mongoDB_failed ' , tb = bwe .details )
90+ self .log .exception ('bulk_write_to_mongodb_failed ' , tb = bwe .details )
9191 self ._insert_1by1 (msgs_list )
9292
9393
@@ -98,9 +98,9 @@ def handle_logs(self, msgs):
9898from logagg .util import flatten_dict , is_number
9999
100100class InfluxDBForwarder (BaseForwarder ):
101- EXCLUDE_TAGS = ["raw" , "timestamp" , "type" , "event" ]
101+ EXCLUDE_TAGS = ["id" , " raw" , "timestamp" , "type" , "event" ]
102102
103- influxDB_records = []
103+ influxdb_records = []
104104
105105 def __init__ (self ,
106106 host , port ,
@@ -116,12 +116,12 @@ def __init__(self,
116116 self ._ensure_connection ()
117117
118118 def _ensure_connection (self ):
119- # Establish connection to influxdb to store metrics
119+ # Establish connection to influxDB to store metrics
120120 self .influxdb_client = InfluxDBClient (self .host , self .port , self .user ,
121121 self .passwd , self .db_name )
122- self .log .info ('InfluxDB_server_connection_established ' , host = self .host )
122+ self .log .info ('influxdb_server_connection_established ' , host = self .host )
123123 self .influxdb_database = self .influxdb_client .create_database (self .db_name )
124- self .log .info ('InfluxDB_database_created ' , dbname = self .db_name )
124+ self .log .info ('influxdb_database_created ' , dbname = self .db_name )
125125
126126 def _tag_and_field_maker (self ,event ):
127127 t = dict ()
@@ -134,7 +134,7 @@ def _tag_and_field_maker(self,event):
134134 t [key ] = event [key ]
135135 return t , f
136136
137- def parse_msg_for_influxDB (self , msgs ):
137+ def parse_msg_for_influxdb (self , msgs ):
138138 #TODO: We need to do this by using iteration object.
139139 series = []
140140 for msg in msgs :
@@ -161,19 +161,18 @@ def handle_logs(self, msgs):
161161 msgs_list .append (msg_body )
162162
163163 self .log .debug ('parsing_of_metrics_started' )
164- records = self .parse_msg_for_influxDB (msgs_list )
165- self .influxDB_records .extend (records )
164+ records = self .parse_msg_for_influxdb (msgs_list )
165+ self .influxdb_records .extend (records )
166166 self .log .debug ('parsing_of_metrics_completed' )
167167
168- self .influxDB_records = [record for record in self .influxDB_records if record ]
169168 try :
170169 self .log .debug ('inserting_the_metrics_into_influxdb' )
171- self .influxdb_client .write_points (self .influxDB_records )
170+ self .influxdb_client .write_points (self .influxdb_records )
172171 self .log .info ('metrics_inserted_into_influxdb' ,
173- length = len (self .influxDB_records ),
172+ length = len (self .influxdb_records ),
174173 type = 'metric' )
175- self .influxDB_records = []
174+ self .influxdb_records = []
176175 except (InfluxDBClientError , InfluxDBServerError ) as e :
177176 self .log .exception ('failed_to_insert metric' ,
178- record = self .influxDB_records ,
179- length = len (self .influxDB_records ))
177+ record = self .influxdb_records ,
178+ length = len (self .influxdb_records ))
0 commit comments