Skip to main content

GitHub

Logs

Capture GitHub events to:

  • Track issues and PRs opened by your customers
  • Track new features from code changes
  • Identify when new code changes lead to system alerts or build failures

Before you begin, you'll need: Admin permissions to the GitHub project

Add a webhook to your GitHub project

Open your GitHub project. On your project page, go to Setting > Webhooks and select Add webhook.

How to add a GitHub webhook

Add your payload url

For the Payload url, use either of the following formats. You can send your data encrypted via HTTPS, or unencrypted, via HTTP:

For HTTPS shipping

https://<<LISTENER-HOST>>:8071/?token=<<LOG-SHIPPING-TOKEN>>&type=github

For HTTP shipping

http://<<LISTENER-HOST>>:8070/?token=<<LOG-SHIPPING-TOKEN>>&type=github

Replace <<LOG-SHIPPING-TOKEN>> with the token of the account you want to ship to.

Replace <<LISTENER-HOST>> with the host for your region. For example, listener.logz.io if your account is hosted on AWS US East, or listener-nl.logz.io if hosted on Azure West Europe. The required port depends whether HTTP or HTTPS is used: HTTP = 8070, HTTPS = 8071.

Configure your webhook

Complete filling in the form:

  1. Content Type: Select application/json.
  2. Secret: Leave it blank. Your Logz.io account token is used to securely route your logs to your account.
  3. SSL verification: We recommend enabling SSL verification.
  4. Select your event triggers. The options available are:
    • Just the push event
    • Send me everything
    • Let me select individual events. A checklist will appear for you to make your selections.
  5. Active. Make sure this checkbox is enabled.
  6. Click Add webhook to save your webhook.

Check Logz.io for your logs

Give your logs some time to get from your system to ours, and then open Open Search Dashboards. Search for type:github in Open Search Dashboards Discover to filter for your GitHub events. Your logs should be already parsed thanks to the Logz.io preconfigured parsing pipeline.

If you still don't see your logs, see log shipping troubleshooting.

Metrics

GitHub is a Git repository hosting service. Telegraf is a plug-in driven server agent for collecting and sending metrics and events from databases, systems and IoT sensors.

To send your Prometheus-format Github metrics to Logz.io, you need to add the inputs.github and outputs.http plug-ins to your Telegraf configuration file.

Configure Telegraf to send your metrics data to Logz.io

Set up Telegraf v1.17 or higher

For Windows

wget https://dl.influxdata.com/telegraf/releases/telegraf-1.27.3_windows_amd64.zip

After downloading the archive, extract its content into C:\Program Files\Logzio\telegraf\.

The configuration file is located at C:\Program Files\Logzio\telegraf\.

For MacOS

brew install telegraf

The configuration file is located at /usr/local/etc/telegraf.conf.

For Linux

Ubuntu & Debian

sudo apt-get update && sudo apt-get install telegraf

The configuration file is located at /etc/telegraf/telegraf.conf.

RedHat and CentOS

sudo yum install telegraf

The configuration file is located at /etc/telegraf/telegraf.conf.

SLES & openSUSE

# add go repository
zypper ar -f obs://devel:languages:go/ go
# install latest telegraf
zypper in telegraf

The configuration file is located at /etc/telegraf/telegraf.conf.

FreeBSD/PC-BSD

sudo pkg install telegraf

The configuration file is located at /etc/telegraf/telegraf.conf.

Add the inputs.github plug-in

First you need to configure the input plug-in to enable Telegraf to scrape the Github data from your hosts. To do this, add the following code to the configuration file:

[[inputs.github]]
## List of repositories to monitor
repositories = [
"influxdata/telegraf",
"influxdata/influxdb"
]

## Github API access token. Unauthenticated requests are limited to 60 per hour.
# access_token = ""

## Github API enterprise url. Github Enterprise accounts must specify their base url.
# enterprise_base_url = ""

## Timeout for HTTP requests.
# http_timeout = "5s"

## List of additional fields to query.
## NOTE: Getting those fields might involve issuing additional API-calls, so please
## make sure you do not exceed the rate-limit of GitHub.
##
## Available fields are:
## - pull-requests -- number of open and closed pull requests (2 API-calls per repository)
# additional_fields = []
note

The database name is only required for instantiating a connection with the server and does not restrict the databases that we collect metrics from. The full list of data scraping and configuring options can be found here.

Add the outputs.http plug-in

After you create the configuration file, configure the output plug-in to enable Telegraf to send your data to Logz.io in Prometheus-format. To do this, add the following code to the configuration file:

[[outputs.http]]
url = "https://<<LISTENER-HOST>>:8053"
data_format = "prometheusremotewrite"
[outputs.http.headers]
Content-Type = "application/x-protobuf"
Content-Encoding = "snappy"
X-Prometheus-Remote-Write-Version = "0.1.0"
Authorization = "Bearer <<PROMETHEUS-METRICS-SHIPPING-TOKEN>>"

Replace the placeholders to match your specifics. (They are indicated by the double angle brackets << >>):

  • Replace <<LISTENER-HOST>> with the Logz.io Listener URL for your region, configured to use port 8052 for http traffic, or port 8053 for https traffic. For example, listener.logz.io if your account is hosted on AWS US East, or listener-nl.logz.io if hosted on Azure West Europe.
  • Replace <<PROMETHEUS-METRICS-SHIPPING-TOKEN>> with a token for the Metrics account you want to ship to.
    Here's how to look up your Metrics token.

Check Logz.io for your metrics

Give your data some time to get from your system to ours, then log in to your Logz.io Metrics account, and open the Logz.io Metrics tab.