MAPREDUCE服务 MRS-OpenTSDB样例程序开发思路:场景说明
场景说明
假定用户开发一个应用程序,用于记录和查询城市的气象信息,记录数据如下表表1,表2和表3所示。
城市 |
区域 |
时间 |
温度 |
湿度 |
---|---|---|---|---|
Shenzhen |
Longgang |
2017/7/1 00:00:00 |
28 |
54 |
Shenzhen |
Longgang |
2017/7/1 01:00:00 |
27 |
53 |
Shenzhen |
Longgang |
2017/7/1 02:00:00 |
27 |
52 |
Shenzhen |
Longgang |
2017/7/1 03:00:00 |
27 |
51 |
Shenzhen |
Longgang |
2017/7/1 04:00:00 |
27 |
50 |
Shenzhen |
Longgang |
2017/7/1 05:00:00 |
27 |
49 |
Shenzhen |
Longgang |
2017/7/1 06:00:00 |
27 |
48 |
Shenzhen |
Longgang |
2017/7/1 07:00:00 |
27 |
46 |
Shenzhen |
Longgang |
2017/7/1 08:00:00 |
29 |
46 |
Shenzhen |
Longgang |
2017/7/1 09:00:00 |
30 |
48 |
Shenzhen |
Longgang |
2017/7/1 10:00:00 |
32 |
48 |
Shenzhen |
Longgang |
2017/7/1 11:00:00 |
32 |
49 |
Shenzhen |
Longgang |
2017/7/1 12:00:00 |
33 |
49 |
Shenzhen |
Longgang |
2017/7/1 13:00:00 |
33 |
50 |
Shenzhen |
Longgang |
2017/7/1 14:00:00 |
32 |
50 |
Shenzhen |
Longgang |
2017/7/1 15:00:00 |
32 |
50 |
Shenzhen |
Longgang |
2017/7/1 16:00:00 |
31 |
51 |
Shenzhen |
Longgang |
2017/7/1 17:00:00 |
30 |
51 |
Shenzhen |
Longgang |
2017/7/1 18:00:00 |
30 |
51 |
Shenzhen |
Longgang |
2017/7/1 19:00:00 |
29 |
51 |
Shenzhen |
Longgang |
2017/7/1 20:00:00 |
29 |
52 |
Shenzhen |
Longgang |
2017/7/1 21:00:00 |
29 |
53 |
Shenzhen |
Longgang |
2017/7/1 22:00:00 |
28 |
54 |
Shenzhen |
Longgang |
2017/7/1 23:00:00 |
28 |
54 |
该场景里记录了深圳市龙岗区在2017年7月1日零时的温度和湿度数据,这里通过OpenTSDB的方式建模实质上是两组数据点。
指标项(metric) |
城市(city) |
区域(region) |
Unix timestamp |
指标数值(value) |
---|---|---|---|---|
city.temp |
Shenzhen |
Longgang |
1498838400 |
28 |
city.temp |
Shenzhen |
Longgang |
1498842000 |
27 |
city.temp |
Shenzhen |
Longgang |
1498845600 |
27 |
city.temp |
Shenzhen |
Longgang |
1498849200 |
27 |
city.temp |
Shenzhen |
Longgang |
1498852800 |
27 |
city.temp |
Shenzhen |
Longgang |
1498856400 |
27 |
city.temp |
Shenzhen |
Longgang |
1498860000 |
27 |
city.temp |
Shenzhen |
Longgang |
1498863600 |
27 |
city.temp |
Shenzhen |
Longgang |
1498867200 |
29 |
city.temp |
Shenzhen |
Longgang |
1498870800 |
30 |
city.temp |
Shenzhen |
Longgang |
1498874400 |
32 |
city.temp |
Shenzhen |
Longgang |
1498878000 |
32 |
city.temp |
Shenzhen |
Longgang |
1498881600 |
33 |
city.temp |
Shenzhen |
Longgang |
1498885200 |
33 |
city.temp |
Shenzhen |
Longgang |
1498888800 |
32 |
city.temp |
Shenzhen |
Longgang |
1498892400 |
32 |
city.temp |
Shenzhen |
Longgang |
1498896000 |
31 |
city.temp |
Shenzhen |
Longgang |
1498899600 |
30 |
city.temp |
Shenzhen |
Longgang |
1498903200 |
30 |
city.temp |
Shenzhen |
Longgang |
1498906800 |
29 |
city.temp |
Shenzhen |
Longgang |
1498910400 |
29 |
city.temp |
Shenzhen |
Longgang |
1498914000 |
29 |
city.temp |
Shenzhen |
Longgang |
1498917600 |
28 |
city.temp |
Shenzhen |
Longgang |
1498921200 |
28 |
指标项(metric) |
城市(city) |
区域(region) |
Unix timestamp |
指标数值(value) |
---|---|---|---|---|
city.hum |
Shenzhen |
Longgang |
1498838400 |
54 |
city.hum |
Shenzhen |
Longgang |
1498842000 |
53 |
city.hum |
Shenzhen |
Longgang |
1498845600 |
52 |
city.hum |
Shenzhen |
Longgang |
1498849200 |
51 |
city.hum |
Shenzhen |
Longgang |
1498852800 |
50 |
city.hum |
Shenzhen |
Longgang |
1498856400 |
49 |
city.hum |
Shenzhen |
Longgang |
1498860000 |
48 |
city.hum |
Shenzhen |
Longgang |
1498863600 |
46 |
city.hum |
Shenzhen |
Longgang |
1498867200 |
46 |
city.hum |
Shenzhen |
Longgang |
1498870800 |
48 |
city.hum |
Shenzhen |
Longgang |
1498874400 |
48 |
city.hum |
Shenzhen |
Longgang |
1498878000 |
49 |
city.hum |
Shenzhen |
Longgang |
1498881600 |
49 |
city.hum |
Shenzhen |
Longgang |
1498885200 |
50 |
city.hum |
Shenzhen |
Longgang |
1498888800 |
50 |
city.hum |
Shenzhen |
Longgang |
1498892400 |
50 |
city.hum |
Shenzhen |
Longgang |
1498896000 |
51 |
city.hum |
Shenzhen |
Longgang |
1498899600 |
51 |
city.hum |
Shenzhen |
Longgang |
1498903200 |
51 |
city.hum |
Shenzhen |
Longgang |
1498906800 |
51 |
city.hum |
Shenzhen |
Longgang |
1498910400 |
52 |
city.hum |
Shenzhen |
Longgang |
1498914000 |
53 |
city.hum |
Shenzhen |
Longgang |
1498917600 |
54 |
city.hum |
Shenzhen |
Longgang |
1498921200 |
54 |
其中这两组指标数据点都有2个标签:
- 标签(tag):城市city、区域region
- 标签值(tag value):ShenZhen、Longgang
用户可以执行以下数据操作:
- 获取每天的监控数据,通过OpenTSDB的put接口将两个组数据点写入数据库中。
- 对已有的数据使用OpenTSDB的query接口进行数据查询和分析。