github_webhooks

package
v0.10.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 27, 2016 License: MIT Imports: 10 Imported by: 0

README

github_webhooks

This is a Telegraf service plugin that listens for events kicked off by Github's Webhooks service and persists data from them into configured outputs. To set up the listener first generate the proper configuration:

$ telegraf -sample-config -input-filter github_webhooks -output-filter influxdb > config.conf.new

Change the config file to point to the InfluxDB server you are using and adjust the settings to match your environment. Once that is complete:

$ cp config.conf.new /etc/telegraf/telegraf.conf
$ sudo service telegraf start

Once the server is running you should configure your Organization's Webhooks to point at the github_webhooks service. To do this go to github.com/{my_organization} and click Settings > Webhooks > Add webhook. In the resulting menu set Payload URL to http://<my_ip>:1618, Content type to application/json and under the section Which events would you like to trigger this webhook? select 'Send me everything'. By default all of the events will write to the github_webhooks measurement, this is configurable by setting the measurement_name in the config file.

Events

The titles of the following sections are links to the full payloads and details for each event. The body contains what information from the event is persisted. The format is as follows:

# TAGS
* 'tagKey' = `tagValue` type
# FIELDS 
* 'fieldKey' = `fieldValue` type

The tag values and field values show the place on the incoming JSON object where the data is sourced from.

commit_comment event

Tags:

  • 'event' = headers[X-Github-Event] string
  • 'repository' = event.repository.full_name string
  • 'private' = event.repository.private bool
  • 'user' = event.sender.login string
  • 'admin' = event.sender.site_admin bool

Fields:

  • 'stars' = event.repository.stargazers_count int
  • 'forks' = event.repository.forks_count int
  • 'issues' = event.repository.open_issues_count int
  • 'commit' = event.comment.commit_id string
  • 'comment' = event.comment.body string
create event

Tags:

  • 'event' = headers[X-Github-Event] string
  • 'repository' = event.repository.full_name string
  • 'private' = event.repository.private bool
  • 'user' = event.sender.login string
  • 'admin' = event.sender.site_admin bool

Fields:

  • 'stars' = event.repository.stargazers_count int
  • 'forks' = event.repository.forks_count int
  • 'issues' = event.repository.open_issues_count int
  • 'ref' = event.ref string
  • 'issues' = event.ref_type string
delete event

Tags:

  • 'event' = headers[X-Github-Event] string
  • 'repository' = event.repository.full_name string
  • 'private' = event.repository.private bool
  • 'user' = event.sender.login string
  • 'admin' = event.sender.site_admin bool

Fields:

  • 'stars' = event.repository.stargazers_count int
  • 'forks' = event.repository.forks_count int
  • 'issues' = event.repository.open_issues_count int
  • 'ref' = event.ref string
  • 'issues' = event.ref_type string
deployment event

Tags:

  • 'event' = headers[X-Github-Event] string
  • 'repository' = event.repository.full_name string
  • 'private' = event.repository.private bool
  • 'user' = event.sender.login string
  • 'admin' = event.sender.site_admin bool

Fields:

  • 'stars' = event.repository.stargazers_count int
  • 'forks' = event.repository.forks_count int
  • 'issues' = event.repository.open_issues_count int
  • 'commit' = event.deployment.sha string
  • 'task' = event.deployment.task string
  • 'environment' = event.deployment.evnironment string
  • 'description' = event.deployment.description string
deployment_status event

Tags:

  • 'event' = headers[X-Github-Event] string
  • 'repository' = event.repository.full_name string
  • 'private' = event.repository.private bool
  • 'user' = event.sender.login string
  • 'admin' = event.sender.site_admin bool

Fields:

  • 'stars' = event.repository.stargazers_count int
  • 'forks' = event.repository.forks_count int
  • 'issues' = event.repository.open_issues_count int
  • 'commit' = event.deployment.sha string
  • 'task' = event.deployment.task string
  • 'environment' = event.deployment.evnironment string
  • 'description' = event.deployment.description string
  • 'depState' = event.deployment_status.state string
  • 'depDescription' = event.deployment_status.description string
fork event

Tags:

  • 'event' = headers[X-Github-Event] string
  • 'repository' = event.repository.full_name string
  • 'private' = event.repository.private bool
  • 'user' = event.sender.login string
  • 'admin' = event.sender.site_admin bool

Fields:

  • 'stars' = event.repository.stargazers_count int
  • 'forks' = event.repository.forks_count int
  • 'issues' = event.repository.open_issues_count int
  • 'forkee' = event.forkee.repository string
gollum event

Tags:

  • 'event' = headers[X-Github-Event] string
  • 'repository' = event.repository.full_name string
  • 'private' = event.repository.private bool
  • 'user' = event.sender.login string
  • 'admin' = event.sender.site_admin bool

Fields:

  • 'stars' = event.repository.stargazers_count int
  • 'forks' = event.repository.forks_count int
  • 'issues' = event.repository.open_issues_count int
issue_comment event

Tags:

  • 'event' = headers[X-Github-Event] string
  • 'repository' = event.repository.full_name string
  • 'private' = event.repository.private bool
  • 'user' = event.sender.login string
  • 'admin' = event.sender.site_admin bool
  • 'issue' = event.issue.number int

Fields:

  • 'stars' = event.repository.stargazers_count int
  • 'forks' = event.repository.forks_count int
  • 'issues' = event.repository.open_issues_count int
  • 'title' = event.issue.title string
  • 'comments' = event.issue.comments int
  • 'body' = event.comment.body string
issues event

Tags:

  • 'event' = headers[X-Github-Event] string
  • 'repository' = event.repository.full_name string
  • 'private' = event.repository.private bool
  • 'user' = event.sender.login string
  • 'admin' = event.sender.site_admin bool
  • 'issue' = event.issue.number int
  • 'action' = event.action string

Fields:

  • 'stars' = event.repository.stargazers_count int
  • 'forks' = event.repository.forks_count int
  • 'issues' = event.repository.open_issues_count int
  • 'title' = event.issue.title string
  • 'comments' = event.issue.comments int
member event

Tags:

  • 'event' = headers[X-Github-Event] string
  • 'repository' = event.repository.full_name string
  • 'private' = event.repository.private bool
  • 'user' = event.sender.login string
  • 'admin' = event.sender.site_admin bool

Fields:

  • 'stars' = event.repository.stargazers_count int
  • 'forks' = event.repository.forks_count int
  • 'issues' = event.repository.open_issues_count int
  • 'newMember' = event.sender.login string
  • 'newMemberStatus' = event.sender.site_admin bool
membership event

Tags:

  • 'event' = headers[X-Github-Event] string
  • 'user' = event.sender.login string
  • 'admin' = event.sender.site_admin bool
  • 'action' = event.action string

Fields:

  • 'newMember' = event.sender.login string
  • 'newMemberStatus' = event.sender.site_admin bool
page_build event

Tags:

  • 'event' = headers[X-Github-Event] string
  • 'repository' = event.repository.full_name string
  • 'private' = event.repository.private bool
  • 'user' = event.sender.login string
  • 'admin' = event.sender.site_admin bool

Fields:

  • 'stars' = event.repository.stargazers_count int
  • 'forks' = event.repository.forks_count int
  • 'issues' = event.repository.open_issues_count int
public event

Tags:

  • 'event' = headers[X-Github-Event] string
  • 'repository' = event.repository.full_name string
  • 'private' = event.repository.private bool
  • 'user' = event.sender.login string
  • 'admin' = event.sender.site_admin bool

Fields:

  • 'stars' = event.repository.stargazers_count int
  • 'forks' = event.repository.forks_count int
  • 'issues' = event.repository.open_issues_count int
pull_request_review_comment event

Tags:

  • 'event' = headers[X-Github-Event] string
  • 'action' = event.action string
  • 'repository' = event.repository.full_name string
  • 'private' = event.repository.private bool
  • 'user' = event.sender.login string
  • 'admin' = event.sender.site_admin bool
  • 'prNumber' = event.pull_request.number int

Fields:

  • 'stars' = event.repository.stargazers_count int
  • 'forks' = event.repository.forks_count int
  • 'issues' = event.repository.open_issues_count int
  • 'state' = event.pull_request.state string
  • 'title' = event.pull_request.title string
  • 'comments' = event.pull_request.comments int
  • 'commits' = event.pull_request.commits int
  • 'additions' = event.pull_request.additions int
  • 'deletions' = event.pull_request.deletions int
  • 'changedFiles' = event.pull_request.changed_files int
  • 'commentFile' = event.comment.file string
  • 'comment' = event.comment.body string
pull_request event

Tags:

  • 'event' = headers[X-Github-Event] string
  • 'action' = event.action string
  • 'repository' = event.repository.full_name string
  • 'private' = event.repository.private bool
  • 'user' = event.sender.login string
  • 'admin' = event.sender.site_admin bool
  • 'prNumber' = event.pull_request.number int

Fields:

  • 'stars' = event.repository.stargazers_count int
  • 'forks' = event.repository.forks_count int
  • 'issues' = event.repository.open_issues_count int
  • 'state' = event.pull_request.state string
  • 'title' = event.pull_request.title string
  • 'comments' = event.pull_request.comments int
  • 'commits' = event.pull_request.commits int
  • 'additions' = event.pull_request.additions int
  • 'deletions' = event.pull_request.deletions int
  • 'changedFiles' = event.pull_request.changed_files int
push event

Tags:

  • 'event' = headers[X-Github-Event] string
  • 'repository' = event.repository.full_name string
  • 'private' = event.repository.private bool
  • 'user' = event.sender.login string
  • 'admin' = event.sender.site_admin bool

Fields:

  • 'stars' = event.repository.stargazers_count int
  • 'forks' = event.repository.forks_count int
  • 'issues' = event.repository.open_issues_count int
  • 'ref' = event.ref string
  • 'before' = event.before string
  • 'after' = event.after string
repository event

Tags:

  • 'event' = headers[X-Github-Event] string
  • 'repository' = event.repository.full_name string
  • 'private' = event.repository.private bool
  • 'user' = event.sender.login string
  • 'admin' = event.sender.site_admin bool

Fields:

  • 'stars' = event.repository.stargazers_count int
  • 'forks' = event.repository.forks_count int
  • 'issues' = event.repository.open_issues_count int
release event

Tags:

  • 'event' = headers[X-Github-Event] string
  • 'repository' = event.repository.full_name string
  • 'private' = event.repository.private bool
  • 'user' = event.sender.login string
  • 'admin' = event.sender.site_admin bool

Fields:

  • 'stars' = event.repository.stargazers_count int
  • 'forks' = event.repository.forks_count int
  • 'issues' = event.repository.open_issues_count int
  • 'tagName' = event.release.tag_name string
status event

Tags:

  • 'event' = headers[X-Github-Event] string
  • 'repository' = event.repository.full_name string
  • 'private' = event.repository.private bool
  • 'user' = event.sender.login string
  • 'admin' = event.sender.site_admin bool

Fields:

  • 'stars' = event.repository.stargazers_count int
  • 'forks' = event.repository.forks_count int
  • 'issues' = event.repository.open_issues_count int
  • 'commit' = event.sha string
  • 'state' = event.state string
team_add event

Tags:

  • 'event' = headers[X-Github-Event] string
  • 'repository' = event.repository.full_name string
  • 'private' = event.repository.private bool
  • 'user' = event.sender.login string
  • 'admin' = event.sender.site_admin bool

Fields:

  • 'stars' = event.repository.stargazers_count int
  • 'forks' = event.repository.forks_count int
  • 'issues' = event.repository.open_issues_count int
  • 'teamName' = event.team.name string
watch event

Tags:

  • 'event' = headers[X-Github-Event] string
  • 'repository' = event.repository.full_name string
  • 'private' = event.repository.private bool
  • 'user' = event.sender.login string
  • 'admin' = event.sender.site_admin bool

Fields:

  • 'stars' = event.repository.stargazers_count int
  • 'forks' = event.repository.forks_count int
  • 'issues' = event.repository.open_issues_count int

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommitCommentEventJSON

func CommitCommentEventJSON() string

func CreateEventJSON

func CreateEventJSON() string

func DeleteEventJSON

func DeleteEventJSON() string

func DeploymentEventJSON

func DeploymentEventJSON() string

func DeploymentStatusEventJSON

func DeploymentStatusEventJSON() string

func ForkEventJSON

func ForkEventJSON() string

func GollumEventJSON

func GollumEventJSON() string

func IssueCommentEventJSON

func IssueCommentEventJSON() string

func IssuesEventJSON

func IssuesEventJSON() string

func MemberEventJSON

func MemberEventJSON() string

func MembershipEventJSON

func MembershipEventJSON() string

func PageBuildEventJSON

func PageBuildEventJSON() string

func PublicEventJSON

func PublicEventJSON() string

func PullRequestEventJSON

func PullRequestEventJSON() string

func PullRequestReviewCommentEventJSON

func PullRequestReviewCommentEventJSON() string

func PushEventJSON

func PushEventJSON() string

func ReleaseEventJSON

func ReleaseEventJSON() string

func RepositoryEventJSON

func RepositoryEventJSON() string

func StatusEventJSON

func StatusEventJSON() string

func TeamAddEventJSON

func TeamAddEventJSON() string

func WatchEventJSON

func WatchEventJSON() string

Types

type CommitComment

type CommitComment struct {
	Commit string `json:"commit_id"`
	Body   string `json:"body"`
}

type CommitCommentEvent

type CommitCommentEvent struct {
	Comment    CommitComment `json:"comment"`
	Repository Repository    `json:"repository"`
	Sender     Sender        `json:"sender"`
}

func (CommitCommentEvent) NewPoint

func (s CommitCommentEvent) NewPoint() *client.Point

type CreateEvent

type CreateEvent struct {
	Ref        string     `json:"ref"`
	RefType    string     `json:"ref_type"`
	Repository Repository `json:"repository"`
	Sender     Sender     `json:"sender"`
}

func (CreateEvent) NewPoint

func (s CreateEvent) NewPoint() *client.Point

type DeleteEvent

type DeleteEvent struct {
	Ref        string     `json:"ref"`
	RefType    string     `json:"ref_type"`
	Repository Repository `json:"repository"`
	Sender     Sender     `json:"sender"`
}

func (DeleteEvent) NewPoint

func (s DeleteEvent) NewPoint() *client.Point

type Deployment

type Deployment struct {
	Commit      string `json:"sha"`
	Task        string `json:"task"`
	Environment string `json:"environment"`
	Description string `json:"description"`
}

type DeploymentEvent

type DeploymentEvent struct {
	Deployment Deployment `json:"deployment"`
	Repository Repository `json:"repository"`
	Sender     Sender     `json:"sender"`
}

func (DeploymentEvent) NewPoint

func (s DeploymentEvent) NewPoint() *client.Point

type DeploymentStatus

type DeploymentStatus struct {
	State       string `json:"state"`
	Description string `json:"description"`
}

type DeploymentStatusEvent

type DeploymentStatusEvent struct {
	Deployment       Deployment       `json:"deployment"`
	DeploymentStatus DeploymentStatus `json:"deployment_status"`
	Repository       Repository       `json:"repository"`
	Sender           Sender           `json:"sender"`
}

func (DeploymentStatusEvent) NewPoint

func (s DeploymentStatusEvent) NewPoint() *client.Point

type Event

type Event interface {
	NewPoint() *client.Point
}

func NewEvent

func NewEvent(r []byte, t string) (Event, error)

type ForkEvent

type ForkEvent struct {
	Forkee     Repository `json:"forkee"`
	Repository Repository `json:"repository"`
	Sender     Sender     `json:"sender"`
}

func (ForkEvent) NewPoint

func (s ForkEvent) NewPoint() *client.Point

type GithubWebhooks

type GithubWebhooks struct {
	ServiceAddress string
	// Lock for the struct
	sync.Mutex
	// contains filtered or unexported fields
}

func NewGithubWebhooks

func NewGithubWebhooks() *GithubWebhooks

func (*GithubWebhooks) Description

func (gh *GithubWebhooks) Description() string

func (*GithubWebhooks) Gather

func (gh *GithubWebhooks) Gather(acc inputs.Accumulator) error

Writes the points from <-gh.in to the Accumulator

func (*GithubWebhooks) Listen

func (gh *GithubWebhooks) Listen()

func (*GithubWebhooks) SampleConfig

func (gh *GithubWebhooks) SampleConfig() string

func (*GithubWebhooks) Start

func (gh *GithubWebhooks) Start() error

func (*GithubWebhooks) Stop

func (gh *GithubWebhooks) Stop()

type GollumEvent

type GollumEvent struct {
	Pages      []Page     `json:"pages"`
	Repository Repository `json:"repository"`
	Sender     Sender     `json:"sender"`
}

func (GollumEvent) NewPoint

func (s GollumEvent) NewPoint() *client.Point

REVIEW: Going to be lazy and not deal with the pages.

type Issue

type Issue struct {
	Number   int    `json:"number"`
	Title    string `json:"title"`
	Comments int    `json:"comments"`
}

type IssueComment

type IssueComment struct {
	Body string `json:"body"`
}

type IssueCommentEvent

type IssueCommentEvent struct {
	Issue      Issue        `json:"issue"`
	Comment    IssueComment `json:"comment"`
	Repository Repository   `json:"repository"`
	Sender     Sender       `json:"sender"`
}

func (IssueCommentEvent) NewPoint

func (s IssueCommentEvent) NewPoint() *client.Point

type IssuesEvent

type IssuesEvent struct {
	Action     string     `json:"action"`
	Issue      Issue      `json:"issue"`
	Repository Repository `json:"repository"`
	Sender     Sender     `json:"sender"`
}

func (IssuesEvent) NewPoint

func (s IssuesEvent) NewPoint() *client.Point

type MemberEvent

type MemberEvent struct {
	Member     Sender     `json:"member"`
	Repository Repository `json:"repository"`
	Sender     Sender     `json:"sender"`
}

func (MemberEvent) NewPoint

func (s MemberEvent) NewPoint() *client.Point

type MembershipEvent

type MembershipEvent struct {
	Action string `json:"action"`
	Member Sender `json:"member"`
	Sender Sender `json:"sender"`
	Team   Team   `json:"team"`
}

func (MembershipEvent) NewPoint

func (s MembershipEvent) NewPoint() *client.Point

type Page

type Page struct {
	Name   string `json:"page_name"`
	Title  string `json:"title"`
	Action string `json:"action"`
}

type PageBuildEvent

type PageBuildEvent struct {
	Repository Repository `json:"repository"`
	Sender     Sender     `json:"sender"`
}

func (PageBuildEvent) NewPoint

func (s PageBuildEvent) NewPoint() *client.Point

type PublicEvent

type PublicEvent struct {
	Repository Repository `json:"repository"`
	Sender     Sender     `json:"sender"`
}

func (PublicEvent) NewPoint

func (s PublicEvent) NewPoint() *client.Point

type PullRequest

type PullRequest struct {
	Number       int    `json:"number"`
	State        string `json:"state"`
	Title        string `json:"title"`
	Comments     int    `json:"comments"`
	Commits      int    `json:"commits"`
	Additions    int    `json:"additions"`
	Deletions    int    `json:"deletions"`
	ChangedFiles int    `json:"changed_files"`
}

type PullRequestEvent

type PullRequestEvent struct {
	Action      string      `json:"action"`
	PullRequest PullRequest `json:"pull_request"`
	Repository  Repository  `json:"repository"`
	Sender      Sender      `json:"sender"`
}

func (PullRequestEvent) NewPoint

func (s PullRequestEvent) NewPoint() *client.Point

type PullRequestReviewComment

type PullRequestReviewComment struct {
	File    string `json:"path"`
	Comment string `json:"body"`
}

type PullRequestReviewCommentEvent

type PullRequestReviewCommentEvent struct {
	Comment     PullRequestReviewComment `json:"comment"`
	PullRequest PullRequest              `json:"pull_request"`
	Repository  Repository               `json:"repository"`
	Sender      Sender                   `json:"sender"`
}

func (PullRequestReviewCommentEvent) NewPoint

func (s PullRequestReviewCommentEvent) NewPoint() *client.Point

type PushEvent

type PushEvent struct {
	Ref        string     `json:"ref"`
	Before     string     `json:"before"`
	After      string     `json:"after"`
	Repository Repository `json:"repository"`
	Sender     Sender     `json:"sender"`
}

func (PushEvent) NewPoint

func (s PushEvent) NewPoint() *client.Point

type Release

type Release struct {
	TagName string `json:"tag_name"`
}

type ReleaseEvent

type ReleaseEvent struct {
	Release    Release    `json:"release"`
	Repository Repository `json:"repository"`
	Sender     Sender     `json:"sender"`
}

func (ReleaseEvent) NewPoint

func (s ReleaseEvent) NewPoint() *client.Point

type Repository

type Repository struct {
	Repository string `json:"full_name"`
	Private    bool   `json:"private"`
	Stars      int    `json:"stargazers_count"`
	Forks      int    `json:"forks_count"`
	Issues     int    `json:"open_issues_count"`
}

type RepositoryEvent

type RepositoryEvent struct {
	Repository Repository `json:"repository"`
	Sender     Sender     `json:"sender"`
}

func (RepositoryEvent) NewPoint

func (s RepositoryEvent) NewPoint() *client.Point

type Sender

type Sender struct {
	User  string `json:"login"`
	Admin bool   `json:"site_admin"`
}

type StatusEvent

type StatusEvent struct {
	Commit     string     `json:"sha"`
	State      string     `json:"state"`
	Repository Repository `json:"repository"`
	Sender     Sender     `json:"sender"`
}

func (StatusEvent) NewPoint

func (s StatusEvent) NewPoint() *client.Point

type Team

type Team struct {
	Name string `json:"name"`
}

type TeamAddEvent

type TeamAddEvent struct {
	Team       Team       `json:"team"`
	Repository Repository `json:"repository"`
	Sender     Sender     `json:"sender"`
}

func (TeamAddEvent) NewPoint

func (s TeamAddEvent) NewPoint() *client.Point

type WatchEvent

type WatchEvent struct {
	Repository Repository `json:"repository"`
	Sender     Sender     `json:"sender"`
}

func (WatchEvent) NewPoint

func (s WatchEvent) NewPoint() *client.Point

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL