]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/cephadm: fix the loki address in grafana, promtail configuration files
authorjinhong.kim <jinhong.kim0@navercorp.com>
Fri, 24 Jun 2022 05:50:05 +0000 (14:50 +0900)
committerjinhong.kim <jinhong.kim0@navercorp.com>
Thu, 14 Jul 2022 07:29:05 +0000 (16:29 +0900)
- Fix to use loki address instead of MGR address(grafana datasource, promtail loki host)
- Add a loki dependency on grafana and promtail services

Signed-off-by: jinhong.kim <jinhong.kim0@navercorp.com>
src/pybind/mgr/cephadm/module.py
src/pybind/mgr/cephadm/services/monitoring.py
src/pybind/mgr/cephadm/templates/services/promtail.yml.j2
src/pybind/mgr/cephadm/tests/test_services.py

index d8cf7cee5c1744af0dc2dadd5a6ca6eb4b2dde5b..b9b3ad53dbec925fc8dad5eb1cb5a37e270de921 100644 (file)
@@ -2325,8 +2325,9 @@ Then run the following:
         else:
             need = {
                 'prometheus': ['mgr', 'alertmanager', 'node-exporter', 'ingress'],
-                'grafana': ['prometheus'],
+                'grafana': ['prometheus', 'loki'],
                 'alertmanager': ['mgr', 'alertmanager', 'snmp-gateway'],
+                'promtail': ['loki'],
             }
             for dep_type in need.get(daemon_type, []):
                 for dd in self.cache.get_daemons_by_type(dep_type):
index 246da8e39fd06179e3dedaa48355f7f12c6e5199..b66fdc87c6b8ece23e91955f37a14cd8bbc4116f 100644 (file)
@@ -39,10 +39,9 @@ class GrafanaService(CephadmService):
 
             deps.append(dd.name())
 
-        daemons = self.mgr.cache.get_daemons_by_service('mgr')
+        daemons = self.mgr.cache.get_daemons_by_service('loki')
         loki_host = ''
-        assert daemons is not None
-        if daemons != []:
+        if daemons:
             assert daemons[0].hostname is not None
             addr = daemons[0].ip if daemons[0].ip else self._inventory_get_fqdn(daemons[0].hostname)
             loki_host = build_url(scheme='http', host=addr, port=3100)
@@ -445,14 +444,14 @@ class PromtailService(CephadmService):
     def generate_config(self, daemon_spec: CephadmDaemonDeploySpec) -> Tuple[Dict[str, Any], List[str]]:
         assert self.TYPE == daemon_spec.daemon_type
         deps: List[str] = []
-        hostnames: List[str] = []
-        for dd in self.mgr.cache.get_daemons_by_service('mgr'):
-            assert dd.hostname is not None
-            addr = self.mgr.inventory.get_addr(dd.hostname)
-            hostnames.append(addr)
+        daemons = self.mgr.cache.get_daemons_by_service('loki')
+        loki_host = ''
+        if daemons:
+            assert daemons[0].hostname is not None
+            loki_host = daemons[0].ip or self._inventory_get_fqdn(daemons[0].hostname)
+
         context = {
-            'hostnames': hostnames,
-            'client_hostname': hostnames[0],
+            'client_hostname': loki_host,
         }
 
         yml = self.mgr.template.render('services/promtail.yml.j2', context)
index f500f5d22eef2d815d5012a138251aa8ae39f417..5ce7a3103522617b5037f0feb3882c3547f0ac67 100644 (file)
@@ -12,10 +12,6 @@ clients:
 scrape_configs:
 - job_name: system
   static_configs:
-  - targets:
-{% for url in hostnames %}
-    - {{ url }}
-{% endfor %}
-    labels:
+  - labels:
       job: Cluster Logs
-      __path__: /var/log/ceph/**/*.log
+      __path__: /var/log/ceph/**/*.log
\ No newline at end of file
index 69ee8a9944ee77349abd85065862ec64dc2d8b04..102d6e7cc8055a183a7fe262efc9b1f8c9237437 100644 (file)
@@ -498,14 +498,12 @@ class TestMonitoring:
                   filename: /tmp/positions.yaml
 
                 clients:
-                  - url: http://1::4:3100/loki/api/v1/push
+                  - url: http://:3100/loki/api/v1/push
 
                 scrape_configs:
                 - job_name: system
                   static_configs:
-                  - targets:
-                    - 1::4
-                    labels:
+                  - labels:
                       job: Cluster Logs
                       __path__: /var/log/ceph/**/*.log""").lstrip()
 
@@ -583,7 +581,7 @@ class TestMonitoring:
                             type: 'loki'
                             access: 'proxy'
                             orgId: 2
-                            url: 'http://[1::4]:3100'
+                            url: ''
                             basicAuth: false
                             isDefault: true
                             editable: false""").lstrip(),
@@ -651,7 +649,7 @@ class TestMonitoring:
                                     "    type: 'loki'\n"
                                     "    access: 'proxy'\n"
                                     '    orgId: 2\n'
-                                    "    url: 'http://[1::4]:3100'\n"
+                                    "    url: ''\n"
                                     '    basicAuth: false\n'
                                     '    isDefault: true\n'
                                     '    editable: false',