Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
Set up a query-based alert by using MQL
2.1.
Create a Compute Engine instance
2.2.
Navigate to the Query Editor
2.3.
Perform a simple query and create a chart
2.4.
Set up a query-based alert
2.5.
Clean up
3.
Frequently asked questions
3.1.
What is called a cloud?
3.2.
What is the Cloud Controls Matrix?
3.3.
What is AWS?
3.4.
What is troubleshooting?
3.5.
For what Compute Engines are used?
4.
Conclusion
Last Updated: Mar 27, 2024

Monitoring of query language in Cloud Monitoring

Author Muskan Sharma
0 upvote
Master Python: Predicting weather forecasts
Speaker
Ashwin Goyal
Product Manager @

Introduction

We all have worked on Cloud. But have you ever wondered how to monitor a query language? 

Don't worry. Coding ninjas have got your back.

Let's explore how to monitor the query language in cloud monitoring.

Set up a query-based alert by using MQL

In this, you'll learn how to explore metrics, make charts, and set up a query-based alert using Monitoring Query Language (MQL).

Create a Compute Engine instance

Create a Compute Engine instance by completing the following steps to have a Google Cloud resource to get metrics from:

1.Choose Compute Engine from the menu on the Google Cloud console.

Compute Engine

2. Click Create after selecting Create instance.

Navigate to the Query Editor

Start by performing the following to use MQL:

1.Select Monitoring from the Google Cloud console menu.

2. Choose Metrics Explorer under Monitoring.

3. Choosing the MQL tab.

Metrics explorer

Perform a simple query and create a chart

Make a simple query that displays your instance's CPU usage:

1.In the Query Editor, copy the following query and past it

fetch gce_instance::compute.googleapis.com/instance/cpu/utilization
| {
    top 1, max(val())
  ;
    bottom 1, min(val())
  }
| union
Metrics explorer

2. Select Run Query. The graph shows the maximum and minimum CPU use for your instance on two lines:

3. Click Save Chart to store the chart. Give the chart a name and then add it to a dashboard that already exists or create a new one. 

Save Chart

Set up a query-based alert

You can design an alerting strategy that keeps track of a query's outcomes. Complete the following actions to develop such an alerting policy:

1.Pick Monitoring, then select Alerting from the console's menu.

2. Click Edit Notification Channels on the Alerting page. You set up an email address in this stage to receive alert messages.

  • Scroll down to Email on the Notification channels page and click Add.
  • In the Email Address area, type the email address where you want alert notifications sent.
  • In the Display name area, type a precise summary of this channel, such as "Alert on-call."
  • Click on Save.
  • By clicking Back on the page header, you can return to the Alerting page. 

3. Click on Create Policy on the Alerting page.

Create alerting policy

4. Click Add Condition to specify what you want the alert to be about. The form-based condition editor appears when this action is taken.

  • Clicking on code Query Editor will switch to the Query Editor window of the condition editor. The Query Editor and a Configuration pane are included in this version of the condition editor:
Query Editor

Source-Cloud Monitoring 

                   

  • Give your condition a name, e.g., "MQL Quickstart condition."
  • Enter the following command to receive a notification when the CPU utilization time for your instance exceeds 2 seconds:
fetch gce_instance::compute.googleapis.com/instance/cpu/usage_time
| window 1m
| condition val() > 2 's'
  • To view the chosen data and a threshold line, click Run Query.
  • Use the Condition pane as shown to receive an alert when your instance's CPU consumption reaches the threshold and persists there for five minutes:
  •  Set the For field's value to five minutes.
  •  Keep the value in the Condition triggers if the field is unchanged.
  • Click Add to save your condition in your alerting policy.

5. To go to the following step, which is creating notifications, click Next.

6. Click OK after selecting the notification channel you previously established.

7. In order to save your policy, click Save.

Clean up

Follow these instructions to prevent your Google Cloud account from being charged for the resources used on this page.

1.Go to the Google Cloud console's Identity and Access Management page.

Go to the Project Settings

2. After selecting Shut down, proceed as directed.

Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

Frequently asked questions

What is called a cloud?

The term "the cloud" describes the software and databases that run on servers that may be accessed via the Internet.

What is the Cloud Controls Matrix?

The Cloud Controls Matrix (CCM) from the Cloud Security Alliance is a tool created expressly to help potential cloud customers and cloud vendors analyze the overall security risk of a cloud provider.

What is AWS?

AWS (Amazon Web Service)  is an online platform that offers scalable and affordable cloud computing solutions.

What is troubleshooting?

A methodical method of problem-solving known as troubleshooting is frequently used to identify and resolve problems with sophisticated machinery, electronics, computers, and software systems.

For what Compute Engines are used?

The Google infrastructure can be used to build and run virtual machines using Compute Engine, a customized compute service.

Conclusion

This blog has extensively discussed Monitoring of query language in Cloud Monitoring and Setting up query-based alerts using MQL. We hope this blog has helped you in enhancing your knowledge about the Monitoring of query language in Cloud Monitoring. If you want to learn more, check out the excellent content on the Coding Ninjas Website:

Key concepts of cloud loggingManaging the Monitoring AgentIncidents in Cloud Monitoring, Introduction to JQuery

Refer to our guided paths on the Coding Ninjas Studio platform to learn more about DSA, DBMS, Competitive Programming, Python, Java, JavaScript, etc. 

Refer to the links problemstop 100 SQL problemsresources, and mock tests to enhance your knowledge.

For placement preparations, visit interview experiences and interview bundle.

Thank you

Do upvote our blog to help other ninjas grow. Happy Coding!

Previous article
Amazon ec2 instance with cloud monitoring
Next article
Concept of cloud datalab
Live masterclass