Appendix A: Code Components

The Real-Time Insights on AWS Account Activity solution uses three main code components
to process and display metrics on the real-time dashboard. The Amazon Kinesis Data
Analytics application (RealTimeInsightsAccountActivityApp) runs SQL queries against the in-application streams and emits the results. A JavaScript
file (dash.js) populates the chart with the results of the queries, and an HTML file (dash.html) renders the chart on the dashboard in real-time.

The following example shows the SQL, JavaScript, and HTML code for the CallsPreUniqueIp metric.

SQL Query

The SQL query calculates the number of calls, in one minute intervals, based on an
IP address. The result is stored in an output in-application stream (DESTINATION_SQL_STREAM) with the name of the metric (CallsPerUniqueIp) and the corresponding values: IP address and count.