in this video we set up windows virtual desktop monitoring
in log analytics
hello everyone i'm Travis and this is Ciraltos in this video we're going to
go over collecting performance data from windows virtual desktop in log
analytics and viewing that data with a custom workbook made available for
microsoft before that please take a second to like
subscribe and click the bell icon for notifications
of new content this video is based off a tech community post from Christiaan
Brinkhoff i'll include a link below this is a great solution microsoft put
together to actively monitor windows virtual desktop services
logins and session hosts i'm going to do a walkthrough of setting up the solution
starting with deploying the log analytics workspace
then collecting performance data for the servers
and sending azure diagnostic data to log analytics
once that's in place we deploy the workbook to visualize
and review the data that gets collected let's jump in and get started
here we are at the portal the first thing i'm going to do is create a log
analytics workspace so let's go to create a resource
and log analytics
we'll just select this
and create
i'll create a new resource group and i'll call this demo
larg
i'll give it a name i'll call it let's call it
cir log analytics demo
i'll change the region to central us
we'll go to the pricing tier we're going to leave it as pay as you go
i'll leave tags blank and we'll go to reveal and create
and i'll give it a minute to finish that finished
let's go to the resource here i am in the log analytics demo now
the first thing i have to do is add the log analytics agent to my
session host so to do that i'll go to the workspace and then i'm going to go
to workspace data source
and select virtual machines and here we can see the two
that i'm going to select are the wvd demo
i'm going to go to the first one and just click connect
and that will deploy the agent to that server
and add it to this workspace
now i'll go to the second one and do the same
well that's finishing the next thing i'm going to do is add the data collection
for the session host so in order to get this solution to work we have to
gather certain performance statistics from these servers to pull them in
to log analytics and then the solution will use that data to present the
information i'm just going to open up another window
and go to the solution page and i'll have these links available
below under collect performance counters
there's a list of two batches of performance counters we
have to add and it's broken into two because log
analytics can only have like up to i think it's 20 entries per api call
so they broke this into two set batches and i'm just going to start with the
first one so i'll copy this and then i'm going to go to i'm going to
come back up to advanced settings
data windows performance counters and i can add that in
now that will work but that's a lot of work to go through and
add each one individual so what i did is i created a script
and i'll make this available as well all you have to do is give it the resource
group of that log analytics workspace and then the workspace name
and then i've got a list of all those counters from that website
and i just created a list out of that and this will loop through
all of those counters and add it to the workspace so let's run that
and you do have to be signed into azure for this to work
also you need the az let's go and run the script first i have
to go into the directory
and i'll run the script this will take a couple seconds to run
as it loops through those i think there's a total of about 36
counters adding them one by one uh certainly can be done and if you're
only doing it once it's probably not that bad
but i had to do this a few times for this video so this really
helps speed things up that finish let's go back to the workspace
and see what that looks like i'm going to just refresh
go back to data and windows performance counter
and there they all are
now the next step is to add the azure ad sign-in logs so to do that i'm going to
go to azure ad
and we're going to go to diagnostic settings
diagnostic settings is interesting because you can use it to push
log data to different services i'm going to
add one i'm going to just give this a name i'll call it
aad hyphen diagnostics
i'm going to select sign in logs now notice one thing
you do need an azure ad p1 or p2 license to collect these logs if you don't have
the license that's okay you can skip this step there's a box
that indicates where people are signing in from that won't work
but otherwise if you do have azure adp1 or p2
you can select this option and over here we can send data to event hub
storage accounts or log analytics as you might imagine we want log analytics
and we'll go to that cir log analytics demo
and click save i'm going to go back to windows virtual desktop
i'm going to go to host pools and i have a couple host pools in here
we're just going to focus on this one right now uh so
every object within windows virtual desktop
connected to this host pool so that includes the host pool the application
groups and the workspace i have to do the same thing where i'm
gonna come into diagnostic settings and then add a diagnostic settings
check all these boxes and then send to log analytics
but i have to do that for every object and i'm doing this more than once so i
created another script that will take care of this
here i'm back in vs code and what i need to run the script is i need the host
pool name and the host pool resource group
i also need the workspace resource group if it's different from the hostpool
resource group they can be in the same resource group
or sometimes a workspace is actually in a different resource group
so if it is different entered here otherwise leave it blank or
null and the script will take care of that i also need the log analytics
workspace resource group and the workspace name once i have all
that i can run it and it's just going to find all the different
resource ids needed and it will set up the diagnostic settings on all the
objects related to that host pool
again you have to be logged into azure ad for this to work
and you need the az modules
that finished let's go to the portal and see what happened
if i come into my workspace and diagnostic settings
here you can see i have diagnostic settings in there now
if i go to that workspace
and my diagnostic settings are in place
we can go into edit settings and see it sending information to that
log analytics workspace okay so at this point we have
performance monitors collecting on the session host
and we have the diagnostic settings in place for azure ad
sign-in logs as well as every object related to that host pool
if i was tracking multiple host pools i'd have to run that again
to address those other host pools next we'll create the workbook
here i am back at the portal and let's create that workbook
so we're going to go to log analytics go into the workspace we set up in the
previous steps go to workbooks
i'm just going to move this over and we're going to add a new workbook
go to the code and we need to enter in code here
so to do that i'm going to come back to this webpage
and in the web page under creating a workbook
in azure monitor
here all the steps to do it and i'm going to click on this link
to go into the github repository for the code
here's the code that we need and i'm going to switch this to raw
and then just copy everything so i'll do a control a and a control c
now come back to the workbook and i'll just do a ctrl
a and delete everything out and then ctrl v
to paste in the code we copied from github
and apply we've got some options here select your subscription
and i'm going to select the workspace next go to resource group and i'll
select the resource group that my host pool is in
and then i'll select the host pool and i've got a couple here but select
the one that you applied those performance counters to
and then under hosts i'll select all next i'm going to select done editing
and save i'm going to change the name
and click save
so next time we come in if we go to our workbooks
we can see our recent modified workbook that's right here
now we can take a look at some of the data that came through notice that it
defaults to the workspace that we set up before we saved it but you can
modify that if you need
in the overview tab we have uh windows virtual desktop resources
daily connections current status we've got a login heat map
so you can see where logins are coming from
we've got average session duration by users we've got a whole bunch of good
information here
then we can go to session detail and get details on each session
session overview and history i don't have a lot of data displaying here
because this is a test workspace but it gives you an idea of the type of
information you can get from this solution
here looks like i have some errors connection errors
and it gives a list of the connection errors looks like the numbers are
crowded there but you get the idea we get a lot of
information from this here if i change this name to
yep so if i change it to my name the user i'm using to log in
i can see some details about my connections
we have session performance
and host performance here you can get details about each host
that's an overview of the windows virtual desktop
workbook solution in this demo we deployed a log analytics workspace
we added session host to the workspace and set up the data collector
as well as adding windows virtual desktop diagnostic data
and azure ad sign-in diagnostic data we then created and saved the workbook
and reviewed the information we got from that workbook
i hope you found that helpful i want to thank christiane brinkoff and the rest
of the contributors at microsoft for making the solution available don't
forget to like subscribe and all that good stuff
thanks for watching