Getting journalctl logs from landscape scripts

Hey, we would like to retrieve device logs(journalctl) through landscape scripts, but journalctl requires sudo access, tried with root user too, is there a way to get logs without requiring root privileges.

Thanks in advance

Does the landscape-client snap not run as a daemon (i.e. as root) ? It should have full access to logs and the journalctl binary via the log-observe interface this way…

Its working as a daemon, but seems landscape-client doesnt have this interface

aliihsancengiz@2193a7d4-4204-ad1a-c5e5-04421aadc5e6:~$ snap services
Service                                 Startup   Current   Notes
landscape-client.landscape-client       enabled   active    -
...
aliihsancengiz@2193a7d4-4204-ad1a-c5e5-04421aadc5e6:~$ snap connections landscape-client
Interface         Plug                               Slot               Notes
account-control   landscape-client:account-control   :account-control   -
hardware-observe  landscape-client:hardware-observe  :hardware-observe  -
mount-observe     landscape-client:mount-observe     :mount-observe     -
network           landscape-client:network           :network           -
network-bind      landscape-client:network-bind      :network-bind      -
network-control   landscape-client:network-control   -                  -
network-manager   landscape-client:network-manager   -                  -
network-observe   landscape-client:network-observe   :network-observe   -
process-control   landscape-client:process-control   :process-control   -
scsi-generic      landscape-client:scsi-generic      :scsi-generic      -
shutdown          landscape-client:shutdown          :shutdown          -
snapd-control     landscape-client:snapd-control     :snapd-control     -
system-observe    landscape-client:system-observe    :system-observe    -
aliihsancengiz@2193a7d4-4204-ad1a-c5e5-04421aadc5e6:~$ snap list
Name                 Version                 Rev    Tracking       Publisher                Notes
core                 16-2.61.4-20240607      17200  latest/stable  canonicalâś“               core
core22               20240731                1564   latest/stable  canonicalâś“               base
landscape-client     24.04                   175    latest/stable  canonicalâś“               -
...

Ah, you should open an issue/bug for this then, so the interface gets added

Hey, @mikecw would it be possible to add log-observe interface into landscape-client ?

Yeah ok. I don’t see why not. I’ll sort it out.

1 Like

PR done. It just needs to go through the usual checks, builds, testing, release cycle blah blah blah stuff.

You will need to manually connect the interface though.

thanks a lot, would you mind to notify, when its released into edge or sth, maybe any other way to track it.

Will this always be the case?

I guess we can connect through Landscape API itself :stuck_out_tongue:

Probably not - the interface will probably get auto-connected in the global snap store at some point although if you are using a dedicated snap store, you have the power to make that auto-connection yourself.

And yes - you technically could make the connection with a Landscape script…

The edge track now has the interface. Just manually add with

snap connect landscape-client:log-observe

Request made for auto connect: https://forum.snapcraft.io/t/auto-connect-of-log-observe-for-landscape-client

1 Like

Thanks for update. Do you have estimate time to released as stable?

Not quite I am afraid. We’ve found a slight bug in the edge release with configurations that we just want to get fixed first so I’m afraid at the moment the answer is “not too long”.

1 Like

Should be stable now.

Thank you very much! I’m hoping this auto-connection will be completed soon.

Best regards.