Scripts by boyney123

AWS Log Group: Quickly search and open log groups

Hey @johnlindquist

I created a quick script that allows me to search and open up log groups quickly.

I spent a fair amount of time doing this, so thought I would help myself out.

If anyone else is interested script is here:

// Menu: AWS Log Group
// Description: Quickly find and open your log groups
// Author: David Boyne
// Twitter: @boyney123
const AWS = await npm('aws-sdk');
const { format } = await npm('date-fns');
const region = await env('AWS_REGION');
AWS.config.update({ region: region });
var cloudwatchlogs = new AWS.CloudWatchLogs();
cloudwatchlogs.describeLogGroups({ logGroupNamePrefix: '/aws/' }, async function (err, data) {
if (err) inspect(err);
// an error occurred
else {
// await inspect(data); // successful response
const groups ={ logGroupName, creationTime, retentionInDays }) => ({
name: logGroupName,
value: logGroupName,
html: `<div>
<div style="font-size:10px; padding:0; margin:0;">
Created ${format(new Date(creationTime), 'yyyy-MM-dd')} | Retention ${retentionInDays} days
<div style="font-size:14px; font-weight:bold;">${logGroupName}</div>
const logGroup = await arg('Search for a log group:', groups);
const url = `https://${region}${region}#logsV2:log-groups/log-group/${encodeURIComponent(logGroup)}`;
exec(`open ${url}`);

To get working and still left to do

  • Make sure your AWS access keys and tokens are in the .env file.
  • Use the API to loop over the log groups it only returns 50 at the moment, but easy enough to do if thats a problem for anyone.
Discuss Post