# requires fluent-plugin-github-activities 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 # copy record for event, tag, and actor (requires fluent-plugin-record-reformer) type copy # record for the Events table type record_reformer enable_ruby true tag event.${tag} # fill common fields if possible 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 for the Actors table type record_reformer enable_ruby true renew_record true tag sharetary.actor _key ${(actor || committer)["login"]} uri https://github.com/${(actor || committer)["login"]}/ icon ${self["$github-activities-related-avatar"]} class major # record for the Tags table type record_reformer enable_ruby true renew_record true tag sharetary.tag _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"]} # complete event record from activity (requires fluent-plugin-record-reformer) ## commit and push type record_reformer enable_ruby true renew_record true keep_keys type,actor,source_icon,timestamp,created_at,_repository tag sharetary.event _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 type record_reformer enable_ruby true renew_record true keep_keys type,source_icon,created_at tag sharetary.event _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"]}" || "" } ## comments on commits type record_reformer enable_ruby true renew_record true keep_keys type,actor,source_icon,timestamp,created_at,_repository tag sharetary.event _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} ## issues type record_reformer enable_ruby true renew_record true keep_keys type,actor,source_icon,timestamp,created_at,_repository tag sharetary.event _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 type record_reformer enable_ruby true renew_record true keep_keys type,actor,source_icon,timestamp,created_at,_repository tag sharetary.event _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"]} type record_reformer enable_ruby true renew_record true keep_keys type,actor,source_icon,timestamp,created_at,_repository tag sharetary.event _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"]} type record_reformer enable_ruby true renew_record true keep_keys type,actor,source_icon,timestamp,created_at,_repository tag sharetary.event _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"]} ## pull requests type record_reformer enable_ruby true renew_record true keep_keys type,actor,source_icon,timestamp,created_at,_repository tag sharetary.event _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 type record_reformer enable_ruby true renew_record true keep_keys type,actor,source_icon,timestamp,created_at,_repository tag sharetary.event _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"]} type record_reformer enable_ruby true renew_record true keep_keys type,actor,source_icon,timestamp,created_at,_repository tag sharetary.event _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"]} type record_reformer enable_ruby true renew_record true keep_keys type,actor,source_icon,timestamp,created_at,_repository tag sharetary.event _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"]} type record_reformer enable_ruby true renew_record true keep_keys type,actor,source_icon,created_at,_repository tag sharetary.event _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"]} ## fork type record_reformer enable_ruby true renew_record true keep_keys type,actor,source_icon,timestamp,created_at tag sharetary.event _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"]} ## branch, tag type record_reformer enable_ruby true renew_record true keep_keys type,actor,source_icon,timestamp,created_at,_repository tag sharetary.event _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"]} type record_reformer enable_ruby true renew_record true keep_keys type,actor,source_icon,timestamp,created_at,_repository tag sharetary.event _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"]} # finalize array type `tags` field (requires fluent-plugin-record-reformer) type record_transformer enable_ruby false remove_keys _repository tags ["${_repository}"] # tags ["${_repository}", "sample-extra-tag"] # if needed you can set extra tags. # convert datetime string fields to unixtime integer fields (requires fluent-plugin-filter_typecast) type typecast types created_at:time,timestamp:time # storing event into Groonga's database (requires fluent-plugin-groonga) 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 name Events flags TABLE_HASH_KEY key_type ShortText
name Timestamps flags TABLE_PAT_KEY key_type Time
name Tags flags TABLE_HASH_KEY key_type ShortText
name Actors flags TABLE_HASH_KEY key_type ShortText
name Terms flags TABLE_PAT_KEY key_type ShortText default_tokenizer TokenBigram normalizer NormalizerAuto
name type type ShortText name class type ShortText name title type ShortText table Terms name Events_title_index flags WITH_POSITION name description type Text table Terms name Events_description_index flags WITH_POSITION name extra_description type Text table Terms name Events_extra_description_index flags WITH_POSITION name tags type Tags table Tags name Events_tags_index name uri type ShortText table Terms name Events_uri_index flags WITH_POSITION name source_icon type ShortText name reply_uri type ShortText name actor type Actors table Actors name Events_actor_index name timestamp type Time table Timestamps name Events_timestamp_index name created_at type Time table Timestamps name Events_created_at_index name parent type ShortText table Terms name Events_parent_index flags WITH_POSITION
# tags 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 name Tags flags TABLE_HASH_KEY key_type ShortText
name icon type ShortText
# 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 name Actors flags TABLE_HASH_KEY key_type ShortText
name uri type ShortText name icon type ShortText name class type ShortText