Collecting Time-Series Stock Data with AT&T M2X on Heroku
Guest post by Kristin Peterson, Project Manager at Citrusbyte
AT&T M2X is a times-series data storage service for the Internet of Things (IoT). To demonstrate the simplicity of pushing time-series data to AT&T M2X, we’ve created a suite of Open Source demo applications. This post will walk you through setup and deployment of the M2X Heroku Python demo application.
The demo application serves as a framework for a Heroku-Python application that is capable of interacting with M2X utilizing the M2X-Python client library. The app reports the current stock price of AT&T’s stock (ticker symbol “T”) every minute, and can be modified to suit your application needs.
Before you get started…
There are a couple prerequisites that need to be done:
- Sign up for a Heroku account
- Sign up for an AT&T M2X developer account
- Install the Heroku Toolbelt and login with your Heroku credentials
Note that this application will be using one Heroku dyno and the free M2X developer account so you will not incur any fees from either Heroku or M2X when running this demo application.
Deploying the M2X Heroku Python Demo Application
Once all the prerequisites have been met, it’s time to prep and launch your demo application.
- Clone the “M2X Heroku Python Demo” application repository.
$ git clone https://github.com/attm2x/m2x-demo-heroku-python.git
- Navigate to the `m2x-demo-heroku-python` directory and create the Heroku app.
Note: specifying an APPNAME is optional, if it is omitted Heroku will randomly generate a name for your app.
$ cd m2x-demo-heroku-python
$ heroku apps:create APPNAME
- Obtain your Master API Key from your M2X Account Settings. The Master API Key is utilized when authenticating requests to M2X.
- Set the MASTER_API_KEY environment variable in your Heroku app to the Master API Key obtained in the previous step and push your local repository up to Heroku.
$ heroku config:set MASTER_API_KEY=<your_master_api_key>
$ git push heroku master
- Since this demo application is a clock process, you’ll need to run the following command to start a singleton process in Heroku that will run your code:
$ heroku ps:scale clock=1
After completing the steps above, the M2X demo application will start pushing the current AT&T stock price to a device on your M2X account called “stockreport-heroku” under a Stream called “T.” Navigate to the “stockreport-heroku” device from the M2X device dashboard to watch the data flow.
Now that you’ve conquered pushing data to M2X using this demo application, you should check out the other M2X tutorials to learn more about what you can do with M2X.
About the Author: Kristin Peterson is a Project Manager at Citrusbyte and works on the AT&T M2X team. With offices in Los Angeles and New York City, Citrusbyte provides design, engineering, and product strategy for data intensive software systems.