Reader small image

You're reading from  Developing Modern Database Applications with PostgreSQL

Product typeBook
Published inAug 2021
PublisherPackt
ISBN-139781838648145
Edition1st Edition
Right arrow
Authors (2):
Dr. Quan Ha Le
Dr. Quan Ha Le
author image
Dr. Quan Ha Le

Dr. Quan Ha Le graduated with a Ph.D. in computer science from the Queen's University of Belfast, United Kingdom, in 2005. Since his Ph.D. graduation, he has been working as a PostgreSQL database administrator all over Alberta and Ontario, Canada, until now. From 2008 to 2019, Dr. Le Quan Ha administered, designed, and developed 24 small, medium, large, and huge PostgreSQL databases in Canada. Since 2016, after writing a good publication on PostgreSQL database clusters on clouds, he has been a member of the United States PostgreSQL Association (PgUS) in New York City. Dr. Le Quan Ha has also been a board member of the PgUS Diversity committee since 2018.
Read more about Dr. Quan Ha Le

Marcelo Diaz
Marcelo Diaz
author image
Marcelo Diaz

Marcelo Diaz is a software engineer with more than 15 years of experience, with a special focus on PostgreSQL. He is passionate about open source software and has promoted its application in critical and high-demand environments where he has worked as a software developer and consultant for both private and public companies. He currently works very happily at Cybertec and as a technical reviewer for Packt Publishing. He enjoys spending his leisure time with his daughter, Malvina, and his wife, Romina. He also likes playing football.
Read more about Marcelo Diaz

View More author details
Right arrow
High-Performance Team Dashboards Using PostgreSQL and New Relic

In this chapter, you will learn how to install and activate PostgreSQL integration and will gain an understanding of the data collected by the New Relic infrastructure. New Relic PostgreSQL on-host integration receives and sends inventory metrics from our PostgreSQL database to the New Relic platform, where we can aggregate and visualize key performance metrics. Data about the level of instances, databases, and clusters can help us to more easily monitor our PostgreSQL database. You will learn how to use New Relic to monitor a PostgreSQL RDS and you will be able to access, visualize, and troubleshoot entire PostgreSQL databases for yourself – and your software team. 

With the help of the project demonstrated in this chapter, we will create a New Relic monitoring dashboard for the PostgreSQL 12...

Technical requirements

This chapter will take developers around 6-8 hours of work to create a New Relic monitoring dashboard for the PostgreSQL 12 RDS. For this chapter, you only need a PostgreSQL RDS and a stable internet connection because New Relic is an online dashboard from the web.

Signing up for and installing New Relic

New Relic supplies a high-performance team dashboard for various systems, such as the following:

  • Backend, frontend, and mobile applications
  • Cloud and platform technologies
  • Host operating systems
  • Log ingestion
  • Infrastructure
  • Open source monitoring systems

We can plug New Relic into different cloud platforms such as Amazon Web Services (AWS), Microsoft Azure, and Google Cloud Platform. Hence, obviously, New Relic installation for a PostgreSQL RDS from AWS is a typical application of New Relic.

You can access New Relic through your browser, and we will learn how to make a New Relic dashboard by taking the following steps:

  1. In a browser, open the New Relic website: https://infrastructure.newrelic.com/.
  1. Next, you need to sign in. If you do not have an account, you can register with New Relic by clicking on Create a free account:

Figure 9-1. New Relic login
  1. Enter the required information into the New Relic registration form as shown in Figure...

Defining PostgreSQL role permissions

AWS uses the Identity and Access Management (IAM) service to enable you to grant access to AWS services and resources. With IAM, you can create a new role using permissions to allow New Relic access to AWS resources. Therefore, you need to open two tabs at the same time on your browser for both AWS and New Relic, then you have to copy values from your New Relic account into the AWS IAM service.

The following are the steps to create an IAM policy: 

  1. Now we will link the New Relic user account to the PostgreSQL RDS. In Step 1 on the New Relic page called Trust, remember to copy the details on the page and open a new browser window/tab for AWS. You will then switch between the two browser windows – the browser window of New Relic and the browser window of AWS:

Figure 9-12. The first step – trust
  1. In the second browser window, please sign in and navigate to the AWS Management Console using this linkhttps://console...

Configuring New Relic for PostgreSQL

Now it is time to provide your AWS account details for New Relic. Once New Relic connects to your AWS RDS service using these details, because you have already set up IAM role permissions to authorize New Relic, the New Relic dashboard will be able to launch: 

  1. Switch to the New Relic window and click on Next to move on to the next step, Account Details, in the New Relic browser:

Figure 9-29. Step 5 Account Details

In Figure 9-30, we added the AWS account name in New Relic, and then for the IAM Role ARN, we have to find the correct values from the AWS window.

  1. Switch to the AWS window and click on the My Account drop-down field to get the AWS account details for New Relic as shown in Figure 9-30:

Figure 9-30. AWS account page
  1. Copy the account name as shown in Figure 9-31:

Figure 9-31. AWS My Account page
  1. In the New Relic window, click Next to proceed to step 6, which is Select Services:

Figure...

Adding new metric data for PostgreSQL

The Metric API is a way to get metric data from AWS PostgreSQL RDS into New Relic dashboards. A metric means a numeric measurement of an application, a system, or a database. Metrics are typically reported on a regular schedule. There are two types of metrics:  

  • Aggregated data: the rate of some event per minute
  • A numeric status at a moment in time: for example, the CPU% used status

Metrics are a strong solution for monitoring dashboards. The metrics that are used in New Relic are as follows:

  • readIops: This measures the average number of disk I/O operations per second.
  • writeIops: This measures the average number of disk I/O operations per second.
  • databaseConnections: This measures the number of connections to an instance.
  • cpuUtilization: This measures the percentage of CPU used by a DB instance.
  • readLatency: This measures the average amount of time taken per disk I/O operation, in seconds.
  • writeLatency:&...

Infrastructure inventory data collection

Each AWS service also has its own parameters and values defined by AWS settings. New Relic calls the AWS parameters as an infrastructure inventory data collection. So New Relic will also show the resource parameters on the dashboards so that the system administrator can easily look for the AWS settings and values directly in New Relic.

The RDS Inventory area is located at the end of the RDS dashboard of New Relic, as shown in Figure 9-40:

Figure 9-40. RDS Inventory

You can scroll right and left to see all of the inventory properties of the RDS. All of the property names and explanations are in the following table:

Name Description
awsRegion The AWS region that the instance was provisioned in.
dbInstanceIdentifier Contains a user-supplied database identifier. This identifier is the unique key that identifies a DB instance.
allocatedStorage Specifies the allocated storage size, in gibibytes.
autoMinorVersionUpgrade Indicates that minor...

Summary

In this chapter, we went through step-by-step PostgreSQL RDS database monitoring through New Relic, which is a popular DevOps tool. We learned how to register the Amazon RDS monitoring integration of New Relic. Going ahead, we learned how to prepare the IAM role for New Relic to collect PostgreSQL metrics. We also investigated the RDS dashboard of New Relic. Finally, we understood the metric data for PostgreSQL and learned how to read the RDS inventory data.

This chapter focused on PostgreSQL monitoring for high-performance teams. In the next chapter, we will move on to PostgreSQL database performance monitoring with PGBench and Apache JMeter. 

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Developing Modern Database Applications with PostgreSQL
Published in: Aug 2021Publisher: PacktISBN-13: 9781838648145
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.
undefined
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 $15.99/month. Cancel anytime

Authors (2)

author image
Dr. Quan Ha Le

Dr. Quan Ha Le graduated with a Ph.D. in computer science from the Queen's University of Belfast, United Kingdom, in 2005. Since his Ph.D. graduation, he has been working as a PostgreSQL database administrator all over Alberta and Ontario, Canada, until now. From 2008 to 2019, Dr. Le Quan Ha administered, designed, and developed 24 small, medium, large, and huge PostgreSQL databases in Canada. Since 2016, after writing a good publication on PostgreSQL database clusters on clouds, he has been a member of the United States PostgreSQL Association (PgUS) in New York City. Dr. Le Quan Ha has also been a board member of the PgUS Diversity committee since 2018.
Read more about Dr. Quan Ha Le

author image
Marcelo Diaz

Marcelo Diaz is a software engineer with more than 15 years of experience, with a special focus on PostgreSQL. He is passionate about open source software and has promoted its application in critical and high-demand environments where he has worked as a software developer and consultant for both private and public companies. He currently works very happily at Cybertec and as a technical reviewer for Packt Publishing. He enjoys spending his leisure time with his daughter, Malvina, and his wife, Romina. He also likes playing football.
Read more about Marcelo Diaz