以ä¸ãèªåãä»å¾ã¡ã³ããã³ã¹ããçºã«ãå¿ è¦ãªã®ã§ã¡ã¢ã£ã¦ããã
tl;dr
ä»ã¾ã§ã®å¾©ç¿ã®ã¤ãã㧠DynamoDB + Datapipeline + S3 + Google Chart API ãå°ããã¤ä½¿ã£ã¦ããã¾ãåã§æä¾ããã¦ãã大æ°ä¸ã®æ±æç©è³ªæ¿åº¦éå ±ãã¼ã¿ãå¯è¦åãããµã¤ããä½ã£ã¦ã¿ãã
æ¢ã«ä»¥ä¸ã®ãã㪠API ãã¢ããªãä½æããã¦ããæ¹ãããã£ãããã®ã§ãªã¢ã«ã¿ã¤ã ã«æ å ±ãåå¾ãããå ´åã«ã¯ãã¡ããå©ç¨ãã¾ãããã
- (Android)大気汚染物質広域監視システム「そらまめ君」の簡易受信アプリ - OasisHalfmoon
- 環境省大気汚染物質広域監視システム(そらまめ君)のAPIを作ってみた。 - hachiBucchのブログ
èªåãä½ã£ãã®ã¯åæ¥åã® PM2.5 æ¿åº¦ã®é·ç§»ãè¦ããã ãã®ã·ã³ãã«ãªãã®ãªã®ã§ãå¤ä¼ã¿ã®èªç±ç 究ã¨ãã«ã³ããã§ä½¿ã£ã¦ããããã¨å¬ãããªã...æ¢ã«å¤ä¼ã¿ã¯çµãã£ã¦ãããã©ãï¼æ¥å¹´ã®å¤ä¼ã¿ã®ææã¾ã§éç¨ããã¦ããã°è²´éãªãã¼ã¿ãã¼ã¹ã«ãªã£ã¦ãããã¨ã§ããã...ï¼
memo ã¨ãã¦ã³ãã¯ã¨ã
æ§æå³
å¦çã®æµã
ã½ã¼ã¹ã³ã¼ãã¨ã
- ã¡ã¤ã³ã¨ãªãã½ã¼ã¹ã³ã¼ã
- Data Pipeline ã®ãã¤ãã©ã¤ã³å®ç¾©
{ "objects": [ { "directoryPath": "#{myS3OutputLoc}/#{format(@scheduledStartTime, 'YYYY-MM-dd-HH-mm-ss')}", "name": "S3OutputLocation", "id": "S3OutputLocation", "type": "S3DataNode" }, { "output": { "ref": "S3OutputLocation" }, "stage": "true", "name": "ShellCommandActivityObj", "id": "ShellCommandActivityObj", "runsOn": { "ref": "EC2ResourceObj" }, "type": "ShellCommandActivity", "command": "#{myShellCmd}" }, { "subnetId": "subnet-12345678", "imageId": "ami-12345678", "securityGroupIds": "sg-12345678", "instanceType": "t1.micro", "name": "EC2ResourceObj", "keyPair": "xxxxxxxxxxxxxxxxxxxxxxx", "id": "EC2ResourceObj", "type": "Ec2Resource", "terminateAfter": "15 Minutes" }, { "period": "1 Day", "startDateTime": "2015-09-17T07:59:00", "name": "RunOnce", "id": "DefaultSchedule", "type": "Schedule" }, { "failureAndRerunMode": "CASCADE", "schedule": { "ref": "DefaultSchedule" }, "resourceRole": "DataPipelineDefaultResourceRole", "role": "DataPipelineDefaultRole", "scheduleType": "cron", "name": "Default", "id": "Default" } ], "parameters": [ { "description": "S3 output folder", "id": "myS3OutputLoc", "type": "AWS::S3::ObjectKey" }, { "default": "s3://us-east-1.elasticmapreduce.samples/pig-apache-logs/data", "description": "S3 input folder", "id": "myS3InputLoc", "type": "AWS::S3::ObjectKey" }, { "default": "grep -rc \"GET\" ${INPUT1_STAGING_DIR}/* > ${OUTPUT1_STAGING_DIR}/output.txt", "description": "Shell command to run", "id": "myShellCmd", "type": "String" } ], "values": { "myShellCmd": "mkdir /tmp/build\ncd /tmp/build\nwget https://raw.githubusercontent.com/inokappa/oreno-pipeline/master/Dockerfile\ndocker build --no-cache=true -t soramame-runner .\ndocker run --env 'AWS_REGION=ap-northeast-1' --env 'S3_BUCKET=your.example.com' soramame-runner > ${OUTPUT1_STAGING_DIR}/output.txt", "myS3InputLoc": "s3://your-input-bucket/", "myS3OutputLoc": "s3://your-output-bucket/" } }
- Data Pipeline ã§å©ç¨ãã Dockerfile
FROM ruby MAINTAINER inokappa RUN apt-get update RUN git clone https://github.com/inokappa/oreno-soramame-pipeline.git /app RUN chmod 755 /app/run.sh RUN mkdir -p /app/output/html RUN mkdir -p /app/output/png RUN gem install aws-sdk nokogiri googlecharts --no-ri --no-rdoc CMD /app/run.sh
Data Pipeline ã¯
- ä¸æ¥ä¸åã®å¦çï¼cronï¼ã¨ãã¦å©ç¨
- Shell Activity ã«ã¦ Docker ã³ã³ãããå©ç¨
- æ¨æºåºåã S3 ã«ä¿åï¼S3 Output Location ã§å®ç¾©ããåºåå ã«åºåï¼
Docker ã³ã³ãã
- å¦çãè¡ãã¹ã¯ãªãããã³ã³ããå
- AMI ä½ãããã楽ãã¹ã¯ãªããã®ã¡ã³ããã³ã¹ãæãï¼ã¨æã£ãï¼
- æ¯å build ãããï¼ææ°ã®ã½ã¼ã¹ã³ã¼ãã§å¦çããããã¨ãåºæ¥ãããã«ãã®æé㯠5 åç¨åº¦ãªã®ã§å ¨ä½ã®å¦çæéã¸ã®å½±é¿ã¯å°ãªãï¼
æå¾ã«
æãããã¨
- Data Pipeline ã® Shell Activity 㯠Cron ã®ä»£æ¿ã«ãªãããï¼ä½ã 15 åæªæºã®ééãå®ç¾©ãããã¨ã¯åºæ¥ãªãã®ã§æ³¨æï¼
- ã¡ãã£ã¨ããã¹ã¯ãªããã¨ãã Docker ã³ã³ããåãã¦ããã¨ããæ°
- DynamoDB ã® Scan ã Query ã®ãã£ã«ã¿ãã¤ãã¤ãç解åºæ¥ã¦ããªã
æ¹åæ¡
- Ruby ã®ã½ã¼ã¹ã³ã¼ãã極ãã¦éã§ã¨ã©ã¼å¦ççæ®ã©å ¥ã£ã¦ããªãã®ã§ã¡ããã¡ããç´ãã¦ãããã
- DynamoDB ã®æ¤ç´¢çµæãæªããï¼æ½åºæ¡ä»¶ã®æå®æ¹æ³ãæªããï¼ã®ã§è¦ç´ã
- åºæ¥ãã ããªã¢ã«ã¿ã¤ã æ§ãæãããããã«ãã
- ä»»æã®æ¡ä»¶ã§æ¤ç´¢ãã°ã©ãæç»åºæ¥ãããã«ããã
- ã°ã©ãä¸ä½å°ç¹åã¨å°å³ä¸å°ç¹ããªã³ã¯ãããã
DynamoDB 㨠Datapipeline
- DynamoDB ã®ããã©ã¼ãã³ã¹é¢çã«ã¤ãã¦å¼ãç¶ã調æ»
- Datapipeline ã®ã¨ã©ã¼ãã³ããªã³ã°ããªãã©ã¤å¦çã«ã¤ãã¦å¼ãç¶ã調æ»
- S3 ã®ãã¼ã¿ã Datapipeline çµç±ã§ DynamoDB ã«ã¤ã³ãã¼ãï¼ç°¡åããã§é£ããã£ãï¼ããªãã©ã¤