Microsoft Azure AZ-801 — Section 17: Monitor Windows Server by using Windows Server tools and Azure services Part 4
106. Collect performance counters to Azure
Now I’d like to show you how when we’ve set up our log analytics workspace, how we can actually collect performance counters from a server that has been connected.
So, in my case, I have actually already installed the agent on the log analytics agent on my NYC-SVR1 and here I am on portal.com. I can click my menu button, go to resource groups here and I’ve got a resource group called Log Data RG. I’m going to click on that and I have a log analytics workspace called my Log Analytics Workspace. I’m going to click on that and then from there I’m going to click on agent Management and you can see that says a Windows computer is connected to. See them in logs. And from there I can run. I can basically run what’s known as CXL, the custom query language for determining what machines showing up. You can see NYC-SVR1 but not going to get into Cousteau query language a lot right now. Let’s go back to our log analytics workspace. And what I want to do is click on data collection rules. This is going to control what I want to collect.
So, I’m going to say Create a data collection rule and we’re going to call this is for Windows, obviously, and then we’re going to go over here to you don’t really as far as resources goes, there’s not really anything regarding resources you have to do with Windows here. But what you in this case. But it’s automatically going to know for Windows devices because you’ve installed the agent. But what we need to do is cover here to collect and deliver. We’re going to click Add data source. We’ll drop this down and there you go, Windows, the performance counters. All right. And I can collect data for the CPU memory disk network. You can also do some other if you want to kind of customize things a little bit more. They have lots of other counters there that you can do. We’ll go ahead and grab these four basic ones and then it says, All right, well, what’s your destination? Select the destinations for where the data will be delivered. Normal usage charges for destination will occur. Of course, they can tell you about the pricing of all that. So, it’s going to destination. So, you can do it in either Azure monitor or logs or Azure monitor metrics. Either one, we’ll click Add data source. And then we’ll click, review and create. And let’s see. Oh, I forgot to give it a name. So, we’ll say collect performance. Is one of my call it and we’ll click, review and create and it validates and we will click create and that is how you can configure it to collect performance counters.
Now, just like everything else in Azure, again, this is going to take some time, but this, this is now deployed and what I will eventually be able to do, give it some time, is go to menu. Go down here to monitor the monitor blade. All right. And then we’ll go over here to metrics. If you chose to store this in logs, you would go to logs. But in my case, I chose to store it. I had chosen to store it in metrics.
Then I’ll go there and I’ll expand out my resource group, and I’m going to select the log analytics workspace. All right. And then we’re going to hit Apply. And then I can choose the metrics I want to look at, which in the case of like your CPU, you have to you have to basically choose the counters that you selected. Right? Like processor. But it hasn’t really collected any real data from the server just yet because it can take like an hour or something like that to, to really start collecting information.
So, it probably won’t show me anything. Not yet, at least. But let’s go right here and let’s find. Percent processor time. There you go. Yeah. And so I can see an average and it hasn’t really it hasn’t really pulled anything to show me just yet. But given time, you’ll be able to pull metrics and all that stuff from that server, but that’s how you’d actually pull that information.
107. Create alerts
Let’s take a look at another great feature that Azure Monitor offers and that involves being able to set up alerts.
So, to get to this, we’re going to go to portal.azure.com, We’re going to click the menu button and go down to the monitor blade and we’re going to click on the alerts blade.
Now, from there we can go right up here to the left and click create. And we can create an alert rule. All right. We have to select our subscription and then we’re going to hit Dunn. And then from there, we’re going to click Next and we’re going to set our conditions. So, our conditions are going to involve what they call signals, which are things we want to look for that potentially might generate an alert.
For example, if I scroll down or better yet, why don’t we look for let’s look for Virtual machine, let’s do a search for that and then let’s see, add virtual machine remove captures, start a virtual machine, redeploy, maybe, shut down a virtual machine. Maybe. We want to know if a virtual machine has been shut down. All right.
We’ll go ahead and select that. All right. And of course, it’s going to show us if there’s any data in the last 6 hours. We can of course, we can look at the last 24 hours if we want, see if anything happens then. But anyway, we can go down here. We have the event level, whether it’s flagged as a critical error warning, informational, verbose, you can select all of these. So, whatever. In my case, I’m going to do all. So, whatever event level that’s shutting down a VM might be triggered by.
Then from there I’m going to go to actions and I can set up what’s called an action group. All right. Of course, I don’t have any action groups, so I’m going to create an action group from there. An action group. I’m going to assign this to a resource. Why don’t we assign it to the VM Destination Resource Group, which is where my VM is. If this is going to be a region, whether it’s you’ll see here global in my case and there’s some other region options as well. But I’m going to go global and then action group name, I’m going to call it VM Alert Action and then we’re going to click Next. All right. And then it says, okay, what kind of notification do you want to do? I’m going to do a so I could do Azure Resource manager role email the Azure resource manager role email, SMS message or push. And then from there, if I wanted to put an email address, cell phone number, all that, I can have Azure Mobile app associated with it, voice information. I’m going to do email and we’ll say JSI at exam lab practice.com. All right. And then I’ll go ahead and click Okay to that. All right. I’m going to call this email, JSI. That’s the name of it. We’ll click Next.
The other thing I can do is I can have action types and a little bit outside the scope of what we’re getting into the thorough details of this. But you can do things like automation, run books, you could have scripts that get ran a bunch of different things. Microsoft has what are called logic apps, the Event Hub. There’s various things here that I could have a type of action. In my case, I’m not going to I don’t I’m not going to set any actions. I’m just going to simply have it to where I just get alerted. Because if I’m caring about the virtual machine shutting down, I just want to be alerted.
So, I’m then going to click to review and create. All right. And we’ll go ahead and click create. And it’s going to now create this little action group that brings us back to our alert rule. And then we’re going to go ahead and click details. All right. Says, okay, so you’re going to where are you going to store this alert rule? I’m going to store it in the VM destination. What do you want to call it? I’m going to say alert VM shutdown. Give it a description if you want. There’s alsome advanced options here. You can set add your own properties to an alert rule. These will be sent by the alert payload. So, if it was being emailed out, you’d have some additional data that’s going to be sent to you. But I’m going to click Review and create and we’re going to go ahead and click create. All right.
Let’s go up and click on Alert Rules and we should be able to see our alert rule. Keep in mind that sometimes when you do this, it can take a minute or two before this will actually show up.
So, just be advised that you might if you do this, you might want to give it a minute or two, but you can see that our alert rule is now ready to go. We have set up this alert rule. If we want to go in and make some changes, we can we can click on it. And if we want to edit, we can. But you can see the information here that we’ve selected. If we want to go in and edit this, we can just click, edit and we can alter the action information as well. You can’t change the name. That’s one thing they don’t let you do. But if you want to go in and for example, change the email information, you can click on the action and you can alter, you can alter that information.
So, here I wanted to do that. I could I can edit that, change the email address that it’s going to use. All right. And so that is how we can set up an alert.
I encourage you to try that out. I encourage you to try to generate some alerts and see if you can get the alerts generated in an email to you. All right. Pretty neat stuff. Definitely something fun to play around with and very, very handy.
108. Monitor Azure Virtual Machines by using Azure diagnostics extension
I’d now like to show you how we have a newer feature in Azure for monitoring virtual machines and their guest operating systems just built right into Azure. It’s known as the Azure Diagnostic extension.
So, what we’re going to do, we’re just going to create a virtual machine. Real quick, click the menu button, go to virtual machines, and we’re going to click to create a new one. All right. And let me just create a new resource group and I’m just going to call this a. Monitor. My VM RG. And then we’ll just create a VM. This is going to just be called. I think I’ve already got a server in Arabs can call this Windows Server two because I think I’ve already got a VM. Which I’m not using in this demonstration, and we’re just going to do a Windows Server East. Use all that looks good. And we’ll do Windows Server 2022. Leave it as the default. EOP admin will be my admin account and I’m just going to put a password in real fast. All right. Everything else should be fine there. Let’s go to disk. We’ll just set this to standard. Standard HDD. And let’s see. Anything else? We can enable operating system guest diagnostics. Turn that on notice. It’s going to want to create a storage account, right, for this so I can go ahead and just allow it to create a new storage account. Taken the default there. All right. This can be enabled later if you’ve already got a VM. Just so you know. All right. So, that’s fine. And for management, I am going to do an auto shut off and I’ll have the auto shut off at 11 p.m. Eastern time.
So, let me just go here. There we go. And I think everything else is good. So, we’ll go to. Review and create. We’ll let it validate. And then I’m going to go ahead. Let’s see. Networking. Public IP address. Let’s see. I think I might have just moved too fast. Let’s try that again. Yeah, I think I was just moving too fast through the Wizard. Sometimes it does that. So, here we go. Validation pass. I’m going to go ahead and pull the trigger. We’ll click to create and I’ll pause the recording while it’s creating the VM. All right, now that is done, I’m just going to click go to Resource. And we can scroll down here to where it says diagnostic settings. And as you can see, this has already been enabled based on what I chose through monitoring earlier.
Now, had I not had I had if I had already installed this virtual machine and I had not selected what I did when I created it, I would just have an option to do it here. So, I could have just done it here, could have created a storage account and all that. And I would have been able to enable that here. All right.
So, you have just an overview of here, of here of what we can do involving performance counters, event logs, directory information, crash dump information, sync information agent and boot diagnostics. And you’ll see you have various Tabs here that involve the same things you’re seeing in overview. So, we’ll click on performance counters first, because that’s really what we care about in this particular lesson.
Essentially I’ve got CPU memory, disk and network. These are all things I’m going to be monitoring. I’ve also got ASP.NET and SQL. So, every you can see every 60 seconds, every minute. Basically it’s gathering this information and storing this information. All right, now I can go over here.
Grabbing these counters, I can also go custom and I can choose various other counters here if I want. Goes a little deeper. You can obviously switch pages and go deeper into it’s more like a performance monitor style thing, but you’re already grabbing all that data. This is sort of like the parent object.
So, go in custom would just let you sort of disable some of the things you don’t want, right? Then I can go to logs and it’s going to grab log information.
So, event log information is all going to be grabbed. I can specify stuff there. I can even do things like IIS logs and fail request logs. You can have application logs for.net and all that being grabbed. Those are called trace logs, crash dumps. So, get like a blue screen of death or something. You can have that and then sync.
This would essentially involve I wanted this to go somewhere else other than the storage account if I want it to be stored somewhere other than that storage account, I can I can go here. Of course they do tell you with Azure Monitor requires a managed identity. You have to set up what’s called a manage identity for that and an application inside.
So, I want to do that. I can have application insights, get a copy of this information and then agent the agent that’s, that’s embedded. It’s already been installed on the virtual machine when I enabled this and it’s storing everything into this storage account right here.
Everything I’m doing is being dumped into that storage account. If I wanted to remove this, I can remove it here. Also, there is a disk quota that’s being set there you can see and diagnostic infrastructure log is also being pulled. And they tell you here that by enabling this option, you’re collecting logs generated by the Azure diagnostic agent. These logs can basically be used for troubleshooting and stuff like that, including any kind of errors and diagnostic data as you can grab that they can be grabbed. And you’ve also got log level. So, the minimum severity level of logs that will be collected, anything involving errors, you can obviously adjust that if you want. All right. So, anything I change here, I would then save it. All right. Ultimately, though, I do now I have diagnostic setting, a diagnostic information being logged.
Where is it all being stored? You have to go to the storage account for that. So, if we go to the menu button and we go to storage accounts, the storage account where I’ve that I created was this one right here. So, I’m going to click on that. All right. And if you just go to Tables, you’ll see it, but you can’t really view anything. What you got to do is go to storage browser and then go to Tables there, and then you can click on the performance counter and all that, and it shows you all this information. I can also link this to my Azure monitor and metrics and all that if I want. Which will, which will pull all this into like if I want to pull it into a log analytics workspace and that way I can run queries and all that I can, or if I want to pull it into Azure Monitor, I can.
So, there’s various things there I can do pull in, go into Azure monitor and clicking on virtual machines and. I can analyze data using performance metrics and all that, which I’m not getting into in this video. But you can, you can on board it and all that. But ultimately that’s how you’re actually gathering that information into Tables, using this extension. It’s built in. You’re not having to install anything special. It’s all being done through Azure.
109. Monitor Azure Virtual Machines performance by using VM insights
Let’s talk about the concepts now of VM Insights with Azure.
Now, VM Insights is a feature, as you can see here in this article, that is used for monitoring the performance and health of a virtual machine. Not only does it search, does it look at virtual machine and pull analytic data, but it also looks at skill sets as well.
If you have multiple virtual machine skill sets that are generating more virtual machines upon load, it’s going to analyze all of that for you. And the major thing this brings to the Table is a predictive performance analysis, meaning if you’re if you’re slowly starting to bottleneck the virtual machines, slowly starting to bottleneck over time, it can alert you and let you know that the virtual machine is bottlenecking. As you can see, this does support Windows and Linux. You’ve got Azure Virtual Machine skill sets, sports hybrid Azure or on-premises virtual machines as well, and virtual machines hosted in other cloud environments. All right. This can grab logging information and store all of that data in the Azure Monitor. Of course, there is some pricing stuff here involving the Azure Monitor, and you can look at the pricing page here just by clicking that link to get a feel for the cost. And you can also go to the Azure calculator and take a look at that. As you can see, this is a pay as you go 100 gigs per day depends on how much data you’re pulling. Let’s take a look how we can enable this.
A couple of ways we can do this. I’ve actually got a virtual machine called Windows Server two that I’ve set up previously, and if I go to any virtual machine really will do here as far as playing around with this. But when server two is the one I’m going to click on.
One way that I could turn this on. Is just by coming right in here. And if we scroll down just a little bit, let me find it. Here it is. Insights under the monitoring blade. You can enable it right here. Another way of doing this is to go to the menu button and go to monitor. And then if we scroll down a bit here and look for. Where is it at? Virtual machines, right there in front of me. Under Insights, you can click right here where it says configure insights. And then from there it’ll detect there’s your virtual machine and you’ll notice it’s currently not enabled.
So, I’m going to go ahead and click to enable this and we’ll choose Enable. All right. This is all right. You’re enabling the Azure Monitor agent for this subscription and it’s going to create a data collection rule for this. And I’m going to go ahead and now click configure. All right. And so now that is going to go ahead and able that I’m going to go ahead and pause a recording while that’s happening. All right. Once that’s done, you have to refresh the web browser. And then once you refresh the web browser, you should be able to go over here to overview and you’ll see right here it’s been added, it’s been able. But the collection rule that was created is you have to enable the performance monitor counters that you want to monitor.
So, just click on that. And then we’ll come over here to data sources and there’s performance counters. K We’ll go there, We’ll enable those. We’ll click. Next, it’s going to store it in Azure logs. Save. And that’s it. We’ve now basically enabled that. And now, now it can start gathering information. Of course, it does take time to start updating and all that, but it will begin monitoring the health of your virtual machine for you. All right. And you’ll be able to take a look at the performance metrics and all that, that’ll start showing up over here. Once that once that has officially refresh, it looks like it actually has started showing up already. So, you can see here CPU utilization, my memory usage bytes sent, networking bytes received.
So, all this inside information is showing up. All right. Pretty neat little feature, very easy to turn on and manage. And of course, you can filter, filter what you’re looking at. And if you want to look at the as far as CPU utilization, you can look at average minimum, maximum, whatever it is you want to look at, you can very easily switch all that. But all right, that is how you can turn that feature on. Pretty neat little feature, like I said, very easy to set up.