summaryrefslogtreecommitdiff
path: root/smoketest/scripts/cli
diff options
context:
space:
mode:
authorViacheslav Hletenko <v.gletenko@vyos.io>2024-06-25 09:56:47 +0000
committerMergify <37929162+mergify[bot]@users.noreply.github.com>2024-06-28 12:48:28 +0000
commit362a810c001c94910230e8e19d483f94c724703a (patch)
treef78557aa332e3107ec4819679b23b090a0632491 /smoketest/scripts/cli
parent2c4e778cb460b66106e91d2cb68502da92e94c06 (diff)
downloadvyos-1x-362a810c001c94910230e8e19d483f94c724703a.tar.gz
vyos-1x-362a810c001c94910230e8e19d483f94c724703a.zip
T6477: Add telegraf loki output plugin
Add Loki plugin to telegraf set service monitoring telegraf loki url xxx (cherry picked from commit 3365eb7ab99fa9a259fe440eb51e82fc0a0a4dc6)
Diffstat (limited to 'smoketest/scripts/cli')
-rwxr-xr-xsmoketest/scripts/cli/test_service_monitoring_telegraf.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/smoketest/scripts/cli/test_service_monitoring_telegraf.py b/smoketest/scripts/cli/test_service_monitoring_telegraf.py
index 3374411f5..886b88683 100755
--- a/smoketest/scripts/cli/test_service_monitoring_telegraf.py
+++ b/smoketest/scripts/cli/test_service_monitoring_telegraf.py
@@ -17,6 +17,7 @@
import unittest
from base_vyostest_shim import VyOSUnitTestSHIM
+from vyos.configsession import ConfigSessionError
from vyos.utils.process import process_named_running
from vyos.utils.file import read_file
@@ -63,5 +64,33 @@ class TestMonitoringTelegraf(VyOSUnitTestSHIM.TestCase):
for input in inputs:
self.assertIn(input, config)
+ def test_02_loki(self):
+ label = 'r123'
+ loki_url = 'http://localhost'
+ port = '3100'
+ loki_username = 'VyOS'
+ loki_password = 'PassW0Rd_VyOS'
+
+ self.cli_set(base_path + ['loki', 'url', loki_url])
+ self.cli_set(base_path + ['loki', 'port', port])
+ self.cli_set(base_path + ['loki', 'metric-name-label', label])
+
+ self.cli_set(base_path + ['loki', 'authentication', 'username', loki_username])
+ # password not set
+ with self.assertRaises(ConfigSessionError):
+ self.cli_commit()
+ self.cli_set(base_path + ['loki', 'authentication', 'password', loki_password])
+
+ # commit changes
+ self.cli_commit()
+
+ config = read_file(TELEGRAF_CONF)
+ self.assertIn(f'[[outputs.loki]]', config)
+ self.assertIn(f'domain = "{loki_url}:{port}"', config)
+ self.assertIn(f'metric_name_label = "{label}"', config)
+ self.assertIn(f'username = "{loki_username}"', config)
+ self.assertIn(f'password = "{loki_password}"', config)
+
+
if __name__ == '__main__':
unittest.main(verbosity=2)