@@ -31,7 +31,6 @@ def __init__(self, name, init_config, instances):
3131 script_path = self .instance .get ('script_path' )
3232 server_string = CONNECTION_STRING .format (host , port )
3333 self .tags = self .instance .get ('tags' , [])
34- self .parsed_data = {}
3534
3635 self .cmd = tibemsadmin_cmd + [
3736 '-server' ,
@@ -55,18 +54,20 @@ def check(self, _):
5554 sections = self ._section_output (cleaned_data )
5655
5756 # Parse the output
57+ parsed_data = {}
5858 for command , section in sections .items ():
5959 pattern = SHOW_METRIC_DATA [command ]['regex' ]
6060 if command == 'show server' :
61- self . parsed_data [command ] = self ._parse_show_server (section , pattern )
61+ parsed_data [command ] = self ._parse_show_server (section , pattern )
6262 else :
6363 try :
64- self . parsed_data [command ] = self ._parse_factory (section , pattern )
64+ parsed_data [command ] = self ._parse_factory (section , pattern )
6565 except Exception as e :
6666 self .log .error ('Error parsing command %s: %s' , command , e )
6767 continue
6868
69- for command , metric_info in self .parsed_data .items ():
69+ for command , metric_info in parsed_data .items ():
70+ self .log .debug ("Processing output from %s command" , command )
7071 metric_keys = SHOW_METRIC_DATA [command ]['metric_keys' ]
7172 tag_keys = SHOW_METRIC_DATA [command ]['tags' ]
7273 metric_prefix = SHOW_METRIC_DATA [command ]['metric_prefix' ]
@@ -205,11 +206,14 @@ def sanitize_name(name):
205206 return data
206207
207208 def _submit_metrics_factory (self , prefix , metric_data , metric_names , tag_keys ):
209+ self .log .debug ("Submitting %s metrics (%s tags) for %s" , len (metric_names ), len (tag_keys ), prefix )
208210 tags = []
209211 for key in tag_keys :
210212 if prefix == 'server' :
211213 # Add server tags to all metrics
212- self .tags .append (f"server_{ key } :{ metric_data [key ]} " )
214+ server_tag = f"server_{ key } :{ metric_data [key ]} "
215+ if server_tag not in self .tags :
216+ self .tags .append (server_tag )
213217 else :
214218 if metric_data .get (key ):
215219 tags .append (f"{ key } :{ metric_data [key ]} " )
0 commit comments