Skip to content
10/04/2019
Tutorials

Monitoring AWS with Centreon

Blog Monitoring AWS with Centreon

In this tutorial, we’ll describe how Centreon can monitor the resources you’re deploying into the Amazon Web Services cloud platform.

Example of AWS Architecture – Copyright AWS Inc.

The Centreon solution includes multiple plugins to monitor AWS: one plugin per AWS service. At the time of writing, the following AWS services are included in the Centreon Plugin Library:

  • Billing
  • Cloudfront
  • Cloudwatch
  • EBS
  • Elasticache
  • ELB
  • Lambda
  • RDS
  • S3

Centreon’s Plugin Pack functionality, which facilitates configuring these plugins by providing ready-to-use Host Templates and Service Templates, are included in both Centreon IMP and Centreon EMS. Be sure to check the Centreon Documentation or the Integration page of our website to get the most up to date list of supported Plugin Packs.

ln this tutorial, we’ll use the following example: how do we monitor an AWS EC2 virtual machine?
We will first explain how Centreon connects to the Amazon CloudWatch service to collect metrics. We will then install the AWS EC2 Plugin and test it from the Command Line Interface to better understand how it’s working. Finally, we’ll explain how to use the Plugin Pack and easily start monitoring.

 

1. AWS API credentials and Amazon CloudWatch service

AWS provides a Rest API for all its cloud services. There is one API access per Amazon Region.

For the Centreon plugins to connect and authenticate with this API, an Access Key, consisting of an access key ID and a secret access key is needed. This AWS IAM documentation gives information about how to use the Identity and Access Management service to create the required credentials such as:

  • Amazon Region name (eg ‘us-east-2’)
  • Secret Key
  • Access Key

 

AWS includes its own monitoring service: CloudWatch. CloudWatch is a free service (for basic use) that collects performance metrics for all of your AWS resources. CloudWatch comes with its own API that Centreon plugins will query every five minutes. The free package allows up to 1 million requests per month, which should be plenty.

Please refer to the Amazon CloudWatch documentation for further information.

 

2. Installing and testing the AWS EC2 Centreon Plugin

Prerequisites

The Centreon AWS monitoring plugins require either the Perl paws library or the awscli command line to connect to the AWS Rest API. In this tutorial, we will use the awscli tool which we will install alongside the plugin.

Plugin Installation

The Centreon AWS plugins are open source. The Git repository can be found under the project centreon-plugins. To install the EC2 plugin, please use the packages provided by Centreon on a CentOS/RedHat 7.x operating system. This should be done on the poller that accesses the AWS API.

# yum install centreon-plugin-Cloud-Aws-Ec2-Api.noarch awscli

 

Testing the Plugin

It’s always a good practice to test the plugin from the CLI, at the minimum to verify our credentials grant access to the API. Please perform various tests to validate the proper operation of this plugin and to know more about its functionalities.

Please note that by default the plugin collects the average usage of your resources. But it’s also possible to get the minimum and maximum usage of your resources by using the –statistic option. For example, to get both the average and minimum usage metrics, you must add the following option in your command line:

--statistic=average --statistic=minimum

 

Test 1 – Get the EC2 instance list
$ /usr/lib/centreon/plugins/centreon_aws_ec2_api.pl --plugin=cloud::aws::ec2::plugin --custommode=awscli --region=eu-west-1 --aws-secret-key='cgDbAaBKpGSYphr8+RiWcvXAf3Y7QpT' --aws-access-key='AKIAIAHAQ7FJ7C3Q' --mode=list-instances 
List instances: 
[Name = i-f15afe17][AvailabilityZone = us-east-2b][InstanceType = t2.small][State = running][Tags = centreon-support]
[Name = i-06717f4d0eee337af][AvailabilityZone = us-east-2b][InstanceType = t2.micro][State = stopped][Tags = centreon-poc-ha-poller]
 

 

Test 2 – Check EC2 instance status

For this check, we need to give the name of the EC2 instance with –name option.

$ /usr/lib/centreon/plugins/centreon_aws_ec2_api.pl --plugin=cloud::aws::ec2::plugin --custommode=awscli --region=eu-west-1 --aws-secret-key='cgDbAaBKpGSYphr8+RiWcvXAf3Y7QpT' --aws-access-key='AKIAIAHAQ7FJ7C3Q' --mode=status --type=instance --name=i-f15afe17 --critical-status='%{status} =~ /failed/i'
OK: Instance 'i-f15afe17' StatusCheckFailed_Instance: passed, StatusCheckFailed_System: passed 

 

Test 3 – Check all CPU metrics of EC2 instance

Specify the name of the EC2 instance with –name option.

$ /usr/lib/centreon/plugins/centreon_aws_ec2_api.pl --plugin=cloud::aws::ec2::plugin --custommode=awscli --region=eu-west-1 --aws-secret-key='cgDbAaBKpGSYphr8+RiWcvXAf3Y7QpT' --aws-access-key='AKIAIAHAQ7FJ7C3Q' --mode=cpu --type=instance --name=i-f15afe17 
OK: Instance 'i-f15afe17' average CPUCreditBalance: 288.00, CPUCreditUsage: 0.02, CPUSurplusCreditBalance: 0.00, CPUSurplusCreditsCharged: 0.00, CPUUtilization: 0.37 % | 'cpucreditbalance_average'=288.00;;;; 'cpucreditusage_average'=0.02;;;; 'cpusurpluscreditbalance_average'=0.00;;;; 'cpusurpluscreditscharged_average'=0.00;;;; 'cpuutilization_average'=0.37%;;;;

Here is a short description of each metric (More details in this AWS documentation):

Metric Description
cpucreditbalance The number of earned CPU credits that an instance has accrued since it was launched or started.
cpucreditusage The number of CPU credits spent by the instance for CPU utilization.
cpusurpluscreditbalance The number of surplus credits that have been spent by an unlimited instance when its CPUCreditBalance value is zero.
cpusurpluscreditscharged The number of spent surplus credits that are not paid down by earned CPU credits, and which, then incur an additional charge.
cpuutilization The percentage of allocated EC2 compute units that are currently in use on the instance.

 

Test 4  – Check AWS EC2 network metrics

Specify the name of the EC2 instance with –name option.

$ /usr/lib/centreon/plugins/centreon_aws_ec2_api.pl --plugin=cloud::aws::ec2::plugin --custommode=awscli --region=eu-west-1 --aws-secret-key='cgDbAaBKpGSYphr8+RiWcvXAf3Y7QpT' --aws-access-key='AKIAIAHAQ7FJ7C3Q' --mode=network --type=instance --name=i-f15afe17 
OK: Instance 'i-f15afe17' average NetworkIn: 39.90KB, NetworkOut: 40.59KB, NetworkPacketsIn: 123.00 packets, NetworkPacketsOut: 117.40 packets | 'networkin_average'=40858.40B;;;; 'networkout_average'=41559.40B;;;; 'networkpacketsin_average'=123.00packets;;;; 'networkpacketsout_average'=117.40packets;;;;

Here is a short description of each metric (more details in this AWS documentation)

Metric Description
networkin The number of bytes received on all network interfaces by the instance.
networkout The number of bytes sent out on all network interfaces by the instance.
networkpacketsin The number of packets received on all network interfaces by the instance.
networkpacketsout The number of packets sent out on all network interfaces by the instance.

 

Test 5 – Check AWS EC2 disk metrics

Specify the name of the EC2 instance with –name option.

$ /usr/lib/centreon/plugins/centreon_aws_ec2_api.pl --plugin=cloud::aws::ec2::plugin --custommode=awscli --region=eu-west-1 --aws-secret-key='cgDbAaBKpGSYphr8+RiWcvXAf3Y7QpT' --aws-access-key='AKIAIAHAQ7FJ7C3Q' --mode=diskio --type=instance --name=i-f15afe17
OK: Instance 'i-f15afe17' average DiskReadBytes: 0.00B, DiskWriteBytes: 0.00B, DiskReadOps: 0.00 ops, DiskWriteOps: 0.00 ops | 'diskreadbytes_average'=0.00B;;;; 'diskwritebytes_average'=0.00B;;;; 'diskreadops_average'=0.00ops;;;; 'diskwriteops_average'=0.00ops;;;;

Here is a short description of each metric (More detail this AWS documentation):

Metric Description
diskreadbytes Bytes read from all instance store volumes available to the instance.
diskwritebytes Bytes written to all instance store volumes available to the instance.
diskreadops Completed read operations from all instance store volumes available to the instance in a specified period of time.
diskwriteops Completed write operations to all instance store volumes available to the instance in a specified period of time.

 

3. Installing and using the AWS EC2 Centreon Plugin Pack

Plugin Packs Manager is the name of the Centreon user interface by which you can list, download and update from our 300+ (and counting) Centreon Plugin Packs.

From the Configuration > Plugin Packs > Manager user interface, search for aws:

On the Centreon Plugin Pack Manager user interface:
  • Install the  AWS EC2 pack by clicking on the ‘+’ button
  • As usual, the ‘?’ button will automatically redirect to the relevant Monitoring Procedure, including how to install the relevant Plugin

If the installation has been completed properly, you should find the host template Cloud-Aws-Ec2-Instance-Custom in the Configuration > Hosts > Templates menu.

To monitor our AWS EC2 instance, we need to create a new host in Centreon with the following parameters:

  • IP Address / DNS: localhost
  • Host Template: Cloud-Aws-EC2-Instance-custom;
  • Macros AWSSECRETKEY, AWSACCESSKEY and AWSREGION: your AWS API credentials
  • Macro AWSINSTANCENAME: your instance name (eg i-f15afe17)

 

  • Make sure you check the option to Create Services linked to the Template too: this will automatically create and configure the 5 Services defined by the Service Templates included in the Plugin Pack:
    • Cloud-Aws-Ec2-Cpu-Credit-Api for CPU credits usage metrics
    • Cloud-Aws-Ec2-Cpu-Usage-Api for CPU usage metrics
    • Cloud-Aws-Ec2-Diskio-Api for disks I/O utilization metrics
    • Cloud-Aws-Ec2-Network-Api for network usage metrics
    • Cloud-Aws-Ec2-Status-API for internal checks status metrics

You are now ready to generate the configuration, export it and send it to the Poller:

You are now able to verify Centreon is collecting metrics for your EC2 instance in the  Monitoring> Status Details> Hosts user interface:

Done! Your Centreon platform is now monitoring your AWS EC2 virtual machine.

Tip : the  Configuration> Hosts> Templates user interface let’s you modify the Cloud-Aws-Ec2-Instance-Custom template to save the credentials in the relevant macro. You are also able to create one such template by AWS Region.

 

4. What’s next?

From there on, you can start using the Centreon AWS Plugin Packs and plugins to monitor your complete AWS infrastructure. You will now be able to build your infrastructure and applications by using the following tools: Center for Dashboards, MAP for graphical dashboards and MBI for weekly and monthly analytics reports.

 

Real-time AWS infrastructure monitoring with Centreon MAP

 

Visit our Plugin Packs Library!  300+ standard industry IT domains already addressed: networks, servers, applications, storage, database, devices, equipment, etc. – physical, virtual and hybrid infrastructures.

More tutorials:

 

Share

Facebook picto Twitter picto Twitter picto

Similar posts

Ready to see how Centreon can transform your business?

Keep informed on our latest news