Skip to content

Instantly share code, notes, and snippets.

@sue445
Last active August 29, 2015 14:03
Show Gist options
  • Save sue445/039b3ae8d7f1f5e0c1bd to your computer and use it in GitHub Desktop.
Save sue445/039b3ae8d7f1f5e0c1bd to your computer and use it in GitHub Desktop.
Example of fluentd + gitlab webhook + Chatwork notification http://sue445.hatenablog.com/entry/2014/06/29/094035
<source>
type http
port 8888
</source>
<match gitlab.**>
type copy
<store>
type rewrite
add_prefix filtered
<rule>
key object_kind
pattern ^(.+)$
append_to_tag true
last true
</rule>
<rule>
key ref
pattern ^refs\/(.+)\/(.+)$
append_to_tag true
</rule>
</store>
</match>
# Issue Requests Events
<match filtered.gitlab.*.*.issue>
type forest
subtype chatwork
<template>
api_token XXXXXXXXXXXXXXXXXXXXXXXXX
room_id 00000000
message [info][title][${tag_parts[4]}] <%= record['object_attributes']['title'] %> is <%= record['object_attributes']['state'] %> [/title]http://git.example.com/${tag_parts[2]}/${tag_parts[3]}/<%= record['object_attributes']['iid'] %> [/info]
</template>
</match>
# Merge Requests Events
<match filtered.gitlab.*.*.merge_request>
type forest
subtype chatwowk
<template>
api_token XXXXXXXXXXXXXXXXXXXXXXXXX
room_id 00000000
message [info][title][${tag_parts[4]}] <%= record['object_attributes']['title'] %> is <%= record['object_attributes']['state'] %> [/title]http://git.example.com/${tag_parts[2]}/${tag_parts[3]}/<%= record['object_attributes']['iid'] %> [/info]
</template>
</match>
# Push events
<match filtered.gitlab.*.*.heads.*>
type forest
subtype chatwork
<template>
api_token XXXXXXXXXXXXXXXXXXXXXXXXX
room_id 00000000
message [info][title][Push to ${tag_parts[5]}] @<%= record['user_name'] %>[/title]http://git.example.com/${tag_parts[2]}/${tag_parts[3]}/<%= record['total_commits_count'] <= 1 ? "commit/" + record['after'].slice(0,8): "compare/" + record['before'].slice(0,8) + "..." + record['after'].slice(0,8) %> \n<%= record['commits'].map {|c| "* " + c['message'].slice(/^.+$/) }.join("\n") %> [/info]
</template>
</match>
# Tag Push events
<match filtered.gitlab.*.*.tags.*>
type forest
subtype chatwork
<template>
api_token XXXXXXXXXXXXXXXXXXXXXXXXX
room_id 00000000
message [info][title][Tag ${tag_parts[5]}] @<%= record['user_name'] %>[/title]http://git.example.com/${tag_parts[2]}/${tag_parts[3]}/commits/${tag_parts[5]}[/info]
</template>
</match>
<match filtered.gitlab.**>
type stdout
</match>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment