Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Zabbix 7 IT Infrastructure Monitoring Cookbook

You're reading from   Zabbix 7 IT Infrastructure Monitoring Cookbook Explore the new features of Zabbix 7 for designing, building, and maintaining your Zabbix setup

Arrow left icon
Product type Paperback
Published in Jul 2024
Publisher Packt
ISBN-13 9781801078320
Length 540 pages
Edition 3rd Edition
Tools
Concepts
Arrow right icon
Authors (2):
Arrow left icon
Nathan Liefting Nathan Liefting
Author Profile Icon Nathan Liefting
Nathan Liefting
Brian van Baekel Brian van Baekel
Author Profile Icon Brian van Baekel
Brian van Baekel
Arrow right icon
View More author details
Toc

Table of Contents (16) Chapters Close

Preface 1. Chapter 1: Installing Zabbix and Getting Started Using the Frontend 2. Chapter 2: Getting Things Ready with Zabbix User Management FREE CHAPTER 3. Chapter 3: Setting Up Zabbix Monitoring 4. Chapter 4: Working with Triggers and Alerts 5. Chapter 5: Building Your Own Structured Templates 6. Chapter 6: Visualizing Data, Inventory, and Reporting 7. Chapter 7: Using Discovery for Automatic Creation 8. Chapter 8: Setting Up Zabbix Proxies 9. Chapter 9: Integrating Zabbix with External Services 10. Chapter 10: Extending Zabbix Functionality with Custom Scripts and the Zabbix API 11. Chapter 11: Maintaining Your Zabbix Setup 12. Chapter 12: Advanced Zabbix Database Management 13. Chapter 13: Bringing Zabbix to the Cloud with Zabbix Cloud Integration 14. Index 15. Other Books You May Enjoy

Setting up Microsoft Azure monitoring

The Microsoft Azure cloud is a big player in the cloud market these days and it’s important to keep an eye on this infrastructure as much as you would your own hardware. In this recipe, we are going to discover how to monitor Azure instances with our Zabbix setup.

Getting ready

For this recipe, we are going to need our Azure cloud with at least one of the following resources in it already.

  • Cosmos DB for MongoDB databases
  • Microsoft SQL databases
  • MySQL servers
  • PostgreSQL servers
  • Virtual machines

The recipe does not cover how to set up any of these resources, so make sure to do this in advance. We will also need our Zabbix server, which we’ll call lar-book-rocky in this recipe.

How to do it…

For Azure monitoring, we face some of the same techniques as we do for AWS monitoring. It can become a bit daunting if we dive into customization, but setting up the initial monitoring is a lot easier than it looks. Let’s check it out:

  1. With Azure monitoring, first we are going to need to set up our authentication correctly. To do so, navigate to portal.azure.com and log in.
  2. In the search bar, search for Enterprise applications and select it from the list. Click on New application:
Figure 13.17 – Azure enterprise application creation

Figure 13.17 – Azure enterprise application creation

  1. Then click on Create your own application:
Figure 13.18 – Azure enterprise application creation – creating your own application

Figure 13.18 – Azure enterprise application creation – creating your own application

  1. This is where we have to name our application. Name it something appropriate, as seen in the following screenshot:
Figure 13.19 – Azure enterprise application creation – setting the name of your application

Figure 13.19 – Azure enterprise application creation – setting the name of your application

  1. Then click Create at the bottom of the page to finish creating a new empty application. It will show you the application ID on this page. Make sure to write it down as we will need it later:
Figure 13.20 – Azure enterprise application overview page

Figure 13.20 – Azure enterprise application overview page

  1. With the application created, let’s immediately dive into setting up the credentials for it. To do so, use the Azure search bar at the top and search for Azure Active Directory, then select it from the list.
  2. In the left-hand sidebar, you should see App registrations. We are going to create a new registration, so click on New registration:
Figure 13.21 – Azure enterprise application – App registrations

Figure 13.21 – Azure enterprise application – App registrations

  1. Simply give your registration a new name and keep the rest of the settings as the default:
Figure 13.22 – Azure enterprise application – new app registration

Figure 13.22 – Azure enterprise application – new app registration

  1. Click Register to finish this registration. This will redirect you to your newly created registration.
  2. Now let’s add the authentication. Go to Certificates & secrets in the left-hand sidebar.
  3. We’ll create a new client secret here. To do so, click on New client secret:
Figure 13.23 – Azure enterprise application – app registration secrets

Figure 13.23 – Azure enterprise application – app registration secrets

  1. All we have to do now is name the secret and set an expiry time period. Keep in mind that a shorter expiry means more administrative overhead. Faster expiry could mean better security as there is less time to potentially leak (or use once leaked) the secrets:
Figure 13.24 – Azure enterprise application – app registration secret creation

Figure 13.24 – Azure enterprise application – app registration secret creation

  1. Now click on Add to finish setting up the new secret. It will show you the values once. Make sure to store them somewhere safe, such as in a password vault:
Figure 13.25 – Azure enterprise application secrets

Figure 13.25 – Azure enterprise application secrets

  1. With the authentication out of the way, there is only one thing left to do. We need to provide the correct permissions to this new enterprise application. To do so, search for Subscriptions in the Azure search bar at the top of the page.
  2. For things such as Azure virtual machine and database instance monitoring, you will need to assign (read) permissions to your entire subscription. Find the subscription where your resources are located. Mine is called OICTS Azure:
Figure 13.26 – Azure subscriptions

Figure 13.26 – Azure subscriptions

  1. Now is also a great time to write down the subscription ID, as we will need it in a later step!
  2. Select your subscription, and then from the list, select Access control (IAM). Then, click on Add role assignment.
Figure 13.27 – Azure subscription – role assignment

Figure 13.27 – Azure subscription – role assignment

  1. On the next page, select the Reader role from the list and then press Next.
  2. At the Members part of the creation process, click on + Select members. We’ll add the Zabbix book monitoring member. It will look as follows:
Figure 13.28 – Azure subscription – role assignment members

Figure 13.28 – Azure subscription – role assignment members

  1. Now click on Review + assign and the permissions will be added.
  2. There’s one more thing to do in the Azure portal. In the search bar at the top of the page, type in Tenant properties and select it from the list. On this page, make sure to note down the tenant ID as we will need it shortly.
  3. With the application set up, the authentication created, and the permissions assigned, let’s move on to the Zabbix frontend. Navigate to Data collection | Hosts and create a new host by clicking on Create host in the top-right corner:
Figure 13.29 – Azure tenant properties

Figure 13.29 – Azure tenant properties

  1. Create the following host, with the name lar-book-azure, the Azure by HTTP template, and a host group such as Cloud:
Figure 13.30 – New Azure monitoring host in Zabbix

Figure 13.30 – New Azure monitoring host in Zabbix

  1. Before adding the host, switch to the Macros tab:
Figure 13.31– New Azure monitoring host macros in Zabbix

Figure 13.31– New Azure monitoring host macros in Zabbix

We will have to add at least the following macros here:

  • For {$AZURE.APP.ID}, fill in the application ID from step 5.
  • For {$AZURE.PASSWORD}, fill in the value under the Value column from step 13.
  • For {$AZURE.SUBSCRIPTION.ID}, fill in the subscription ID from step 15.
  • For {$AZURE.TENANT.ID}, fill in the tenant ID from step 22.
  1. That’s it; you can now add the new host by clicking on the Add button.
  2. After the discovery rule runs for the first time, your discovered instances will be added as new hosts, as you can see in the following screenshot:
Figure 13.32 – New Azure-discovered virtual machine

Figure 13.32 – New Azure-discovered virtual machine

That’s it, your automated Azure monitoring is now working as expected. Let’s have a look at how it works.

How it works…

If you’ve followed the recipe on AWS monitoring, you might think that Azure monitoring works in the exact same way. To an extent, that is true; the monitoring is completely based on API calls made from Zabbix toward the Azure API.

What is different between AWS and Azure is of course going to be the JavaScript scripts used in the Zabbix items on the templates.

The templates provided by Zabbix 7.0 out of the box use a fairly extensive piece of JavaScript code to execute API calls toward Azure, parse through the received data, and then put that into a JSON array that Zabbix low-level discovery understands.

Looking at the template found at Data collection | Templates and then opening Discovery for the Azure by HTTP template, we can see six discovery rules.

Figure 13.33 – Azure by HTTP discovery rules

Figure 13.33 – Azure by HTTP discovery rules

These six rules discover the different types of Azure database instances and virtual machines and use host prototypes to create a new host for each instance found. The only difference here is that storage accounts won’t use host prototypes but item prototypes to supply you with information. The hosts created by host prototypes will then in turn use their own templates to get the actual statistics from those instances or buckets, as we can see in the template list:

Figure 13.34 – The other Azure templates in Zabbix 7.0

Figure 13.34 – The other Azure templates in Zabbix 7.0

In my case, only one virtual machine was discovered, and as such, that host was added with the Azure Virtual Machine by HTTP template, as seen in Figure 13.32.

All of the information is then collected by Script item types with their own unique JavaScript code. We can see a piece of the code in the following screenshot, where we make a call to Azure to a specific URL (underlined):

Figure 13.35 – Azure template call

Figure 13.35 – Azure template call

It is also possible to edit this JavaScript code to create entirely new calls to retrieve your own data and create different types of monitoring, as well as simply extending the out-of-the-box templates.

There’s more…

We can discover way more from Azure using the method applied in this recipe. The JavaScript we employ is used to get metrics from Azure, which can be edited to gather almost any metric from the Azure API.

Check out the Azure API documentation for more information on the metrics retrieved using JavaScript:

https://learn.microsoft.com/en-us/rest/api/azure/

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image