Commit 3f116631 authored by Jérome Perrin's avatar Jérome Perrin

software/grafana: fix loki and promtail listening on all IPs

Both loki and promtail were not configured properly and listening on all IPs.
This was partially because doc was wrong at the time, but also this was not
done properly.
parent 13818932
Pipeline #13951 failed with stage
in 0 seconds
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
[instance-profile] [instance-profile]
filename = instance.cfg.in filename = instance.cfg.in
md5sum = 12d9507c6dfb1ae9151a0bf7eb741060 md5sum = 3ccdd2299e759488545b62368c7a0b91
[influxdb-config-file] [influxdb-config-file]
filename = influxdb-config-file.cfg.in filename = influxdb-config-file.cfg.in
...@@ -35,8 +35,8 @@ md5sum = 3aa0f1ed752b2a59ea2b5e7c1733daf3 ...@@ -35,8 +35,8 @@ md5sum = 3aa0f1ed752b2a59ea2b5e7c1733daf3
[loki-config-file] [loki-config-file]
filename = loki-config-file.cfg.in filename = loki-config-file.cfg.in
md5sum = 02ba5acf23fcf88f5594919f46838533 md5sum = ad2baf4599a937d7352034a41fa24814
[promtail-config-file] [promtail-config-file]
filename = promtail-config-file.cfg.in filename = promtail-config-file.cfg.in
md5sum = c77788d0a3cc654ad9393eb4b1f31e94 md5sum = c8c9d815dd7b427788c066f041f04573
...@@ -219,6 +219,7 @@ storage-boltdb-dir = ${directory:loki-storage-boltdb-dir} ...@@ -219,6 +219,7 @@ storage-boltdb-dir = ${directory:loki-storage-boltdb-dir}
storage-filesystem-dir = ${directory:loki-storage-filesystem-dir} storage-filesystem-dir = ${directory:loki-storage-filesystem-dir}
ip = ${instance-parameter:ipv4-random} ip = ${instance-parameter:ipv4-random}
port = 3100 port = 3100
grpc-port = 9095
url = http://${:ip}:${:port} url = http://${:ip}:${:port}
...@@ -238,9 +239,10 @@ command-line = ...@@ -238,9 +239,10 @@ command-line =
wrapper-path = ${directory:service}/promtail wrapper-path = ${directory:service}/promtail
dir = ${directory:promtail-dir} dir = ${directory:promtail-dir}
http_port = 19080 http-port = 19080
grpc-port = 19095
ip = ${instance-parameter:ipv4-random} ip = ${instance-parameter:ipv4-random}
url = http://${:ip}:${:http_port} url = http://${:ip}:${:http-port}
[promtail-config-file] [promtail-config-file]
<= config-file <= config-file
...@@ -252,7 +254,7 @@ context = ...@@ -252,7 +254,7 @@ context =
[promtail-listen-promise] [promtail-listen-promise]
<= check-port-listening-promise <= check-port-listening-promise
hostname= ${promtail:ip} hostname= ${promtail:ip}
port = ${promtail:http_port} port = ${promtail:http-port}
......
auth_enabled: false auth_enabled: false
server: server:
http_listen_address: {{ loki['ip'] }}
http_listen_port: {{ loki['port'] }} http_listen_port: {{ loki['port'] }}
grpc_listen_address: {{ loki['ip'] }}
grpc_listen_port: {{ loki['grpc-port'] }}
ingester: ingester:
lifecycler: lifecycler:
......
# https://github.com/grafana/loki/blob/master/docs/logentry/processing-log-lines.md
server: server:
http_listen_port: {{ promtail['http_port'] }} http_listen_address: {{ promtail['ip'] }}
# XXX this external_url does not work ... promtail still listen on all IPs http_listen_port: {{ promtail['http-port'] }}
grpc_listen_address: {{ promtail['ip'] }}
grpc_listen_port: {{ promtail['grpc-port'] }}
external_url: {{ promtail['url'] }} external_url: {{ promtail['url'] }}
grpc_listen_port: 0
positions: positions:
filename: {{ promtail['dir'] }}/positions.yaml filename: {{ promtail['dir'] }}/positions.yaml
......
...@@ -25,12 +25,13 @@ ...@@ -25,12 +25,13 @@
# #
############################################################################## ##############################################################################
import os
import textwrap
import logging import logging
import os
import tempfile import tempfile
import textwrap
import time import time
import psutil
import requests import requests
from slapos.testing.testcase import makeModuleSetUpAndTestCaseClass from slapos.testing.testcase import makeModuleSetUpAndTestCaseClass
...@@ -251,3 +252,68 @@ class TestLoki(GrafanaTestCase): ...@@ -251,3 +252,68 @@ class TestLoki(GrafanaTestCase):
verify=False).json() verify=False).json()
self.assertIn('level', resp['values']) self.assertIn('level', resp['values'])
self.assertIn('name', resp['values']) self.assertIn('name', resp['values'])
class TestListenInPartition(GrafanaTestCase):
def setUp(self):
with self.slap.instance_supervisor_rpc as supervisor:
all_process_info = supervisor.getAllProcessInfo()
self.process_dict = {
p['name'].replace('-on-watch', ''): psutil.Process(p['pid'])
for p in all_process_info if p['name'] != 'watchdog'
}
def test_grafana_listen(self):
self.assertEqual(
[
c.laddr for c in self.process_dict['grafana'].connections()
if c.status == 'LISTEN'
],
[(self._ipv6_address, 8180)],
)
def test_influxdb_listen(self):
self.assertEqual(
sorted([
c.laddr for c in self.process_dict['influxdb'].connections()
if c.status == 'LISTEN'
]),
[
(self._ipv4_address, 8088),
(self._ipv6_address, 8086),
],
)
def test_telegraph_listen(self):
self.assertEqual(
[
c.laddr for c in self.process_dict['telegraf'].connections()
if c.status == 'LISTEN'
],
[],
)
def test_loki_listen(self):
self.assertEqual(
sorted([
c.laddr for c in self.process_dict['loki'].connections()
if c.status == 'LISTEN'
]),
[
(self._ipv4_address, 3100),
(self._ipv4_address, 9095),
],
)
def test_promtail_listen(self):
self.assertEqual(
sorted([
c.laddr for c in self.process_dict['promtail'].connections()
if c.status == 'LISTEN'
]),
[
(self._ipv4_address, 19080),
(self._ipv4_address, 19095),
],
)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment