Best practice to recover remote logs?

Hi,

I want to test my program performance. Currently we have some logging tool implemented that requires some generated logs from the main app (inside the container). Usually, I just connected via ssh and copied the .txt file to the remote local computer and send it by email, but know I don’t know how to do it when the device is not in my same network. Any standard procedure that you are using?

regards

Hey there! What I’ve done in the past is to configure the application to dump the logs into a file in the persistent data partition. Then you can remotely connect to it through the Balena VPN by using the Balena Cloud dashboard and fetch it from there.

Do you mean from the web SSH console? or there is an option?
I already have a shared data partition where I put my data. So I’m only missing the fetching part (can you develop it a little more please).

Hi Andres,

Yes, you can use either the web console or the Balena CLI to connect to the device through SSH over the Balena VPN and copy the file as usual. The Balena CLI just crafts an SSH command that pivots on the VPN (https://github.com/balena-io/balena-cli/blob/master/lib/actions/ssh.ts#L152)

ok, my problem is that used to

  1. connect to a remote computer that was in the same network as my device using any desk or Teamviewer.
  2. From that computer using putty I copied the file like this:
    scp root@xxx.xx.xx.x:/data/log.txt /tmp

so I can not do this. 1) I can not install Balena CLI everywhere and 2) the idea of having Balena stop using intermediary PCs.

So what am I thinking in wrong way?

Hi Andres,

Once you are in the computer that you connected to using Teamviewer, you can use scp in the same way, just that you will have to configure how SSH makes the connection to the device is more advanced way in order to create a tunnel from your computer running Putty to the remote device.

The only difference between your existing setup and Balena is that you would SSH (using scp) over our VPN instance rather than directly from the local network.

Hi,

I have a Partition :

volumes:
cam-config-data: {}
that is used by my containers. There I put the Log, however, when I do:

scp -P 22222 root@192.168.4.25:/data/log_Events.txt /data/

There is no file. So I understand that I connect to the host and not to any of the containers. From the host where I can access the shared Partition?

I tried looking like in /media and /mnt but I didn’t find the shared partition between containers.

Hi Andres. Yeah so when you ssh/scp into a device it drops you into the hostOS filesystem rather than the container specific one. To find the volume mounts are a bit of a fiddle, but basically you can use balena volume ls to find the volume name and then balena volume inspect <VOLUME_NAME> and that should out put as below:

root@d058311:~# balena volume ls
DRIVER              VOLUME NAME
local               1539544_resin-data
root@d058311:~# balena volume inspect 1539544_resin-data
[
    {
        "CreatedAt": "2020-01-06T20:09:05Z",
        "Driver": "local",
        "Labels": {
            "io.balena.supervised": "true"
        },
        "Mountpoint": "/var/lib/docker/volumes/1539544_resin-data/_data",
        "Name": "1539544_resin-data",
        "Options": {},
        "Scope": "local"
    }
]

you should then be able to run your scp command on the “Mountpoint” path listed in the inspect output.

1 Like