Skip to content

Commit

Permalink
DTIN-2346: Set monitor attribute when message_log_template is used (#…
Browse files Browse the repository at this point in the history
…1236)

* DTIN-2346: Set monitor attribute when message_log_template is used

* DTIN-2346: Update unit tests
  • Loading branch information
jmakar-s1 authored Jan 22, 2024
1 parent 9aed9f1 commit c065ef0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion scalyr_agent/builtin_monitors/syslog_monitor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017-2023 Scalyr Inc.
# Copyright 2017-2024 Scalyr Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -1768,6 +1768,7 @@ def __handle_syslog_logs(self, data, extra):
)

attribs = self.__syslog_attributes.copy()
attribs["monitor"] = "agentSyslog"
attribs.update(
{
k: v
Expand Down
22 changes: 22 additions & 0 deletions tests/unit/builtin_monitors/syslog_template_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ def test_no_params(self):
{
"path": "./syslog.log",
"attributes": {
"monitor": "agentSyslog",
"proto": "tcp",
"srcip": "127.0.0.1",
"destport": self.__class__.tcp_port,
Expand Down Expand Up @@ -321,6 +322,7 @@ def test_proto_destport_params_one_logconfig(self):
{
"path": "./syslog-tcp-%d.log" % self.__class__.tcp_port,
"attributes": {
"monitor": "agentSyslog",
"proto": "tcp",
"srcip": "127.0.0.1",
"destport": self.__class__.tcp_port,
Expand All @@ -335,6 +337,7 @@ def test_proto_destport_params_one_logconfig(self):
{
"path": "./syslog-udp-%d.log" % self.__class__.udp_port,
"attributes": {
"monitor": "agentSyslog",
"proto": "udp",
"srcip": "127.0.0.1",
"destport": self.__class__.udp_port,
Expand Down Expand Up @@ -388,6 +391,7 @@ def test_proto_destport_param_two_logconfigs(self):
{
"path": "./syslog-tcp-%d.log" % self.__class__.tcp_port,
"attributes": {
"monitor": "agentSyslog",
"proto": "tcp",
"srcip": "127.0.0.1",
"destport": self.__class__.tcp_port,
Expand All @@ -402,6 +406,7 @@ def test_proto_destport_param_two_logconfigs(self):
{
"path": "./syslog-tcp-%d.log" % (self.__class__.tcp_port + 1,),
"attributes": {
"monitor": "agentSyslog",
"proto": "tcp",
"srcip": "127.0.0.1",
"destport": self.__class__.tcp_port + 1,
Expand Down Expand Up @@ -443,6 +448,7 @@ def test_srcip_param(self):
{
"path": "./syslog-127.0.0.1.log",
"attributes": {
"monitor": "agentSyslog",
"proto": "tcp",
"srcip": "127.0.0.1",
"destport": self.__class__.tcp_port,
Expand All @@ -457,6 +463,7 @@ def test_srcip_param(self):
{
"path": "./syslog-127.0.1.1.log",
"attributes": {
"monitor": "agentSyslog",
"proto": "tcp",
"srcip": "127.0.0.2",
"destport": self.__class__.tcp_port,
Expand Down Expand Up @@ -493,6 +500,7 @@ def test_hostname_param_one_logconfig(self):
{
"path": "./syslog-alpha.log",
"attributes": {
"monitor": "agentSyslog",
"proto": "tcp",
"srcip": "127.0.0.1",
"destport": self.__class__.tcp_port,
Expand All @@ -507,6 +515,7 @@ def test_hostname_param_one_logconfig(self):
{
"path": "./syslog-bravo.log",
"attributes": {
"monitor": "agentSyslog",
"proto": "tcp",
"srcip": "127.0.0.1",
"destport": self.__class__.tcp_port,
Expand Down Expand Up @@ -551,6 +560,7 @@ def test_hostname_param_two_explicit_logconfigs(self):
{
"path": "./syslog-alpha.log",
"attributes": {
"monitor": "agentSyslog",
"proto": "tcp",
"srcip": "127.0.0.1",
"destport": self.__class__.tcp_port,
Expand All @@ -565,6 +575,7 @@ def test_hostname_param_two_explicit_logconfigs(self):
{
"path": "./syslog-bravo.log",
"attributes": {
"monitor": "agentSyslog",
"proto": "tcp",
"srcip": "127.0.0.1",
"destport": self.__class__.tcp_port,
Expand Down Expand Up @@ -605,6 +616,7 @@ def test_hostname_param_two_globbed_logconfigs(self):
{
"path": "./syslog-alpha.log",
"attributes": {
"monitor": "agentSyslog",
"proto": "tcp",
"srcip": "127.0.0.1",
"destport": self.__class__.tcp_port,
Expand All @@ -619,6 +631,7 @@ def test_hostname_param_two_globbed_logconfigs(self):
{
"path": "./syslog-bravo.log",
"attributes": {
"monitor": "agentSyslog",
"proto": "tcp",
"srcip": "127.0.0.1",
"destport": self.__class__.tcp_port,
Expand Down Expand Up @@ -661,6 +674,7 @@ def test_hostname_param_two_logconfigs_fallthrough(self):
{
"path": "./syslog-alpha.log",
"attributes": {
"monitor": "agentSyslog",
"proto": "tcp",
"srcip": "127.0.0.1",
"destport": self.__class__.tcp_port,
Expand All @@ -675,6 +689,7 @@ def test_hostname_param_two_logconfigs_fallthrough(self):
{
"path": "./syslog-bravo.log",
"attributes": {
"monitor": "agentSyslog",
"proto": "tcp",
"srcip": "127.0.0.1",
"destport": self.__class__.tcp_port,
Expand Down Expand Up @@ -715,6 +730,7 @@ def test_appname_param_one_logconfig(self):
{
"path": "./syslog-apiserver.log",
"attributes": {
"monitor": "agentSyslog",
"proto": "tcp",
"srcip": "127.0.0.1",
"destport": self.__class__.tcp_port,
Expand All @@ -729,6 +745,7 @@ def test_appname_param_one_logconfig(self):
{
"path": "./syslog-database.log",
"attributes": {
"monitor": "agentSyslog",
"proto": "tcp",
"srcip": "127.0.0.1",
"destport": self.__class__.tcp_port,
Expand Down Expand Up @@ -770,6 +787,7 @@ def test_multiple_attribs(self):
{
"path": "./syslog-app1.log",
"attributes": {
"monitor": "agentSyslog",
"proto": "tcp",
"srcip": "127.0.0.1",
"destport": self.__class__.tcp_port,
Expand All @@ -785,6 +803,7 @@ def test_multiple_attribs(self):
{
"path": "./syslog-app2.log",
"attributes": {
"monitor": "agentSyslog",
"proto": "tcp",
"srcip": "127.0.0.1",
"destport": self.__class__.tcp_port,
Expand Down Expand Up @@ -836,6 +855,7 @@ def test_multiple_attribs_two_logconfigs(self):
{
"path": "./syslog-app1.log",
"attributes": {
"monitor": "agentSyslog",
"proto": "tcp",
"srcip": "127.0.0.1",
"destport": self.__class__.tcp_port,
Expand All @@ -851,6 +871,7 @@ def test_multiple_attribs_two_logconfigs(self):
{
"path": "./syslog-app2.log",
"attributes": {
"monitor": "agentSyslog",
"proto": "tcp",
"srcip": "127.0.0.1",
"destport": self.__class__.tcp_port,
Expand Down Expand Up @@ -890,6 +911,7 @@ def test_max_log_files(self):
{
"path": "./syslog-app%d.log" % i,
"attributes": {
"monitor": "agentSyslog",
"proto": "tcp",
"srcip": "127.0.0.1",
"destport": self.__class__.tcp_port,
Expand Down

0 comments on commit c065ef0

Please sign in to comment.