Quantcast
Channel: Cloud Training Program
Viewing all articles
Browse latest Browse all 1891

[AZ-400] Monitor Azure With Grafana

$
0
0

This blog gives a hands-on overview of Grafana, a tool that allows you to query, visualize, alert on, and understand your metrics no matter where they are stored. Create, explore, and share dashboards with your team and foster a data-driven culture.

This blog talks about technologies that are part of the Azure DevOps environment. If it’s something in which you have an interest or you want to learn it then you can visit our previous blog to know more about the [AZ-400] Microsoft Azure DevOps certification.

In this blog we will be covering:

  1. Uses of Grafana
  2. Azure Monitor Data Source For Grafana
  3. Install Grafana on macOS
  4. Installing the Plugin on an Existing Grafana with the CLI
  5. Installing the Plugin Manually on an Existing Grafana
  6. Grafana Data Source Configuration
  7. Importing a Dashboard from the Grafana Dashboard

Grafana dashboard

  • Visualize → Fast and flexible visualizations with a multitude of options allow you to visualize your data any way you want.
  • Dynamic Dashboards → Create dynamic & reusable dashboards with template variables that appear as dropdowns at the top of the dashboard.
  • Explore Metrics → Explore your data through ad-hoc queries and dynamic drill-down. Split view and compare different time ranges, queries, and data sources side by side.
  • Explore Logs → Experience the magic of switching from metrics to logs with preserved label filters. Quickly search through all your logs or streaming them live.
  • Alerting → Visually define alert rules for your most important metrics. Grafana will continuously evaluate and send notifications to systems like Slack, PagerDuty, VictorOps, OpsGenie.
  • Mixed Data Sources → Mix different data sources in the same graph! You can specify a data source on a per-query basis. This works for even custom data sources.
  • Annotations → Annotate graphs with rich events from different data sources. Hover over events shows you the full event metadata and tags.
  • Ad-hoc Filters → Ad-hoc filters allow you to create new key/value filters on the fly, which are automatically applied to all queries that use that data source.

Graphana charts

Azure Monitor Data Source For Grafana

Azure Monitor is the platform service that provides a single source for monitoring Azure resources. Application Insights is an extensible Application Performance Management (APM) service for web developers on multiple platforms and can be used to monitor your live web application — it will automatically detect performance anomalies.

The Azure Monitor Data Source plugin supports Azure Monitor, Azure Log Analytics, and Application Insights metrics in Grafana.

Features

  • Support for all the Azure Monitor metrics
  • includes support for the latest API version that allows multi-dimensional filtering for the Storage and SQL metrics.
  • Automatic time grain mode which will group the metrics by the most appropriate time grain value depending on whether you have zoomed in to look at fine-grained metrics or zoomed out to look at an overview.
  • Application Insights metrics
  • Write raw log analytics queries, and select x-axis, y-axis, and grouped values manually.
  • Automatic time grain support
  • Support for Log Analytics (both for Azure Monitor and Application Insights)
  • You can combine metrics from both services in the same graph.

Install Grafana On MacOS

Before you begin, you must have Home-brew installed on your mac machine.

1. On the Grafana download page, select the Grafana version you want to install.

2. Select an Edition.

  • Open Source — Functionally identical to the enterprise version, but you will need to download the enterprise version if you want enterprise features.
  • Enterprise — Not currently available for Mac.

3. Click Mac.

4. Copy and paste the code from the installation page into your command line and run. It follows the pattern shown below.

brew update
brew install grafana

Start Grafana using Home-brew services:

brew services start grafana

To upgrade Grafana, use the reinstall command:

brew update
brew reinstall grafana

Grafana comes with a command-line tool that can be used to install plugins.

  1. Upgrade Grafana to the latest version.
  2. Run this command: grafana-cli plugins install grafana-azure-monitor-datasource
  3. Restart the Grafana server.
  4. Open the browser at http://localhost:3000 or http://your-domain-name:3000
  5. Login in with a user that has admin rights. This is needed to create data sources.
  6. To make sure the plugin was installed, check the list of installed data sources. Click the Plugins item on the main menu. Both core data sources and installed data sources will appear.

If the server where Grafana is installed has no access to the Grafana.com server, then the plugin can be downloaded and manually copied to the server.

  1. Upgrade Grafana to the latest version.
  2. Extract the zip file into the data/plugins subdirectory for Grafana.
  3. Restart the Grafana server
  4. To make sure the plugin was installed, check the list of installed data sources. Click the Plugins item on the main menu. Both core data sources and installed data sources will appear.

Configure The Data Source

The plugin can access metrics from both the Azure Monitor service and the Application Insights API. You can configure access to one service or both services.

Step 1: Accessed from the Grafana main menu, newly installed data sources can be added immediately within the Data Sources section. Next, click the “Add data source” button in the upper right. The data source will be available for selection in the Type select box.

Step 2: Select Azure Monitor from the Type dropdown:

adding data source

Step 3: In the name field, fill in a name for the data source. It can be anything. Some suggestions are Azure Monitor or App Insights.

Step 4: If you are using Azure Monitor, then you need 4 pieces of information from the Azure portal (see link above for detailed instructions):

  • Tenant Id (Azure Active Directory -> Properties -> Directory ID)
  • Subscription Id (Subscriptions -> Choose subscription -> Overview -> Subscription ID)
  • Client Id (Azure Active Directory -> App Registrations -> Choose your app -> Application ID)
  • Client Secret ( Azure Active Directory -> App Registrations -> Choose your app -> Keys)

Step 5: Paste these four items into the fields in the Azure Monitor API Details section:

Monitor API details

Step 6: If you are also using the Azure Log Analytics service, then you need to specify these two config values (or you can reuse the Client Id and Secret from the previous step).

  • Client Id (Azure Active Directory -> App Registrations -> Choose your app -> Application ID)
  • Client Secret ( Azure Active Directory -> App Registrations -> Choose your app -> Keys -> Create a key -> Use client secret)

Step 7: If you are are using Application Insights, then you need two pieces of information from the Azure Portal (see link above for detailed instructions):

  • Application ID
  • API Key

Step 8: Paste these two items into the appropriate fields in the Application Insights API Details section:

Application Insight Details

Step 9: Test that the configuration details are correct by clicking on the “Save & Test” button:

Grafana Application check

Alternatively, on step 4 if creating a new Azure Active Directory App, use the Azure CLI:

az ad sp create-for-rbac -n "http://localhost:3000"

Grafana Azure ConfigurationAzure as source for Grafana
Once after all the details are passed on, we need to click on Save & Test and we must get this output below :
Grafana connection test

Importing A Dashboard From The Grafana Dashboard

Step 1: Click on the below website and then choose the Dashboards and we can choose any template that we wanted to do so.

Grafana dashboard marketplace

Step 2: Filter the Data Source as Azure monitor since we have used that as our Data Source.

Grafana datasource filterStep 3: We can see these are the major reviewed and downloaded ones, so we can use this on our project.

Azure options for grafana

Step 4: Click on any of these and then download the JSON file as export.

Step 5: Now we need to login to Grafana Dashboard and then we need to click on the Dashboard section and import the JSON file which we downloaded.

New Grafana Dashboard

Step 6: After importing we can see the Dashboard and its corresponding Data Source.

Dashboard import

Dashbourd import settings

Step 7: Now we can click on the Dashboard and then we can check the output from it.

Starred Dashboards

Step 8: Here is the output of the same for the Azure VM’s that are monitored by the Azure monitor.

Grafana dashboard demo

Step 9: Here is the output for the same for the Mongo DB monitored by the Azure monitor.

Azure MongoDB Monitor

Similarly, we have many Data sources and we can make use of this Grafana as much as we can.

Configuration

Add Data source

Logging And Document database

Monitoring Options

Here are some of the examples of the Grafana Dashboards.

Dashboard Examples

Related/References

Next Task For You

Begin your journey towards becoming a Microsoft [AZ-400] Certified Azure DevOps Engineer and earning a lot more in 2020 by joining our FREE Class.

Click on the image below to Register for the Free Class Now!Masterclass AZ-400

The post [AZ-400] Monitor Azure With Grafana appeared first on Cloud Training Program.


Viewing all articles
Browse latest Browse all 1891

Trending Articles