Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

Simulation Service Developer Reference Guide

Peter Felts edited this page Apr 17, 2020 · 11 revisions

Contents

SSH into a VM

  1. Reset the username and password for The VMSS deploymnet

  2. Upgrade VM instances

  3. Obtain IP address of VM instanace

  4. SSH into a VM

Viewing Logs

  1. How to view logs

  2. Copying log files to another machine

  3. Changing the log level

Viewing simulated data

  1. Viewing message throughput and connected devices in the Azure Portal

  2. Viewing simulated data using Remote Monitoring V2

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.

1. Set username and password for VM

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. image
  • 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. image
  • 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>

Viewing Logs

How to view logs

  1. Open a bash window.

  2. SSH into your VM

  3. Navigate to the /app folder

    cd /app
  4. Run the logs.sh script.

    sudo ./logs.sh
  5. This will show you the real-time log output of all running services.

Copying log files to another machine

  1. Open a bash terminal.

  2. SSH into the VM using the instructions above in SSH into a VM

  3. Obtain root account access: sudo su

  4. Find your container name or id with docker ps.

  5. 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): image

  6. Write the logs for a container to disk:

    docker logs <containerid> > mylogs.log
  7. Ensure the log data is present:

    sudo nano mylogs.log
  8. Open a second bash terminal on your local machine.

  9. Copy the file local:

    scp <username>@<vm ip>:mylogs.log c:/temp/mylogs.log

Changing the log level

  1. Open a bash terminal.
  2. SSH into the VM using the instructions above in SSH into a VM
  3. Navigate to the /app folder and edit the environment variables file.
    cd /app
    sudo nano env-vars
  4. Add the following line to the environment variables file. Supported values are ["Debug", "Info", "Warn", "Error"].
export PCS_LOG_LEVEL="[your log level choice]"
  1. Press control+X to exit and save the file
  2. Restart the service with the new log level with:
sudo ./start.sh

Viewing simulated data

Viewing message throughput and connected devices in the Azure Portal

  1. Go to Azure portal > [your resource group] > IotHub > Metrics.

  2. Select the values that you'd like to view. For example, connected devices, messages sent, etc...

  3. If you just started your simulation you may need to wait a few minutes for the devices to show up in the portal.

    image

Viewing simulated data using Remote Monitoring V2

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.