diff options
author | Viacheslav Hletenko <v.gletenko@vyos.io> | 2024-06-25 09:56:47 +0000 |
---|---|---|
committer | Viacheslav Hletenko <v.gletenko@vyos.io> | 2024-06-28 10:35:05 +0000 |
commit | 3365eb7ab99fa9a259fe440eb51e82fc0a0a4dc6 (patch) | |
tree | f4c0d5e7f6e28b624eb563f73cbd8cf3d0030c09 /smoketest/scripts/cli | |
parent | 4f89e4b7a19a58d893e4e89a6e8491f239f1122e (diff) | |
download | vyos-1x-3365eb7ab99fa9a259fe440eb51e82fc0a0a4dc6.tar.gz vyos-1x-3365eb7ab99fa9a259fe440eb51e82fc0a0a4dc6.zip |
T6477: Add telegraf loki output plugin
Add Loki plugin to telegraf
set service monitoring telegraf loki url xxx
Diffstat (limited to 'smoketest/scripts/cli')
-rwxr-xr-x | smoketest/scripts/cli/test_service_monitoring_telegraf.py | 29 |
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) |