Silver Light and Blue Sky

C# and Infrastructure. Code is everything.

How to show AWS RDS metrics on NewRelic using C#

I'd like to introduce how to show AWS RDS metrics on NewRelic using C#. There is an Amazon RDS Plugin devloped by Ruby, but I have developed by C# because I want to customize components.

Here is a chat of this plugin. This plugin can show a metric (CPU usage in this case) of several instances.


Let's move on to the data structure of sending New Relic API.

Data structure of sending New Relic API has "Component > Metric", a parent and child relationship. A chart can show several metrics in the same components. It seems it cannot show several metrics over the different components at the same time. So I send each instance which I want to show the same chart as each metric under the same component. This means the name of metrics as shown below.

Component/RDS/[instance name of RDS]/[metric name of RDS Cloudwatch]

(sample) Component/RDS/production/CPUUtilization

Then you can get above chart when you set the Metric(s) property of NewRelic chart to "Component/RDS/*/CPUUtilization[Percent]".

Then here is a code. Please add Rx-Main, AWSSDK (2.0), JSON.NET to project references via Nuget. AWS AccessKey and SecretKey must be provided by AppConfig or constructor and LicenseKey and guid of NewRelic must be edited.


This code works as a ConsoleApp. It is executed every 60 seconds by Rx, and query to AWS cloud watch to get each metric and each RDS instance by one API call. We cannot get several metric or instances at one Cloudwatch API call. Then format the data to JSON and send it to NewRelic. The observing RDS instances are defined by calling AWS API. In this case, instance id contains "production".

You can confirm new plugin is added to your NewRelic dashboard after you start this code. And please add a chart and configure its property.

(This post is an English Translation of my original Japanese post.)