Example: Simple Alerts

In this application, the query runs continuously on the in-application
stream created over the demo stream. For more information, see Continuous Queries. If any rows show a stock price
change that is greater than 1 percent, those rows are inserted in another
in-application stream. In the exercise, you can configure the application output
persist the results to an external destination. You can then further investigate
results. For example, you can use an AWS Lambda function to process records and send
you alerts.

The SELECT statement in the application code filters rows in the
SOURCE_SQL_STREAM_001 for stock price changes greater than
1%, and inserts those rows to another in-application stream
DESTINATION_SQL_STREAM using a pump. For more information about the coding
pattern that explains using pumps to insert rows in in-application streams,
see Application Code.

Click Save and run SQL.

Add a destination. You can either choose the Destination in the SQL
Editor, or choose Add a destination on the application
hub.

In SQL editor, choose the Destination tab and then choose Add a
destination.

On the Add a destination page, choose
Configure a new stream.

Choose Go to Kinesis Streams.

In the Amazon Kinesis Data Streams console, create a new Kinesis stream
(for example, gs-destination) with 1 shard.
Wait until the stream status is ACTIVE.

Return to the Amazon Kinesis Data Analytics console. On the
Destination page, choose the stream that you
created.

If the stream does not show, refresh the page.

Now you have an external destination, where Amazon Kinesis Data Analytics persists
any records your application writes to the in-application stream
DESTINATION_SQL_STREAM.

Choose Save and continue.

Now you have an external destination, a Kinesis stream, where
Amazon Kinesis Data Analytics persists your application output in the
DESTINATION_SQL_STREAM in-application stream.

Configure AWS Lambda to monitor the Kinesis stream you created and
invoke a Lambda function.