Fix bug 1833: fix DATA_SOURCE_NAME in mysqld-exporter 01/11501/1
authorDavid Garcia <david.garcia@canonical.com>
Fri, 17 Dec 2021 07:30:59 +0000 (08:30 +0100)
committerDavid Garcia <david.garcia@canonical.com>
Fri, 17 Dec 2021 07:30:59 +0000 (08:30 +0100)
Change-Id: I6641aa68aaa920bbe14ca688b984c5591c0ff72d
Signed-off-by: David Garcia <david.garcia@canonical.com>
installers/charm/mysqld-exporter/src/charm.py

index 91be02a..46588b9 100755 (executable)
@@ -185,9 +185,9 @@ class MysqlExporterCharm(CharmedOsmBase):
         self._check_missing_dependencies(config)
 
         data_source = (
-            config.mysql_uri.replace("mysql://", "").split("/")[0]
+            f'{config.mysql_uri.replace("mysql://", "").replace("@", "@(").split("/")[0]})/'
             if config.mysql_uri
-            else f"root:{self.mysql_client.root_password}@{self.mysql_client.host}:{self.mysql_client.port}"
+            else f"root:{self.mysql_client.root_password}@({self.mysql_client.host}:{self.mysql_client.port})/"
         )
 
         # Create Builder for the PodSpec