File tree 5 files changed +15
-1
lines changed
5 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 98
98
- resolved_hostname: The resolved hostname of the instance, which respects the `reported_hostname` option.
99
99
- host: The provided host of the instance.
100
100
- port: The port number of the instance.
101
+ - azure_name: The resolved hostname of the instance, which respects the `reported_hostname` option,
102
+ but removes `.database.windows.net`
103
+ - database: The connection database.
101
104
- server_name: The resolved server name of the instance.
102
105
- instance_name: The resolved instance name of the instance.
103
106
In addition, you can use any key from the `tags` section of the configuration.
Original file line number Diff line number Diff line change
1
+ Add database and Azure name to SQL Server database identifier template variables
Original file line number Diff line number Diff line change 38
38
"managed_instance" : "azure_sql_server_managed_instance" ,
39
39
"virtual_machine" : "azure_virtual_machine_instance" ,
40
40
}
41
+ AZURE_SERVER_SUFFIX = ".database.windows.net"
42
+
41
43
42
44
# Metric discovery queries
43
45
COUNTER_TYPE_QUERY = """select distinct cntr_type
Original file line number Diff line number Diff line change @@ -100,6 +100,9 @@ instances:
100
100
## - resolved_hostname: The resolved hostname of the instance, which respects the `reported_hostname` option.
101
101
## - host: The provided host of the instance.
102
102
## - port: The port number of the instance.
103
+ ## - azure_name: The resolved hostname of the instance, which respects the `reported_hostname` option,
104
+ ## but removes `.database.windows.net`
105
+ ## - database: The connection database.
103
106
## - server_name: The resolved server name of the instance.
104
107
## - instance_name: The resolved instance name of the instance.
105
108
## In addition, you can use any key from the `tags` section of the configuration.
Original file line number Diff line number Diff line change 67
67
AUTODISCOVERY_QUERY ,
68
68
AWS_RDS_HOSTNAME_SUFFIX ,
69
69
AZURE_DEPLOYMENT_TYPE_TO_RESOURCE_TYPES ,
70
+ AZURE_SERVER_SUFFIX ,
70
71
BASE_NAME_QUERY ,
71
72
COUNTER_TYPE_QUERY ,
72
73
DATABASE_SERVICE_CHECK_NAME ,
@@ -330,7 +331,11 @@ def database_identifier(self):
330
331
tag_dict ['resolved_hostname' ] = self .resolved_hostname
331
332
tag_dict ['host' ] = str (self .host )
332
333
tag_dict ['port' ] = str (self .port )
333
- print (self .static_info_cache )
334
+ tag_dict ['database' ] = str (
335
+ self .instance .get ('database' , self .connection .DEFAULT_DATABASE if self .connection else None )
336
+ )
337
+ if self .resolved_hostname .endswith (AZURE_SERVER_SUFFIX ):
338
+ tag_dict ['azure_name' ] = self .resolved_hostname [: - len (AZURE_SERVER_SUFFIX )]
334
339
if self .static_info_cache .get (STATIC_INFO_SERVERNAME ) is not None :
335
340
tag_dict ['server_name' ] = self .static_info_cache .get (STATIC_INFO_SERVERNAME )
336
341
if self .static_info_cache .get (STATIC_INFO_INSTANCENAME ) is not None :
You can’t perform that action at this time.
0 commit comments