By using AWS re:Post, you agree to the Terms of Use

How to get MONTHLY cpu metrics using AWS Lambda?


Hi, I'm running EC2 instance and every month I get CPU usage when I need to. But from now on, I want get CPU usgage every month using AWS Lambda. and my question is, how to set up a monthly date to get monthly usage of CPU?

appearently this is what I wrote at Lambda to get exact month for CPU usage.

"start": "2022-06-30T15:00:00.000Z",

"end": "2022-07-31T14:59:59.000Z",

And I want to make it Monthly. How should I fix it?

1 Answer


You can make use of the EventBridge in order to schedule the lambda function to run every month using a cron expression.


You can configure an event bridge rule that will schedule the lambda function to run every month to obtain the CPU metrics of your EC2 instance. This can be done by following the below steps:

➞ Open the Functions page on the Lambda console and choose the lambda function.

➞ Under Function Overview, click on Add trigger.

➞ Set the trigger type to EventBridge (CloudWatch Events).

➞ For Rule, select Create a new rule, and then provide the rule name and rule description.

➞ For rule type, choose Schedule expression.

➞ In the Schedule expression field, enter a cron expression. For example, to run the function at 8 AM UTC on the first day of every month, you can use cron(0 8 1 * ? *)


You can find more information on how to write cron expressions in the below document:


Please note that you would have to configure the lambda function code such that it is able to obtain the CPU usages of the EC2 instance.

answered 15 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions