Multi-Cloud Monitoring at Simplilearn — Part I

Anurag Bapat
Simplilearn Engineering
7 min readSep 17, 2021
Photo by Luke Peters on Unsplash

Not enough eyes

Simplilearn infrastructure is hosted on multiple cloud providers — GCP, AWS and Azure which makes it difficult to monitor infrastructure from all the three clouds on a single interface.

Each cloud provider has their own native monitoring service :

  • GCP : Google Cloud Monitoring
  • Azure : Azure Monitor
  • AWS : CloudWatch

The traditional implementation of monitoring was daunting due to an increasing footprint of infrastructure that required constant maintenance, optimization and servicing.

In this first blog from multi-part series, we explain how to install and configure Grafana.

A New Approach

As a core monitoring system, Simplilearn aimed to bring all the native monitors under a single roof. Through a redesign of the architecture, keeping it in line with modern principles by adopting Grafana.

The metrics and telemetry data from all the cloud providers can be extracted using the native cloud APIs and visualized on Grafana using charts and graphs. This new architecture allowed us to create a dashboard , visualizing metrics of component deployed across multiple clouds providers as well as multiple accounts.

Installing Grafana

Grafana is an open-source, analytics, and monitoring platform that is tinkered for connection with a variety of sources like Elasticsearch, Influxdb, Graphite, Prometheus, AWS Cloud Watch, and many others. In this blog, we will share how to setup Grafana and integrate different cloud providers like GCP , Azure and AWS.

Launch an Ubuntu 20.04 server and update the package information.

sudo apt update

Note: Grafana can be installed on earlier versions of Ubuntu as well as other operating systems. Refer to the installation guide for Windows/MacOS installations.

Ensure that the dependencies for Grafana are installed.

sudo apt-get install -y adduser libfontconfig1

Now to download the binary, and run the Debian package manager.

wget https://dl.grafana.com/oss/release/grafana_8.1.1_amd64.debsudo dpkg -i grafana_7.1.3_amd64.deb

Note: Grafana is updated regularly. To see the list of releases available to download, visit https://github.com/grafana/grafana/tags

The install has now completed. You can now start the Grafana service.

sudo service grafana-server start

Check the status

sudo service grafana-server status

Note: If you reboot your server, the Grafana Service may not restart automatically. You can set the Grafana service to auto restart after reboot by entering,

sudo systemctl enable grafana-server.service

Open port 3000 on your Ubuntu server.

firewall-cmd — add-port=3000/tcp — permanentfirewall-cmd — reload

Congratulations, your Grafana server will be hosted at —

http://[your Grafana server IP]:3000

(http://localhost:3000 in case you’re using your local machine for the setup)

The default Grafana login credentials is :

Username : admin
Password : admin

Integrating Google Cloud Platform (GCP)

Grafana ships with built-in support for Google Cloud Monitoring. Google Stackdriver is a monitoring service that provides teams with performance data about applications and virtual machines.

Enable Monitoring

Click on the links below and click the Enable button:

https://console.cloud.google.com/apis/library/monitoring.googleapis.com

Setup a GCP service account and create an API key

  1. Navigate to the APIs and Services Credentials page.
  2. Click on the Create credentials dropdown/button and choose the Service account option.

3. On the Create service account key page, fill in the details and click on Create and Continue

4. In the next option select Monitoring Viewer role and click on Continue.

5. You can skip the next visible option and click on Done and a service account will be created.

6. Navigate to the Service Account.

  • Click on select Keys tab
  • Click on “ADD KEY” then “Create new key”
  • Select “JSON” and Create

A secret file will be downloaded. Now navigate to Grafana click on settings , add data source and select “Google Cloud Monitoring” to upload the downloaded file. Click on test and save.

Integrating Azure — Azure Monitor

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

Register an Application

  1. Open Azure App Directory in Azure Portal and Select App Registrations and click on New Registration .

2. Provide a name for the application and click on Register.

Assigning role for created Application

  1. Go to Subscriptions select the respective subscription and click on Access control (IAM). Then click on “Add” and “Add role assignment”.

2. Select Monitoring Reader role and type in the created application name and click on Save.

Generating Secret for created application.

  1. Open Azure App Directory and Select App Registrations and click on the created application.
  2. Copy the Client ID and Tenant ID.
  3. Click on Certificates & secrets and click on “New Client Secret”. Provide a name and click on “Add”. Copy the Value of the created secret.

Now navigate to Grafana click on settings -> add data source and select “Azure Monitor”. Enter the above saved secrets and click on “Save & test”.

Integrating Amazon Web Services (AWS)

Grafana ships with built-in support for CloudWatch. Add it as a data source, then you are ready to build dashboards or use Explore with CloudWatch metrics and CloudWatch Logs.

Create a new IAM Policy

  1. On the AWS console navigate to Services, Select IAM , click on Policies and Create Policy.

2. Select JSON and add the below JSON

{
"Version": "2012–10–17",
"Statement": [
{
"Sid": "AllowReadingMetricsFromCloudWatch",
"Effect": "Allow",
"Action": [
"cloudwatch:DescribeAlarmsForMetric",
"cloudwatch:DescribeAlarmHistory",
"cloudwatch:DescribeAlarms",
"cloudwatch:ListMetrics",
"cloudwatch:GetMetricStatistics",
"cloudwatch:GetMetricData"
],
"Resource": "*"
},
{
"Sid": "AllowReadingLogsFromCloudWatch",
"Effect": "Allow",
"Action": [
"logs:DescribeLogGroups",
"logs:GetLogGroupFields",
"logs:StartQuery",
"logs:StopQuery",
"logs:GetQueryResults",
"logs:GetLogEvents"
],
"Resource": "*"
},
{
"Sid": "AllowReadingTagsInstancesRegionsFromEC2",
"Effect": "Allow",
"Action": [
"ec2:DescribeTags",
"ec2:DescribeInstances",
"ec2:DescribeRegions"
],
"Resource": "*"
},
{
"Sid": "AllowReadingResourcesForTags",
"Effect": "Allow",
"Action": "tag:GetResources",
"Resource": "*"
}
]
}

3. After that, click on next, provide a name and click on “Create Policy”.

4. Once done, verify if the policy is created.

Creating a User

  1. Navigate to Services Select IAM , click on User and “Add user”. Provide a name and required permissions and click on next.

2. Select attach existing policy and add the policy created previously and click on next and create the user. Copy the Access ID and Access secret key.

Now navigate to Grafana. Click on settings and add data source. Select CloudWatch, enter the above saved secrets and click on “Save & test”.

This successfully adds the three cloud providers as data sources. This allows the Grafana server to use the APIs to retrieve time series and telemetry data to be further used for visualization.

List of data sources configured in Grafana

Conclusion

The objective of this article was to explain how to add multiple cloud providers to Grafana. After this initial setup we can start creating dashboards using the created data sources which shall be covered in the upcoming blog.

Keep an eye out on this space, as we will be coming out with next blog soon!

P.S. We will also be exploring using Prometheus to collect metrics from various sources and exporters which we will eventually visualize using Grafana dashboards.

We would love to hear from you on any other methods we could have used to solve this problem. Please feel free to leave your comments below.

--

--