This example demonstrates how to load sample data to Amazon Timestream with using Python and boto3. We used One Call API of OpenWeatherMap to fetch temperature, feels-like temperature and humidity data for last five days.
You can check out the blog post about this project at https://sufle.io/blog/data-visualization-with-amazon-timestream-and-grafana
- python +3.7
- pip
After cloning the project, in the main directory:
virtualenv -p python3 venv
source venv/bin/activate
pip install -r requirements
In the constants.py file, you should define your AWS credentials, OpenWeatherMap access token and the latitude and longitude informations of the desired city. You can find a couple of cities defined in the file, e.g. for Istanbul, you should run;
python3 main.py --city Istanbul
- $__database = weatherDB
- $__table = weathertable
- $__measure = feels_like or temp
- Query1: SELECT time, measure_value::double as temperature FROM $__database.$__table WHERE city='Istanbul' AND measure_name='$__measure'
- Query2: SELECT time, measure_value::double as feels_like_temperature FROM $__database.$__table WHERE city='Istanbul' AND measure_name='$__measure'
- SELECT AVG(measure_value::double) FROM $__database.$__table WHERE city='Istanbul' AND measure_name='$__measure'