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:
- Uses of Grafana
- Azure Monitor Data Source For Grafana
- Install Grafana on macOS
- Installing the Plugin on an Existing Grafana with the CLI
- Installing the Plugin Manually on an Existing Grafana
- Grafana Data Source Configuration
- Importing a Dashboard from the Grafana Dashboard
Uses Of Grafana
- 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.
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
Start Grafana using Home-brew services:
brew services start grafana
To upgrade Grafana, use the reinstall command:
brew update
brew reinstall grafana
Installing The Plugin On An Existing Grafana With The CLI
Grafana comes with a command-line tool that can be used to install plugins.
- Upgrade Grafana to the latest version.
- Run this command: grafana-cli plugins install grafana-azure-monitor-datasource
- Restart the Grafana server.
- Open the browser at http://localhost:3000 or http://your-domain-name:3000
- Login in with a user that has admin rights. This is needed to create data sources.
- 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.
Installing The Plugin Manually On An Existing Grafana
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.
- Upgrade Grafana to the latest version.
- Get the zip file from Grafana.com and click on the link in step 1.
- Extract the zip file into the data/plugins subdirectory for Grafana.
- Restart the Grafana server
- 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.
- Guide to setting up an Azure Active Directory Application for Azure Monitor.
- Guide to setting up an Azure Active Directory Application for Azure Log Analytics.
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:
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:
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:
Step 9: Test that the configuration details are correct by clicking on the “Save & Test” button:
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"
Once after all the details are passed on, we need to click on Save & Test and we must get this output below :
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.
Step 2: Filter the Data Source as Azure monitor since we have used that as our Data Source.
Step 3: We can see these are the major reviewed and downloaded ones, so we can use this on our project.
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.
Step 6: After importing we can see the Dashboard and its corresponding Data Source.
Step 7: Now we can click on the Dashboard and then we can check the output from it.
Step 8: Here is the output of the same for the Azure VM’s that are monitored by the Azure monitor.
Step 9: Here is the output for the same for the Mongo DB monitored by the Azure monitor.
Similarly, we have many Data sources and we can make use of this Grafana as much as we can.
Here are some of the examples of the Grafana Dashboards.
Related/References
- [AZ-400] Microsoft Azure DevOps Certification Exam: Everything You Need To Know
- [AZ-400] Azure DevOps Certification Path
- [AZ-400] Roles And Responsibilities As An Azure DevOps Engineer
- [AZ-400] Microsoft Azure DevOps Training: Step By Step Activity Guides/Hands-On Lab Exercise
- [AZ-400] Azure DevOps Services for Beginners
- [AZ-400] Designing and Implementing Microsoft DevOps Solutions [Official Page]
- Azure DevOps Service Hooks | Subscription Of Service Hooks | Release Approvals
- SonarCloud Azure DevOps | Integrating SonarCloud In Azure
- Azure DevOps Environments | How To Setup DevOps Environment | Approval Checks | Azure DevOps Pipeline
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!
The post [AZ-400] Monitor Azure With Grafana appeared first on Cloud Training Program.