Showing
1 changed file
with
107 additions
and
0 deletions
@@ -15,6 +15,113 @@ POST /android_report.do | @@ -15,6 +15,113 @@ POST /android_report.do | ||
15 | Host: error-report.yoho.cn | 15 | Host: error-report.yoho.cn |
16 | ``` | 16 | ``` |
17 | 17 | ||
18 | + | ||
19 | +## 1. Write APP report error info to log files | ||
20 | + | ||
21 | +``` | ||
22 | +null|null|null|android|null|180c05cb6ef78f508731690851f7e263|ULOGIN|null|null|null|null|20170505153357|50988732|null|null|null|0|6.0|CAM-TL00H|other|0|0|null|VUxPR0lO|8608630377630425317b29953e941d9|1493969638271|2017-05-05 15:33:58.271 | ||
23 | +``` | ||
24 | + | ||
25 | +## 2.split logs file to per-hour: | ||
26 | + | ||
27 | +``` | ||
28 | +app_error_2017-05-05-11.log | ||
29 | +app_error_2017-05-05-12.log | ||
30 | +``` | ||
31 | + | ||
32 | +## 3.create external hive tables | ||
33 | + | ||
34 | +```sql | ||
35 | +create external table app_error_logs ( | ||
36 | +time string, | ||
37 | +cid string, | ||
38 | +body string, | ||
39 | +client string, | ||
40 | +ec string, | ||
41 | +ei string, | ||
42 | +et string, | ||
43 | +id string, | ||
44 | +method string, | ||
45 | +response string, | ||
46 | +sid string, | ||
47 | +ts string, | ||
48 | +uid string, | ||
49 | +tec string, | ||
50 | +cts string, | ||
51 | +method_event string, | ||
52 | +index string, | ||
53 | +osv string, | ||
54 | +dm string, | ||
55 | +av string, | ||
56 | +net string, | ||
57 | +ca string, | ||
58 | +st string, | ||
59 | +exception_type string, | ||
60 | +udid string, | ||
61 | +collect_time bigint, | ||
62 | +collect_time_ts timestamp | ||
63 | +) | ||
64 | +partitioned by (day string) | ||
65 | +row format delimited | ||
66 | +fields terminated by '|' | ||
67 | +stored as textfile; | ||
68 | + | ||
69 | +``` | ||
70 | + | ||
71 | +## 4. cron: put files to qcloud cos storage | ||
72 | + | ||
73 | +```bash | ||
74 | + | ||
75 | +#!/bin/bash | ||
76 | + | ||
77 | +file_path="/Data/applogs" | ||
78 | +file_name_prefix="app_error" | ||
79 | + | ||
80 | +ssh_host="root@10.66.4.133" | ||
81 | +remote_path="/data/applogs" | ||
82 | + | ||
83 | +function getFileFullName () { | ||
84 | + file_time=`date -d '-1 hour' +'%Y-%m-%d-%H'` | ||
85 | + file_name=${file_name_prefix}"_"${file_time}".log" | ||
86 | + file_full_path=${file_path}"/"${file_name} | ||
87 | +} | ||
88 | + | ||
89 | +getFileFullName | ||
90 | + | ||
91 | +date_path=`date -d '-1 hour' +'%Y-%m-%d'` | ||
92 | +if [ -e ${file_full_path} ] | ||
93 | +then | ||
94 | + remote_date_path=${remote_path}"/"${date_path} | ||
95 | + if ssh $ssh_host test -e $remote_date_path | ||
96 | + then | ||
97 | + echo `date`":"${remote_date_path}" exists, does not create" | ||
98 | + else | ||
99 | + echo `date`":"${remote_date_path}" does not exist, ready to create" | ||
100 | + ssh $ssh_host "cd ${remote_path}; mkdir ${date_path}" | ||
101 | + ssh $ssh_host /usr/local/service/hadoop/bin/hadoop fs -mkdir cosn://applogs/app_error_logs/${date_path} | ||
102 | + ssh $ssh_host "/usr/local/service/hive/bin/hive -e \"alter table app_error_logs add partition (day='${date_path}') location 'cosn://applogs/app_error_logs/${date_path}'\"" | ||
103 | + fi | ||
104 | + | ||
105 | + remote_file=${remote_date_path}"/"${file_name} | ||
106 | + if ssh $ssh_host test -e $remote_file | ||
107 | + then | ||
108 | + echo `date`":"${remote_file}" exists" | ||
109 | + exit | ||
110 | + fi | ||
111 | + | ||
112 | + scp ${file_full_path} ${ssh_host}:${remote_date_path} | ||
113 | + ssh $ssh_host /usr/local/service/hadoop/bin/hadoop fs -put ${remote_file} cosn://applogs/app_error_logs/${date_path} | ||
114 | +else | ||
115 | + echo `date`":the file ["${file_full_path}"] does not exist" | ||
116 | + exit | ||
117 | +fi | ||
118 | + | ||
119 | + | ||
120 | + | ||
121 | +``` | ||
122 | + | ||
123 | + | ||
124 | + | ||
18 | APP ERROR INFO: | 125 | APP ERROR INFO: |
19 | http://git.yoho.cn/mobile/yohoanalyticssdk | 126 | http://git.yoho.cn/mobile/yohoanalyticssdk |
20 | 127 |
-
Please register or login to post a comment