-
Notifications
You must be signed in to change notification settings - Fork 73
Simulation Service Developer Reference Guide
SSH into a VM
Device Simulation is comprised of a set of microservices running inside Docker containers. Each microservice writes its logs inside its container. Logs for individual microservices are obtained by establishing an SSH connection to a Device Simulation container (running in a virtual machine on Azure), exporting the logs, then finally transferring the logs to your local machine for analysis). The steps below describe to to accomplish this.
In order to access the VM, you will need to set a username and password for your VM.
- Go to
Azure portal > [your resource group] > Virtual machine scale set > reset password
. - Enter a new username and password.
- Hit Save
- After resetting the VM username and password, VM instances will not reflect this change until they are upgraded to the latest model and reimaged. When re-imaging the VMs, all logs will be lost. To obtain useful logs the error you're encountering will need to be reproduced after reimaging the VM instances.
- Go to
Azure portal > [your resource group] > Virtual machine scale set > Instances
. - Select any VM instances and hit
Upgrade
. - After the VM instances have been upgraded, select
reimage
.
- After the VM-upgrade process has completed, navigate to `Azure portal > [your resource group] > Virtual machine scale set > Instances
- Select a VM instance to connect to
- Note/copy the
Public IP address
- You can also select "Connect" from your VM's portal page which will display connection information.
-
Sign into a VM.
- Open a bash window.
- If using Windows Command Prompt, you can enable bash with the instructions here
- To sign into a VM using bash, use the new username (from above) followed by the IP address of the VM and enter the new sign in credentials.
ssh myusername@<VM IP address>
- Open a bash window.
-
Open a bash window.
-
Navigate to the
/app
foldercd /app
-
Run the logs.sh script.
sudo ./logs.sh
-
This will show you the real-time log output of all running services.
-
Open a bash terminal.
-
SSH into the VM using the instructions above in SSH into a VM
-
Obtain root account access:
sudo su
-
Find your container name or id with
docker ps
. -
Obtain the container ID for the microservice that you would like the logs of (most of the time, this will be the device-simulation-dotnet container):
-
Write the logs for a container to disk:
docker logs <containerid> > mylogs.log
-
Ensure the log data is present:
sudo nano mylogs.log
-
Open a second bash terminal on your local machine.
-
Copy the file local:
scp <username>@<vm ip>:mylogs.log c:/temp/mylogs.log
- Open a bash terminal.
- SSH into the VM using the instructions above in SSH into a VM
- Navigate to the
/app
folder and edit the environment variables file.cd /app sudo nano env-vars
- Add the following line to the environment variables file. Supported values are ["Debug", "Info", "Warn", "Error"].
export PCS_LOG_LEVEL="[your log level choice]"
- Press control+X to exit and save the file
- Restart the service with the new log level with:
sudo ./start.sh
-
Go to
Azure portal > [your resource group] > IotHub > Metrics
. -
Select the values that you'd like to view. For example, connected devices, messages sent, etc...
-
If you just started your simulation you may need to wait a few minutes for the devices to show up in the portal.
If you have a Remote Monitoring V2 deployment, you can enter the hub connection string for the hub from the Remote Monitoring deployment instead of the one deployed with Device Simulation.
Using an RMv2 Hub works well and allows you to see the data show up in the RMv2 dashboard.