AWS Cloudwatch Log Scroller

AWS Cloudwatch Log Scroller

This is a quick tip about a quick solution to a regular small problem! AWS CloudWatch logs are great, but the search feature on those logs is not. The search only lists the lines that are exact match to your search term. Usually you would want to see a few lines above or below the match as well! Not all logs are single line, unless you spend efforts in ensuring that there are no newlines in the content being logged out. And so, every so often you have resort to ‘scrolling’ through the logs.

The logs load dynamically on scroll of the mouse wheel, and it is tedious (read ‘irritating’) to keep spinning the mouse wheel to scroll through those logs, especially the ECS container logs. So here is a little script which does that for you. Run this in your browser console and specify it the number of times it should run, and done. It does the scroll action, waits for the page to load (fixed) and scrolls again till it has scrolled for the times you specified.

You can also stop the scroll in between by calling clearTimeout on the timer.

Here it is:

Disclaimer: This is still not the best solution for long running tasks / huge log files, you are limited by the load times anyway. This only takes the need for manually scrolling through logs where you would have otherwise done so. For larger logs, it is probably best to export them.

One thought on “AWS Cloudwatch Log Scroller

  1. Since 2018 they have change the UI. I messed around and was able to get this to work:

    function scrollLogUp(times, currVal) {
    currVal = currVal || 0;
    if (times > currVal) {
    scrollLogUp.timer = setTimeout(function() {
    document.getElementsByClassName(“logs__main”)[0].scrollTop = 9999;
    scrollLogUp(times, ++currVal);
    }, 5000);
    } else {
    console.log(“done..”)
    }
    }

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.