# How show a log flow from journald on UI Dashboard

**URL:** <https://discourse.nodered.org/t/how-show-a-log-flow-from-journald-on-ui-dashboard/71885>\
**Category:** Dashboard\
**Tags:** node-red-dashboard\
**Created:** [8 December 2022 16:30 UTC](https://discourse.nodered.org/t/how-show-a-log-flow-from-journald-on-ui-dashboard/71885 "2022-12-08T16:30:08Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mannshoch](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mannshoch/32/19477_2.png) [@Mannshoch](https://discourse.nodered.org/u/Mannshoch)\
**Post date:** [8 December 2022 16:30 UTC](https://discourse.nodered.org/t/how-show-a-log-flow-from-journald-on-ui-dashboard/71885/1 "2022-12-08T16:30:08Z")

</div>

I try to get data from journalctl into into the Dashboard.  
with e.g. `systemd-cat -t NAME -p4` I put several outputs of several shell scripts into journald.

now I try to get this data out from jounrald into /ui  
the bash script: `journalctl -t NAME -o cat -f -n1 -p4 |grep -v "EXCLUDE1" | grep -v "EXCLUDE2" |grep ...`  
I have two problems:

1. It seems Exec note do not rescive the data. (it seems a problem of PID?)
2. I do not have a solution to get aflow that show me only the last 20 lines.

Any Idea?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [8 December 2022 16:48 UTC](https://discourse.nodered.org/t/how-show-a-log-flow-from-journald-on-ui-dashboard/71885/2 "2022-12-08T16:48:04Z")

</div>

> [@Mannshoch](#):
>
> It seems Exec note do not rescive the data. (it seems a problem of PID?)

What error are you seeing? Have you checked all three outputs of the exec node?

Show us how you have configured the exec node.

Does that command work if you run it in a terminal?

---

<div class="post-metadata">

**Author:** ![Mannshoch](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mannshoch/32/19477_2.png) [@Mannshoch](https://discourse.nodered.org/u/Mannshoch)\
**Post date:** [9 December 2022 16:51 UTC](https://discourse.nodered.org/t/how-show-a-log-flow-from-journald-on-ui-dashboard/71885/3 "2022-12-09T16:51:08Z")

</div>

Nodered

```auto
[{"id":"96985776.50d0c8","type":"debug","z":"81da06dc.48fab","name":"direct-stdout","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":510,"y":340,"wires":[]},{"id":"afe6bf414a20ace8","type":"debug","z":"81da06dc.48fab","name":"stderr","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":490,"y":380,"wires":[]},{"id":"38d950c4f69ac025","type":"debug","z":"81da06dc.48fab","name":"stdreturn","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":500,"y":420,"wires":[]},{"id":"0a9729d044157f88","type":"exec","z":"81da06dc.48fab","command":"/home/pi/journal-hp.bash","addpay":"","append":"","useSpawn":"true","timer":"","winHide":false,"oldrc":false,"name":"journalctl -f","x":290,"y":360,"wires":[["95a1bd0afaf622a7","96985776.50d0c8"],["afe6bf414a20ace8"],["38d950c4f69ac025"]]},{"id":"8f439de10cba349a","type":"inject","z":"81da06dc.48fab","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"1","topic":"","payload":"","payloadType":"date","x":130,"y":360,"wires":[["0a9729d044157f88"]]}]

```

Bash

```auto
#!/bin/bash
export SYSTEMD_COLORS=false
journalctl -t Scan -o cat -f -n1 -p4 | grep -v "Reading data" | grep -v "BLOB"

```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [10 December 2022 09:32 UTC](https://discourse.nodered.org/t/how-show-a-log-flow-from-journald-on-ui-dashboard/71885/4 "2022-12-10T09:32:11Z")

</div>

It is important to try to answer all questions. You have not answered:

> [@Colin](#):
>
> What error are you seeing? Have you checked all three outputs of the exec node?
> 
> Does that command work if you run it in a terminal?

I note that you have not set the set the debug nodes to output the full message object. That is important.

---

<div class="post-metadata">

**Author:** ![Mannshoch](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mannshoch/32/19477_2.png) [@Mannshoch](https://discourse.nodered.org/u/Mannshoch)\
**Post date:** [16 December 2022 17:16 UTC](https://discourse.nodered.org/t/how-show-a-log-flow-from-journald-on-ui-dashboard/71885/5 "2022-12-16T17:16:56Z")

</div>

- I do not see any feedback on any node.
- The above script work if I run it in a terminal.
- I changed the Debug node to full message object -\> Still no output.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [17 December 2022 08:45 UTC](https://discourse.nodered.org/t/how-show-a-log-flow-from-journald-on-ui-dashboard/71885/6 "2022-12-17T08:45:32Z")

</div>

Are you sure that running journal-hp.bash manually works? I can't run exactly the journalctl command that you are as it doesn't produce any output, but if, instead I put in the bash script  
`journalctl -f -n1 -u nodered -o cat`  
then your flow does work. Similarly if I use  
`journalctl -f -n1 -u nodered -o cat | grep "info"`  
then it still works.

In case you didn't know, if you configure an Inject node to send msg.kill as an empty string to the exec node you can use it to kill the current process to make testing easier.

**[Edit]** A thought, are you running a Docker install of node-red?

---

<div class="post-metadata">

**Author:** ![Mannshoch](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mannshoch/32/19477_2.png) [@Mannshoch](https://discourse.nodered.org/u/Mannshoch)\
**Post date:** [21 December 2022 08:37 UTC](https://discourse.nodered.org/t/how-show-a-log-flow-from-journald-on-ui-dashboard/71885/7 "2022-12-21T08:37:45Z")

</div>

Yes I'm sure It runs locally

start in one terminal

```auto
journalctl -t scan -o cat -f -n1 -p5 

```

then open a second terminal

```auto
echo hallo welt 4 |systemd-cat -t scan -p4
echo hallo welt 5 |systemd-cat -t scan -p5
echo hallo welt 6 |systemd-cat -t scan -p6

```

you see that all journal entries with level 5 or lower appear in the other terminal

No.  
I run node-red on a "Raspberry Pi 2 Model B Rev 1.1" with Raspbian. I used Running on Raspberry Pi : [Node-RED to install node-red.](https://nodered.org/docs/getting-started/raspberrypi)

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [21 December 2022 11:37 UTC](https://discourse.nodered.org/t/how-show-a-log-flow-from-journald-on-ui-dashboard/71885/8 "2022-12-21T11:37:18Z")

</div>

If you run your script `/home/pi/journal-hp.bash` in a terminal and in a second terminal window use one of your example commands  
`echo hallo welt 4 |systemd-cat -t scan -p4`  
does the result show up in the terminal window running the bash script?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [21 December 2022 11:45 UTC](https://discourse.nodered.org/t/how-show-a-log-flow-from-journald-on-ui-dashboard/71885/9 "2022-12-21T11:45:27Z")

</div>

Does it work for you if you use the examples I suggested?

---

<div class="post-metadata">

**Author:** ![Mannshoch](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mannshoch/32/19477_2.png) [@Mannshoch](https://discourse.nodered.org/u/Mannshoch)\
**Post date:** [21 December 2022 11:53 UTC](https://discourse.nodered.org/t/how-show-a-log-flow-from-journald-on-ui-dashboard/71885/10 "2022-12-21T11:53:20Z")

</div>

@zenofmud yes of course. As I described above.

I found out:  
The exec node shows the pid 1386 `ps aux |grep 1386` show me the bash script. But If I grep for journalctl `ps aux|grep journalctl` I get the pid 1387.

---

<div class="post-metadata">

**Author:** ![Mannshoch](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mannshoch/32/19477_2.png) [@Mannshoch](https://discourse.nodered.org/u/Mannshoch)\
**Post date:** [21 December 2022 12:09 UTC](https://discourse.nodered.org/t/how-show-a-log-flow-from-journald-on-ui-dashboard/71885/11 "2022-12-21T12:09:22Z")

</div>

@Colin It seems we crossposted. I tested your case. And I found two interesting behavior.

1. `grep -v "TEXT"` seems the culprit. If I use somewhere It not anymore work.
2. `msg.kill` only kill the bash script but not the `journalctl -t ...` process. This process still running.

It seems I have to filter excluding text with nodered.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [21 December 2022 13:37 UTC](https://discourse.nodered.org/t/how-show-a-log-flow-from-journald-on-ui-dashboard/71885/12 "2022-12-21T13:37:43Z")

</div>

> [@Mannshoch](#):
>
> `grep -v "TEXT"` seems the culprit. If I use somewhere It not anymore work.

`journalctl -f -n1 -u nodered -o cat | grep "info"`  
works ok for me. Does that not work for you? Do you need to put it in a bash script? Can you put the command directly in the exec node?

---

<div class="post-metadata">

**Author:** ![Mannshoch](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mannshoch/32/19477_2.png) [@Mannshoch](https://discourse.nodered.org/u/Mannshoch)\
**Post date:** [21 December 2022 13:50 UTC](https://discourse.nodered.org/t/how-show-a-log-flow-from-journald-on-ui-dashboard/71885/13 "2022-12-21T13:50:27Z")

</div>

normal grep works `|grep "TEXT"` but not if I wish to exclude e.g. with `|grep -v "TEXT"`

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [21 December 2022 14:37 UTC](https://discourse.nodered.org/t/how-show-a-log-flow-from-journald-on-ui-dashboard/71885/14 "2022-12-21T14:37:51Z")

</div>

> [@Mannshoch](#):
>
> journalctl `ps aux|grep journalctl`

It is a buffering issue of some sort. If you use, in the bash script  
`journalctl -f -n1 -u nodered -o cat | grep -v "Stop"`  
and redeploy node-red a few times, and then kill the process and journalctl then all the lines appear.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [20 January 2023 14:38 UTC](https://discourse.nodered.org/t/how-show-a-log-flow-from-journald-on-ui-dashboard/71885/15 "2023-01-20T14:38:27Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
