Repository: zalando-incubator/kubernetes-log-watcher

Issue:
Add node to Journald attributes
Cluster ``node`` will be useful in filtering

Discussion:
codecov-io: ## [Current coverage](https://codecov.io/gh/zalando-incubator/kubernetes-log-watcher/pull/26?src=pr) is 78.97% (diff: 88.23%)
> Merging [#26](https://codecov.io/gh/zalando-incubator/kubernetes-log-watcher/pull/26?src=pr) into [master](https://codecov.io/gh/zalando-incubator/kubernetes-log-watcher/branch/master?src=pr) will increase coverage by **0.11%**

```diff
@@             master        #26   diff @@
==========================================
  Files             9          9          
  Lines           369        371     +2   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits            291        293     +2   
  Misses           78         78          
  Partials          0          0          
```

> Powered by [Codecov](https://codecov.io?src=pr). Last update [e52f00a...1b46ec6](https://codecov.io/gh/zalando-incubator/kubernetes-log-watcher/compare/e52f00a0c5314d1f62ca00a89cd8e6c14bfc69e2...1b46ec69b46cb48ef85ab2935c096fda01d7085a?src=pr)
hjacobs: :+1: 
mohabusama: 👍 

Patch:
diff --git a/Dockerfile b/Dockerfile
index f9fcad5..f6a1131 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -10,4 +10,4 @@ RUN python setup.py install
 
 ADD scm-source.json /scm-source.json
 
-CMD ["k8s-log-watcher"]
+CMD ["kube-log-watcher"]
diff --git a/README.rst b/README.rst
index 229a3bc..83cdb17 100644
--- a/README.rst
+++ b/README.rst
@@ -1,14 +1,14 @@
 ===============
-K8S Log Watcher
+Kubernetes Log Watcher
 ===============
 
-.. image:: https://api.travis-ci.org/zalando-incubator/k8s-log-watcher.svg?branch=master
-  :target: https://travis-ci.org/zalando-incubator/k8s-log-watcher
+.. image:: https://api.travis-ci.org/zalando-incubator/kubernetes-log-watcher.svg?branch=master
+  :target: https://travis-ci.org/zalando-incubator/kubernetes-log-watcher
 
-.. image:: https://codecov.io/gh/zalando-incubator/k8s-log-watcher/branch/master/graph/badge.svg
-  :target: https://codecov.io/gh/zalando-incubator/k8s-log-watcher
+.. image:: https://codecov.io/gh/zalando-incubator/kubernetes-log-watcher/branch/master/graph/badge.svg
+  :target: https://codecov.io/gh/zalando-incubator/kubernetes-log-watcher
 
-Watch new containers on Kubernetes node, and create corresponding log configuration for log processor agent. K8S-log-watcher is intended to run in a Kubernetes DaemonSet along with log processor agent.
+Watch new containers on Kubernetes node, and create corresponding log configuration for log processor agent. ``kubernetes-log-watcher`` is intended to run in a Kubernetes DaemonSet along with log processor agent.
 
 Supported log agents:
 
diff --git a/k8s_log_watcher/agents/__init__.py b/k8s_log_watcher/agents/__init__.py
deleted file mode 100644
index 43b522a..0000000
--- a/k8s_log_watcher/agents/__init__.py
+++ /dev/null
@@ -1,11 +0,0 @@
-from k8s_log_watcher.agents.base import BaseWatcher
-
-from k8s_log_watcher.agents.appdynamics import AppDynamicsAgent
-from k8s_log_watcher.agents.scalyr import ScalyrAgent
-
-
-__all__ = (
-    AppDynamicsAgent,
-    BaseWatcher,
-    ScalyrAgent,
-)
diff --git a/k8s_log_watcher/__init__.py b/kube_log_watcher/__init__.py
similarity index 100%
rename from k8s_log_watcher/__init__.py
rename to kube_log_watcher/__init__.py
diff --git a/k8s_log_watcher/__main__.py b/kube_log_watcher/__main__.py
similarity index 50%
rename from k8s_log_watcher/__main__.py
rename to kube_log_watcher/__main__.py
index 817b838..d464acc 100644
--- a/k8s_log_watcher/__main__.py
+++ b/kube_log_watcher/__main__.py
@@ -1,4 +1,4 @@
-from k8s_log_watcher.main import main
+from kube_log_watcher.main import main
 
 
 if __name__ == '__main__':
diff --git a/kube_log_watcher/agents/__init__.py b/kube_log_watcher/agents/__init__.py
new file mode 100644
index 0000000..61cd8b3
--- /dev/null
+++ b/kube_log_watcher/agents/__init__.py
@@ -0,0 +1,11 @@
+from kube_log_watcher.agents.base import BaseWatcher
+
+from kube_log_watcher.agents.appdynamics import AppDynamicsAgent
+from kube_log_watcher.agents.scalyr import ScalyrAgent
+
+
+__all__ = (
+    AppDynamicsAgent,
+    BaseWatcher,
+    ScalyrAgent,
+)
diff --git a/k8s_log_watcher/agents/appdynamics.py b/kube_log_watcher/agents/appdynamics.py
similarity index 96%
rename from k8s_log_watcher/agents/appdynamics.py
rename to kube_log_watcher/agents/appdynamics.py
index fc76e8b..a3424be 100644
--- a/k8s_log_watcher/agents/appdynamics.py
+++ b/kube_log_watcher/agents/appdynamics.py
@@ -5,11 +5,11 @@ appdynamics controller.
 import os
 import logging
 
-from k8s_log_watcher.agents.base import BaseWatcher
+from kube_log_watcher.agents.base import BaseWatcher
 
 TPL_NAME = 'appdynamics.job.jinja2'
 
-logger = logging.getLogger('k8s_log_watcher')
+logger = logging.getLogger('kube_log_watcher')
 
 
 class AppDynamicsAgent(BaseWatcher):
diff --git a/k8s_log_watcher/agents/base.py b/kube_log_watcher/agents/base.py
similarity index 100%
rename from k8s_log_watcher/agents/base.py
rename to kube_log_watcher/agents/base.py
diff --git a/k8s_log_watcher/agents/scalyr.py b/kube_log_watcher/agents/scalyr.py
similarity index 95%
rename from k8s_log_watcher/agents/scalyr.py
rename to kube_log_watcher/agents/scalyr.py
index 88988f3..ad831fe 100644
--- a/k8s_log_watcher/agents/scalyr.py
+++ b/kube_log_watcher/agents/scalyr.py
@@ -6,14 +6,14 @@ import shutil
 import logging
 import json
 
-from k8s_log_watcher.agents.base import BaseWatcher
+from kube_log_watcher.agents.base import BaseWatcher
 
 
 TPL_NAME = 'scalyr.json.jinja2'
 
 SCALYR_CONFIG_PATH = '/etc/scalyr-agent-2/agent.json'
 
-logger = logging.getLogger('k8s_log_watcher')
+logger = logging.getLogger('kube_log_watcher')
 
 
 class ScalyrAgent(BaseWatcher):
@@ -86,6 +86,10 @@ class ScalyrAgent(BaseWatcher):
 
         self.logs.append(log)
 
+        # Set journald node attribute
+        if self.journald and 'node' not in self.journald['attributes']:
+            self.journald['attributes']['node'] = target['kwargs']['node_name']
+
     def remove_log_target(self, container_id: str):
         container_dir = os.path.join(self.dest_path, container_id)
 
diff --git a/k8s_log_watcher/kube.py b/kube_log_watcher/kube.py
similarity index 84%
rename from k8s_log_watcher/kube.py
rename to kube_log_watcher/kube.py
index 4ed8b0c..ac312ab 100644
--- a/k8s_log_watcher/kube.py
+++ b/kube_log_watcher/kube.py
@@ -16,7 +16,7 @@ PODS_URL = 'api/v1/namespaces/{}/pods'
 
 PAUSE_CONTAINER_PREFIX = 'gcr.io/google_containers/pause-'
 
-logger = logging.getLogger('k8s_log_watcher')
+logger = logging.getLogger('kube_log_watcher')
 
 
 def update_ca_certificate():
@@ -35,9 +35,10 @@ def get_client():
 
 def get_pods(kube_url=None, namespace=DEFAULT_NAMESPACE) -> list:
     """
-    Return list of pods in cluster. If ``kube_url`` is not ``None`` then K8S service account config won't be used.
+    Return list of pods in cluster.
+    If ``kube_url`` is not ``None`` then kubernetes service account config won't be used.
 
-    :param kube_url: URL of a proxy to K8S cluster api. This is useful to offload authentication/authorization
+    :param kube_url: URL of a proxy to kubernetes cluster api. This is useful to offload authentication/authorization
                      to proxy service instead of depending on serviceaccount config. Default is ``None``.
     :type kube_url: str
 
@@ -69,7 +70,7 @@ def get_pod_labels(pods: list, pod_name: str) -> dict:
 
 def is_pause_container(config: dict) -> bool:
     """
-    Return True if the config belongs to K8S *Pause* containers.
+    Return True if the config belongs to kubernetes *Pause* containers.
 
     :param config: Container "Config" from ``config.v2.json``.
     :type config: dict
diff --git a/k8s_log_watcher/main.py b/kube_log_watcher/main.py
similarity index 96%
rename from k8s_log_watcher/main.py
rename to kube_log_watcher/main.py
index 7599299..0e533cd 100644
--- a/k8s_log_watcher/main.py
+++ b/kube_log_watcher/main.py
@@ -5,10 +5,10 @@ import sys
 import logging
 import json
 
-import k8s_log_watcher.kube as kube
-from k8s_log_watcher.template_loader import load_template
+import kube_log_watcher.kube as kube
+from kube_log_watcher.template_loader import load_template
 
-from k8s_log_watcher.agents import ScalyrAgent, AppDynamicsAgent
+from kube_log_watcher.agents import ScalyrAgent, AppDynamicsAgent
 
 
 CONTAINERS_PATH = '/mnt/containers/'
@@ -22,12 +22,12 @@ BUILTIN_AGENTS = {
     'scalyr': ScalyrAgent,
 }
 
-logger = logging.getLogger('k8s_log_watcher')
+logger = logging.getLogger('kube_log_watcher')
 logger.addHandler(logging.StreamHandler(stream=sys.stdout))
 logger.setLevel(logging.INFO)
 
 
-# Set via K8S downward API.
+# Set via kubernetes downward API.
 CLUSTER_NODE_NAME = os.environ.get('CLUSTER_NODE_NAME')
 
 
@@ -162,7 +162,7 @@ def get_new_containers_log_targets(containers: list, containers_path: str, clust
     :param containers_path: Path to mounted containers directory.
     :type containers_path: str
 
-    :param cluster_id: K8S cluster ID. If not set, then it will not be added to job/config files.
+    :param cluster_id: kubernetes cluster ID. If not set, then it will not be added to job/config files.
     :type cluster_id: str
 
     :param kube_url: URL to Kube API proxy.
@@ -266,7 +266,7 @@ def watch(containers_path, agents_list, cluster_id, interval=60, kube_url=None):
 
 
 def main():
-    argp = argparse.ArgumentParser(description='K8S containers log watcher.')
+    argp = argparse.ArgumentParser(description='kubernetes containers log watcher.')
     argp.add_argument('-c', '--containers-path', dest='containers_path', default=CONTAINERS_PATH,
                       help='Containers directory path mounted from the host. Can be set via WATCHER_CONTAINERS_PATH '
                       'env variable.')
diff --git a/k8s_log_watcher/template_loader.py b/kube_log_watcher/template_loader.py
similarity index 100%
rename from k8s_log_watcher/template_loader.py
rename to kube_log_watcher/template_loader.py
diff --git a/k8s_log_watcher/templates/appdynamics.job.jinja2 b/kube_log_watcher/templates/appdynamics.job.jinja2
similarity index 100%
rename from k8s_log_watcher/templates/appdynamics.job.jinja2
rename to kube_log_watcher/templates/appdynamics.job.jinja2
diff --git a/k8s_log_watcher/templates/scalyr.json.jinja2 b/kube_log_watcher/templates/scalyr.json.jinja2
similarity index 100%
rename from k8s_log_watcher/templates/scalyr.json.jinja2
rename to kube_log_watcher/templates/scalyr.json.jinja2
diff --git a/setup.py b/setup.py
index f742751..522d6c9 100644
--- a/setup.py
+++ b/setup.py
@@ -2,7 +2,7 @@
 # -*- coding: utf-8 -*-
 
 """
-Setup file for K8S log watcher.
+Setup file for kubernetes log watcher.
 """
 import os
 
@@ -21,15 +21,15 @@ def get_requirements(path):
     return [req for req in content.split('\\n') if req != '']
 
 
-MAIN_PACKAGE = 'k8s_log_watcher'
+MAIN_PACKAGE = 'kube_log_watcher'
 VERSION = read_version(MAIN_PACKAGE)
-DESCRIPTION = 'K8S log watcher'
+DESCRIPTION = 'Kubernetes log watcher'
 
-CONSOLE_SCRIPTS = ['k8s-log-watcher=k8s_log_watcher.main:main']
+CONSOLE_SCRIPTS = ['kube-log-watcher=kube_log_watcher.main:main']
 
 
 setup(
-    name='k8s-log-watcher',
+    name='kubernetes-log-watcher',
     version=VERSION,
     description=DESCRIPTION,
     long_description=open('README.rst').read(),
diff --git a/tox.ini b/tox.ini
index 31b1e79..a56560e 100644
--- a/tox.ini
+++ b/tox.ini
@@ -5,7 +5,7 @@ max-line-length = 120
 envlist = py35
 
 [pytest]
-addopts = -v -s --cov k8s_log_watcher
+addopts = -v -s --cov kube_log_watcher
 
 [testenv]
 passenv = TOXENV CI TRAVIS TRAVIS_*


Test patch:
diff --git a/tests/conftest.py b/tests/conftest.py
index eece8d4..ce05388 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -3,6 +3,7 @@ import os
 import pytest
 
 CLUSTER_ID = 'kube-cluster'
+NODE = 'node-1'
 
 APPDYNAMICS_DEST_PATH = '/var/log/watcher/'
 
@@ -20,7 +21,7 @@ TARGET = {
         'pod_name': 'pod-1',
         'namespace': 'default',
         'container_name': 'app-1-container-1',
-        'node_name': 'node-1',
+        'node_name': NODE,
         'log_file_path': '/mn/containers/container-1/container-1-json.log',
         'container_id': 'container-1',
         'container_path': '/mnt/containers/container-1',
@@ -107,7 +108,7 @@ TARGET = {
                 'pod_labels': {'application': 'app-1', 'version': 'v1', 'release': '123'},
                 'id': 'cont-1',
                 'kwargs': {
-                    'pod_name': 'pod-1', 'release': '123', 'namespace': 'default', 'node_name': 'node-1',
+                    'pod_name': 'pod-1', 'release': '123', 'namespace': 'default', 'node_name': NODE,
                     'container_id': 'cont-1', 'cluster_id': 'kube-cluster', 'log_file_name': 'cont-1-json.log',
                     'application_id': 'app-1', 'application_version': 'v1', 'container_path': '/mnt/containers/cont-1',
                     'log_file_path': '/mnt/containers/cont-1/cont-1-json.log', 'container_name': 'cont-1'
@@ -117,7 +118,7 @@ TARGET = {
                 'pod_labels': {'application': 'app-2', 'version': 'v1'},
                 'id': 'cont-5',
                 'kwargs': {
-                    'pod_name': 'pod-4', 'release': '', 'namespace': 'kube', 'node_name': 'node-1',
+                    'pod_name': 'pod-4', 'release': '', 'namespace': 'kube', 'node_name': NODE,
                     'container_id': 'cont-5', 'cluster_id': 'kube-cluster', 'log_file_name': 'cont-5-json.log',
                     'application_id': 'app-2', 'application_version': 'v1', 'container_path': '/mnt/containers/cont-5',
                     'log_file_path': '/mnt/containers/cont-5/cont-5-json.log', 'container_name': 'cont-5'
@@ -150,7 +151,7 @@ def fx_containers_sync(request):
                         'pod': 'pod-1',
                         'namespace': 'default',
                         'container': 'app-1-container-1',
-                        'node': 'node-1',
+                        'node': NODE,
                     }
                 }
             ]
@@ -172,7 +173,7 @@ def fx_scalyr(request):
             'pod_name': 'pod-1',
             'namespace': 'default',
             'container_name': 'app-1-container-1',
-            'node_name': 'node-1',
+            'node_name': NODE,
             'log_file_path': '/mn/containers/container-1/container-1-json.log',
             'container_id': 'container-1',
             'container_path': '/mnt/containers/container-1',
diff --git a/tests/test_appdynamics.py b/tests/test_appdynamics.py
index f4fe1d3..5c03ff0 100644
--- a/tests/test_appdynamics.py
+++ b/tests/test_appdynamics.py
@@ -4,8 +4,8 @@ import pytest
 
 from mock import MagicMock
 
-from k8s_log_watcher.template_loader import load_template
-from k8s_log_watcher.agents.appdynamics import AppDynamicsAgent
+from kube_log_watcher.template_loader import load_template
+from kube_log_watcher.agents.appdynamics import AppDynamicsAgent
 
 from .conftest import CLUSTER_ID, APPDYNAMICS_DEST_PATH
 
diff --git a/tests/test_base.py b/tests/test_base.py
index 2128fb0..39f65ba 100644
--- a/tests/test_base.py
+++ b/tests/test_base.py
@@ -2,10 +2,10 @@ import pytest
 
 from mock import MagicMock
 
-from k8s_log_watcher.template_loader import load_template
-from k8s_log_watcher.main import BUILTIN_AGENTS
+from kube_log_watcher.template_loader import load_template
+from kube_log_watcher.main import BUILTIN_AGENTS
 
-from k8s_log_watcher.agents import BaseWatcher
+from kube_log_watcher.agents import BaseWatcher
 
 from .conftest import CLUSTER_ID
 
diff --git a/tests/test_kube.py b/tests/test_kube.py
index aa8ed02..1f87816 100644
--- a/tests/test_kube.py
+++ b/tests/test_kube.py
@@ -2,8 +2,8 @@ import pytest
 
 from mock import MagicMock
 
-from k8s_log_watcher.kube import get_pods, is_pause_container, get_pod_labels
-from k8s_log_watcher.kube import PAUSE_CONTAINER_PREFIX
+from kube_log_watcher.kube import get_pods, is_pause_container, get_pod_labels
+from kube_log_watcher.kube import PAUSE_CONTAINER_PREFIX
 
 
 KUBE_URL = 'https://my-kube-api'
diff --git a/tests/test_main.py b/tests/test_main.py
index 286b6b6..2627fd7 100644
--- a/tests/test_main.py
+++ b/tests/test_main.py
@@ -4,8 +4,8 @@ import pytest
 
 from mock import MagicMock, call
 
-from k8s_log_watcher.template_loader import load_template
-from k8s_log_watcher.main import (
+from kube_log_watcher.template_loader import load_template
+from kube_log_watcher.main import (
     get_label_value, get_containers, sync_containers_log_agents, get_stale_containers, load_agents,
     get_new_containers_log_targets)
 
@@ -108,8 +108,8 @@ def test_sync_containers_log_agents(monkeypatch, watched_containers, fx_containe
     get_pods = MagicMock()
     get_pods.return_value = pods
 
-    monkeypatch.setattr('k8s_log_watcher.kube.get_pods', get_pods)
-    monkeypatch.setattr('k8s_log_watcher.main.CLUSTER_NODE_NAME', 'node-1')
+    monkeypatch.setattr('kube_log_watcher.kube.get_pods', get_pods)
+    monkeypatch.setattr('kube_log_watcher.main.CLUSTER_NODE_NAME', 'node-1')
 
     stale_containers = watched_containers - result
     if watched_containers:
@@ -120,8 +120,8 @@ def test_sync_containers_log_agents(monkeypatch, watched_containers, fx_containe
     get_targets.return_value = targets
     get_stale = MagicMock()
     get_stale.return_value = stale_containers
-    monkeypatch.setattr('k8s_log_watcher.main.get_new_containers_log_targets', get_targets)
-    monkeypatch.setattr('k8s_log_watcher.main.get_stale_containers', get_stale)
+    monkeypatch.setattr('kube_log_watcher.main.get_new_containers_log_targets', get_targets)
+    monkeypatch.setattr('kube_log_watcher.main.get_stale_containers', get_stale)
 
     agent1 = MagicMock()
     agent2 = MagicMock()
@@ -149,8 +149,8 @@ def test_get_new_containers_log_targets(monkeypatch, fx_containers_sync):
     get_pods = MagicMock()
     get_pods.return_value = pods
 
-    monkeypatch.setattr('k8s_log_watcher.kube.get_pods', get_pods)
-    monkeypatch.setattr('k8s_log_watcher.main.CLUSTER_NODE_NAME', 'node-1')
+    monkeypatch.setattr('kube_log_watcher.kube.get_pods', get_pods)
+    monkeypatch.setattr('kube_log_watcher.main.CLUSTER_NODE_NAME', 'node-1')
 
     targets = get_new_containers_log_targets(containers, CONTAINERS_PATH, CLUSTER_ID)
 
@@ -177,7 +177,7 @@ def test_load_agents(monkeypatch):
         'agent1': agent1,
         'agent2': agent2,
     }
-    monkeypatch.setattr('k8s_log_watcher.main.BUILTIN_AGENTS', builtins)
+    monkeypatch.setattr('kube_log_watcher.main.BUILTIN_AGENTS', builtins)
 
     load_agents(['agent1', 'agent2'], CLUSTER_ID)
 
diff --git a/tests/test_scalyr.py b/tests/test_scalyr.py
index 633fde8..1af390c 100644
--- a/tests/test_scalyr.py
+++ b/tests/test_scalyr.py
@@ -1,17 +1,17 @@
 import os
 import json
+import copy
 
 import pytest
 
 from mock import MagicMock
 
-from k8s_log_watcher.template_loader import load_template
-from k8s_log_watcher.agents.scalyr import ScalyrAgent, SCALYR_CONFIG_PATH, TPL_NAME
+from kube_log_watcher.template_loader import load_template
+from kube_log_watcher.agents.scalyr import ScalyrAgent, SCALYR_CONFIG_PATH, TPL_NAME
 
-from .conftest import CLUSTER_ID
+from .conftest import CLUSTER_ID, NODE
 from .conftest import SCALYR_KEY, SCALYR_DEST_PATH, SCALYR_JOURNALD_DEFAULTS
 
-
 ENVS = (
     {
         'WATCHER_SCALYR_API_KEY': SCALYR_KEY, 'WATCHER_SCALYR_DEST_PATH': SCALYR_DEST_PATH,
@@ -29,6 +29,10 @@ ENVS = (
 KWARGS_KEYS = ('scalyr_key', 'cluster_id', 'logs', 'monitor_journald')
 
 
+SCALYR_MONITOR_JOURNALD = copy.deepcopy(SCALYR_JOURNALD_DEFAULTS)
+SCALYR_MONITOR_JOURNALD['attributes']['node'] = NODE
+
+
 def assert_fx_sanity(kwargs):
     assert set(KWARGS_KEYS) == set(kwargs.keys())
 
@@ -87,7 +91,7 @@ def test_add_log_target(monkeypatch, env, fx_scalyr):
     assert_fx_sanity(kwargs)
 
     # adjust kwargs
-    kwargs['monitor_journald'] = {} if not env.get('WATCHER_SCALYR_JOURNALD') else SCALYR_JOURNALD_DEFAULTS
+    kwargs['monitor_journald'] = {} if not env.get('WATCHER_SCALYR_JOURNALD') else SCALYR_MONITOR_JOURNALD
 
     exists = MagicMock()
     exists.side_effect = (True, True, False, False)
@@ -100,7 +104,6 @@ def test_add_log_target(monkeypatch, env, fx_scalyr):
     monkeypatch.setattr(ScalyrAgent, '_get_current_log_paths', current_targets)
 
     agent = ScalyrAgent(CLUSTER_ID, load_template)
-
     assert_agent(agent, env)
 
     mock_open, mock_fp = patch_open(monkeypatch)
@@ -149,7 +152,7 @@ def test_add_log_target_no_change(monkeypatch, env, fx_scalyr):
     assert_fx_sanity(kwargs)
 
     # adjust kwargs
-    kwargs['monitor_journald'] = {} if not env.get('WATCHER_SCALYR_JOURNALD') else SCALYR_JOURNALD_DEFAULTS
+    kwargs['monitor_journald'] = {} if not env.get('WATCHER_SCALYR_JOURNALD') else SCALYR_MONITOR_JOURNALD
 
     exists = MagicMock()
     exists.side_effect = (True, True, False, False)
@@ -194,7 +197,7 @@ def test_flush_failure(monkeypatch, env, fx_scalyr):
     assert_fx_sanity(kwargs)
 
     # adjust kwargs
-    kwargs['monitor_journald'] = {} if not env.get('WATCHER_SCALYR_JOURNALD') else SCALYR_JOURNALD_DEFAULTS
+    kwargs['monitor_journald'] = {} if not env.get('WATCHER_SCALYR_JOURNALD') else SCALYR_MONITOR_JOURNALD
 
     exists = MagicMock()
     exists.side_effect = (True, True, False, False)
@@ -302,7 +305,7 @@ def test_remove_log_target(monkeypatch, env, exc):
     'kwargs,expected',
     (
         (
-            {'scalyr_key': SCALYR_KEY, 'cluster_id': CLUSTER_ID, 'monitor_journald': 0, 'logs': []},
+            {'scalyr_key': SCALYR_KEY, 'cluster_id': CLUSTER_ID, 'monitor_journald': None, 'logs': []},
             {
                 'api_key': 'scalyr-key-123',
                 'implicit_metric_monitor': False,
@@ -335,7 +338,7 @@ def test_remove_log_target(monkeypatch, env, exc):
                 'logs': [{'path': '/p1', 'attributes': {'a1': 'v1'}}],
                 'monitor_journald': {
                     'journal_path': '/var/log/journal',
-                    'attributes': {'cluster': CLUSTER_ID},
+                    'attributes': {'cluster': CLUSTER_ID, 'node': NODE},
                     'extra_fields': {'_COMM': 'command'}
                 },
             },
@@ -349,7 +352,7 @@ def test_remove_log_target(monkeypatch, env, exc):
                     {
                         'module': 'scalyr_agent.builtin_monitors.journald_monitor',
                         'journal_path': '/var/log/journal',
-                        'attributes': {'cluster': CLUSTER_ID},
+                        'attributes': {'cluster': CLUSTER_ID, 'node': NODE},
                         'extra_fields': {'_COMM': 'command'}
                     }
                 ]