/
fluent-plugin-github-activities.conf
577 lines (492 loc) · 15.6 KB
/
fluent-plugin-github-activities.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
# requires fluent-plugin-github-activities
<source>
type github-activities
# Authentication is strongly recommended, because there is a rate limit: 60requests/hour by default.
# With authentication, it becomes 5000requests/hour (means about 80requests/minute).
# See following the GitHub help about access_token
# https://help.github.com/articles/creating-an-access-token-for-command-line-use/
access_token access-token-of-github
users ashie,cosmo0920,kenhys,kou,min-shin,myokoym,okkez,piroor
clients 4
interval 1
base_tag github-activity.
pos_file /var/log/td-agent/github-activities.json
</source>
# copy record for event, tag, and actor (requires fluent-plugin-record-reformer)
<match github-activity.**>
type copy
# record for the Events table
<store>
type record_reformer
enable_ruby true
tag event.${tag}
# fill common fields if possible
<record>
type ${tag_suffix[-1]}
actor ${actor && actor["login"]}
source_icon https://github.com/favicon.ico
timestamp ${created_at}
created_at ${time}
_repository ${repo && repo["name"]}
</record>
</store>
# record for the Actors table
<store>
type record_reformer
enable_ruby true
renew_record true
tag sharetary.actor
<record>
_key ${(actor || committer)["login"]}
uri https://github.com/${(actor || committer)["login"]}/
icon ${self["$github-activities-related-avatar"]}
class major
</record>
</store>
# record for the Tags table
<store>
type record_reformer
enable_ruby true
renew_record true
tag sharetary.tag
<record>
_key ${tag.end_with?(".commit") ? url.match(/repos\/([^\/]+\/[^\/]+)\/commits/)[1] : tag.end_with?(".fork") ? payload["forkee"]["full_name"] : repo["name"]}
icon ${self["$github-activities-related-organization-logo"]}
</record>
</store>
</match>
# complete event record from activity (requires fluent-plugin-record-reformer)
## commit and push
<match event.github-activity.push>
type record_reformer
enable_ruby true
renew_record true
keep_keys type,actor,source_icon,timestamp,created_at,_repository
tag sharetary.event
<record>
_key https://github.com/${repo["name"]}/compare/${payload["before"]}...${payload["head"]}
class minor
title Push
description Pushed ${payload["size"].to_s} commits to ${repo["name"]}
uri https://github.com/${repo["name"]}/compare/${payload["before"]}...${payload["head"]}
reply_uri https://github.com/${repo["name"]}/compare/${payload["before"]}...${payload["head"]}#commits_bucket
</record>
</match>
<match event.github-activity.commit>
type record_reformer
enable_ruby true
renew_record true
keep_keys type,source_icon,created_at
tag sharetary.event
<record>
_key ${html_url}
class normal
_repository ${url.match(/repos\/([^\/]+\/[^\/]+)\/commits/)[1]}
title Commit ${stats["total"].to_s} changes
description ${commit["message"]}
extra_description ${files.collect{|file| "#{file["filename"]} (#{file["status"]})" }.join("\n, ")}\n\n${files.collect{|file| file["patch"] }.join("\n\n")}
actor ${committer["login"]}
uri ${html_url}
reply_uri ${html_url}#new_commit_comment_field
timestamp ${commit["committer"]["date"]}
parent ${self["$github-activities-related-event"] && "https://github.com/#{self["$github-activities-related-event"]["repo"]["name"]}/compare/#{self["$github-activities-related-event"]["payload"]["before"]}...#{self["$github-activities-related-event"]["payload"]["head"]}" || "" }
</record>
</match>
## comments on commits
<match event.github-activity.commit-comment>
type record_reformer
enable_ruby true
renew_record true
keep_keys type,actor,source_icon,timestamp,created_at,_repository
tag sharetary.event
<record>
_key ${payload["comment"]["html_url"]}
class major
title Commented to the commit ${repo["name"]}/${payload["comment"]["commit_id"]}
description ${payload["comment"]["body"]}
uri ${payload["comment"]["html_url"]}
reply_uri ${payload["comment"]["html_url"].split("#").first}#new_commit_comment_field
parent ${payload["comment"]["html_url"].split("#").first}
</record>
</match>
## issues
<match event.github-activity.issue-open>
type record_reformer
enable_ruby true
renew_record true
keep_keys type,actor,source_icon,timestamp,created_at,_repository
tag sharetary.event
<record>
_key ${payload["issue"]["html_url"]}
class major
title Open
description Opened new issue: ${"#"}${payload["issue"]["number"].to_s} ${payload["issue"]["title"]}: ${(payload["issue"]["body"] || "")}
uri ${payload["issue"]["html_url"]}
reply_uri ${payload["issue"]["html_url"].split("#").first}#new_comment_field
</record>
</match>
<match event.github-activity.issue-close>
type record_reformer
enable_ruby true
renew_record true
keep_keys type,actor,source_icon,timestamp,created_at,_repository
tag sharetary.event
<record>
_key ${payload["issue"]["html_url"]}#${payload["issue"]["updated_at"]}
class major
title Close
description Closed the issue: ${"#"}${payload["issue"]["number"].to_s} ${payload["issue"]["title"]}
uri ${payload["issue"]["html_url"]}
reply_uri ${payload["issue"]["html_url"].split("#").first}#new_comment_field
parent ${payload["issue"]["html_url"]}
</record>
</match>
<match event.github-activity.issue-reopen>
type record_reformer
enable_ruby true
renew_record true
keep_keys type,actor,source_icon,timestamp,created_at,_repository
tag sharetary.event
<record>
_key ${payload["issue"]["html_url"]}#${payload["issue"]["updated_at"]}
class major
title Reopen
description Reopened the issue: ${"#"}${payload["issue"]["number"].to_s} ${payload["issue"]["title"]}
uri ${payload["issue"]["html_url"]}
reply_uri ${payload["issue"]["html_url"].split("#").first}#new_comment_field
parent ${payload["issue"]["html_url"]}
</record>
</match>
<match event.github-activity.issue-comment>
type record_reformer
enable_ruby true
renew_record true
keep_keys type,actor,source_icon,timestamp,created_at,_repository
tag sharetary.event
<record>
_key ${payload["comment"]["html_url"]}
class major
title Comment to ${"#"}${payload["issue"]["number"].to_s} ${payload["issue"]["title"]}
description ${payload["comment"]["body"]}
uri ${payload["comment"]["html_url"]}
reply_uri ${payload["comment"]["html_url"].split("#").first}#new_comment_field
parent ${payload["issue"]["html_url"]}
</record>
</match>
## pull requests
<match event.github-activity.pull-request>
type record_reformer
enable_ruby true
renew_record true
keep_keys type,actor,source_icon,timestamp,created_at,_repository
tag sharetary.event
<record>
_key ${payload["pull_request"]["html_url"]}
class important
title PR
description Created new pull-request: ${"#"}${payload["pull_request"]["number"].to_s} ${payload["pull_request"]["title"]}: ${(payload["pull_request"]["body"] || "")}
uri ${payload["pull_request"]["html_url"]}
reply_uri ${payload["pull_request"]["html_url"].split("#").first}#new_comment_field
</record>
</match>
<match event.github-activity.pull-request-reopen>
type record_reformer
enable_ruby true
renew_record true
keep_keys type,actor,source_icon,timestamp,created_at,_repository
tag sharetary.event
<record>
_key ${payload["pull_request"]["html_url"]}#${payload["pull_request"]["updated_at"]}
class important
title PR Reopen
description Reopened the pull-request ${"#"}${payload["pull_request"]["number"].to_s} ${payload["pull_request"]["title"]}
uri ${payload["pull_request"]["html_url"]}
reply_uri ${payload["pull_request"]["html_url"].split("#").first}#new_comment_field
parent ${payload["pull_request"]["html_url"]}
</record>
</match>
<match event.github-activity.pull-request-merged>
type record_reformer
enable_ruby true
renew_record true
keep_keys type,actor,source_icon,timestamp,created_at,_repository
tag sharetary.event
<record>
_key ${payload["pull_request"]["html_url"]}#${payload["pull_request"]["updated_at"]}
class important
title PR Merge
description Merged the pull-request ${"#"}${payload["pull_request"]["number"].to_s} ${payload["pull_request"]["title"]}
uri ${payload["pull_request"]["html_url"]}
reply_uri ${payload["pull_request"]["html_url"].split("#").first}#new_comment_field
parent ${payload["pull_request"]["html_url"]}
</record>
</match>
<match event.github-activity.pull-request-cancelled>
type record_reformer
enable_ruby true
renew_record true
keep_keys type,actor,source_icon,timestamp,created_at,_repository
tag sharetary.event
<record>
_key ${payload["pull_request"]["html_url"]}#${payload["pull_request"]["updated_at"]}
class important
title PR Cancel
description Cancelled the pull-request ${"#"}${payload["pull_request"]["number"].to_s} ${payload["pull_request"]["title"]}
uri ${payload["pull_request"]["html_url"]}
reply_uri ${payload["pull_request"]["html_url"].split("#").first}#new_comment_field
parent ${payload["pull_request"]["html_url"]}
</record>
</match>
<match event.github-activity.pull-request-comment>
type record_reformer
enable_ruby true
renew_record true
keep_keys type,actor,source_icon,created_at,_repository
tag sharetary.event
<record>
_key ${payload["comment"]["html_url"]}
class important
title PR Comment ${"#"}${payload["issue"]["number"].to_s} ${payload["issue"]["title"]}
description ${payload["comment"]["body"]}
uri ${payload["comment"]["html_url"]}
reply_uri ${payload["comment"]["html_url"].split("#").first}#new_comment_field
timestamp ${payload["comment"]["created_at"]}
parent ${payload["issue"]["pull_request"]["html_url"]}
</record>
</match>
## fork
<match event.github-activity.fork>
type record_reformer
enable_ruby true
renew_record true
keep_keys type,actor,source_icon,timestamp,created_at
tag sharetary.event
<record>
_key ${payload["forkee"]["html_url"]}#forked
class normal
title Fork
description Forked the repository ${repo["name"]} to ${payload["forkee"]["full_name"]}
uri ${payload["forkee"]["html_url"]}#forked
_repository ${payload["forkee"]["full_name"]}
</record>
</match>
## branch, tag
<match event.github-activity.branch>
type record_reformer
enable_ruby true
renew_record true
keep_keys type,actor,source_icon,timestamp,created_at,_repository
tag sharetary.event
<record>
_key https://github.com/${repo["name"]}/tree/${payload["ref"]}
class normal
title Branch
description Created new branch ${payload["ref"]} at the repository ${repo["name"]}
uri https://github.com/${repo["name"]}/tree/${payload["ref"]}
</record>
</match>
<match event.github-activity.tag>
type record_reformer
enable_ruby true
renew_record true
keep_keys type,actor,source_icon,timestamp,created_at,_repository
tag sharetary.event
<record>
_key https://github.com/${repo["name"]}/tree/${payload["ref"]}
class normal
title Tag
description Created new tag ${payload["ref"]} at the repository ${repo["name"]}
uri https://github.com/${repo["name"]}/tree/${payload["ref"]}
</record>
</match>
# finalize array type `tags` field (requires fluent-plugin-record-reformer)
<filter sharetary.event>
type record_transformer
enable_ruby false
remove_keys _repository
<record>
tags ["${_repository}"]
# tags ["${_repository}", "sample-extra-tag"] # if needed you can set extra tags.
</record>
</filter>
# convert datetime string fields to unixtime integer fields (requires fluent-plugin-filter_typecast)
<filter sharetary.event>
type typecast
types created_at:time,timestamp:time
</filter>
# storing event into Groonga's database (requires fluent-plugin-groonga)
<match sharetary.event>
type groonga
store_table Events
protocol http
host localhost
buffer_type file
buffer_path /var/spool/td-agent/buffer/groonga-sharetary-event
flush_interval 1s
<table>
name Events
flags TABLE_HASH_KEY
key_type ShortText
</table>
<table>
name Timestamps
flags TABLE_PAT_KEY
key_type Time
</table>
<table>
name Tags
flags TABLE_HASH_KEY
key_type ShortText
</table>
<table>
name Actors
flags TABLE_HASH_KEY
key_type ShortText
</table>
<table>
name Terms
flags TABLE_PAT_KEY
key_type ShortText
default_tokenizer TokenBigram
normalizer NormalizerAuto
</table>
<mapping>
name type
type ShortText
</mapping>
<mapping>
name class
type ShortText
</mapping>
<mapping>
name title
type ShortText
<index>
table Terms
name Events_title_index
flags WITH_POSITION
</index>
</mapping>
<mapping>
name description
type Text
<index>
table Terms
name Events_description_index
flags WITH_POSITION
</index>
</mapping>
<mapping>
name extra_description
type Text
<index>
table Terms
name Events_extra_description_index
flags WITH_POSITION
</index>
</mapping>
<mapping>
name tags
type Tags
<index>
table Tags
name Events_tags_index
</index>
</mapping>
<mapping>
name uri
type ShortText
<index>
table Terms
name Events_uri_index
flags WITH_POSITION
</index>
</mapping>
<mapping>
name source_icon
type ShortText
</mapping>
<mapping>
name reply_uri
type ShortText
</mapping>
<mapping>
name actor
type Actors
<index>
table Actors
name Events_actor_index
</index>
</mapping>
<mapping>
name timestamp
type Time
<index>
table Timestamps
name Events_timestamp_index
</index>
</mapping>
<mapping>
name created_at
type Time
<index>
table Timestamps
name Events_created_at_index
</index>
</mapping>
<mapping>
name parent
type ShortText
<index>
table Terms
name Events_parent_index
flags WITH_POSITION
</index>
</mapping>
</match>
# tags
<match sharetary.tag>
type groonga
store_table Tags
protocol http
host localhost
buffer_type file
buffer_path /var/spool/td-agent/buffer/groonga-sharetary-tag
flush_interval 1s
<table>
name Tags
flags TABLE_HASH_KEY
key_type ShortText
</table>
<mapping>
name icon
type ShortText
</mapping>
</match>
# actor
<match sharetary.actor>
type groonga
store_table Actors
protocol http
host localhost
buffer_type file
buffer_path /var/spool/td-agent/buffer/groonga-sharetary-actor
flush_interval 1s
<table>
name Actors
flags TABLE_HASH_KEY
key_type ShortText
</table>
<mapping>
name uri
type ShortText
</mapping>
<mapping>
name icon
type ShortText
</mapping>
<mapping>
name class
type ShortText
</mapping>
</match>