Skip to content

Consolidate Run Command results into a CSV

0

Hi,

I would like to consolidate Run Command error results into a CSV.

The configuration is as follows: Run Command error → EventBridge → Lambda → CSV output to S3

In this case, I would like to use the following specifications. A. CSV is one file per month and is updated daily. B. Count the last success date and the number of failures in the month for each instance.

Example

On success: on 5/1, create a new csv and fill in the results of 5/1 May, 2024.csv

instanceid lastsuccess errorcount
i-xxxxx May, 1 0
i-yyyyy 1
:
:

On failure: Update csv to 5/2 and fill in the result of 5/2 May, 2024.csv

instanceid lastsuccess errorcount
i-xxxxx May, 1 1
i-yyyyy May, 2 1
:
:

On success: Update csv to 5/3 and fill in the result of 5/3 May, 2024.csv

instanceid lastsuccess errorcount
i-xxxxx May, 3 1
i-yyyyy May, 2 2
:
:

Is this possible? I need to determine if the CSV in S3 is updated and especially if the instance id is the same. We are concerned about the process of specifying a row in the CSV and updating it.

Best Regards,

2 Answers
4
Accepted Answer

Hi,

Yes, you are right it is possible to achieve your desired outcome with the Run Command error -> EventBridge -> Lambda -> S3 configuration.

Lambda function triggered by Run Command errors:

  1. Gets error details (instance ID, timestamp).

  2. Checks if monthly CSV exists in S3 (May, 2024.csv).

Write CSV to S3: Use the S3 SDK to write the updated CSV data back to the S3 object with the appropriate filename (e.g., May, 2024.csv).

On Success:

Updates existing row (instance ID):

  1. Sets lastsuccess to current date.

On Failure:

Updates existing row (instance ID):

    1. Increments errorcount.

New instance? Create new row:

  1. Add instance ID, current date as lastsuccess, errorcount as 1. Always writes updated data back to monthly CSV in S3.

This keeps one CSV per month, updated daily with success dates and error counts.

EXPERT
answered 2 years ago
EXPERT
reviewed 2 years ago
0

Thank you very much. I was able to realize it.

answered 2 years 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.