Menu
Grafana Cloud

GitHub integration for Grafana Cloud

GitHub is a provider of Internet hosting for software development and version control using Git.

This integration includes 2 pre-built dashboards to help monitor and visualize GitHub metrics.

Before you begin

It is advised that you provide a GitHub personal access token so that the API ratelimit is not reached prematurely.

We strongly recommend that you give it only the strictly mandatory security privileges necessary for monitoring your repositories, which are all read-only, as per the official documentation.

Install GitHub integration for Grafana Cloud

  1. In your Grafana Cloud stack, click Connections in the left-hand menu.
  2. Find GitHub and click its tile to open the integration.
  3. Review the prerequisites in the Configuration Details tab and set up Grafana Agent to send GitHub metrics to your Grafana Cloud instance.
  4. Click Install to add this integration’s pre-built dashboards to your Grafana Cloud instance, and you can start monitoring your GitHub setup.

Post-install configuration for the GitHub integration

This integration is configured to work with the Github exporter, which is embedded in the Grafana Agent.

Enable the integration by adding the provided snippet to your agent configuration file.

In the agent configuration file, you must specify the repositories for which you wish to collect statistics. This can be a combination of specifying entire orgs, or users, and listing repositories explicitly. We also recommend that you use the api_token_file parameter to avoid setting the authentication token directly on the agent config file.

For a full description of configuration options see how to configure the github_exporter_config block in the agent documentation.

Configuration snippets for Grafana Agent

Below integrations, insert the following lines and change the URLs according to your environment:

yaml
  github_exporter:
    enabled: true
    api_token: '<your github api token>'
    repositories:
    - grafana/agent
    relabel_configs:
    - replacement: '<your-instance-name>'
      target_label: instance

Full example configuration for Grafana Agent

Refer to the following Grafana Agent configuration for a complete example that contains all the snippets used for the GitHub integration. This example also includes metrics that are sent to monitor your Grafana Agent instance.

yaml
integrations:
  prometheus_remote_write:
  - basic_auth:
      password: <your_prom_pass>
      username: <your_prom_user>
    url: <your_prom_url>
  agent:
    enabled: true
    relabel_configs:
    - action: replace
      source_labels:
      - agent_hostname
      target_label: instance
    - action: replace
      target_label: job
      replacement: "integrations/agent-check"
    metric_relabel_configs:
    - action: keep
      regex: (prometheus_target_sync_length_seconds_sum|prometheus_target_scrapes_.*|prometheus_target_interval.*|prometheus_sd_discovered_targets|agent_build.*|agent_wal_samples_appended_total|process_start_time_seconds)
      source_labels:
      - __name__
  # Add here any snippet that belongs to the `integrations` section.
  # For a correct indentation, paste snippets copied from Grafana Cloud at the beginning of the line.
  github_exporter:
    enabled: true
    api_token: '<your github api token>'
    repositories:
    - grafana/agent
    relabel_configs:
    - replacement: '<your-instance-name>'
      target_label: instance
logs:
  configs:
  - clients:
    - basic_auth:
        password: <your_loki_pass>
        username: <your_loki_user>
      url: <your_loki_url>
    name: integrations
    positions:
      filename: /tmp/positions.yaml
    scrape_configs:
      # Add here any snippet that belongs to the `logs.configs.scrape_configs` section.
      # For a correct indentation, paste snippets copied from Grafana Cloud at the beginning of the line.
metrics:
  configs:
  - name: integrations
    remote_write:
    - basic_auth:
        password: <your_prom_pass>
        username: <your_prom_user>
      url: <your_prom_url>
    scrape_configs:
      # Add here any snippet that belongs to the `metrics.configs.scrape_configs` section.
      # For a correct indentation, paste snippets copied from Grafana Cloud at the beginning of the line.
  global:
    scrape_interval: 60s
  wal_directory: /tmp/grafana-agent-wal

Dashboards

The GitHub integration installs the following dashboards in your Grafana Cloud instance to help monitor your system.

  • GitHub API Usage
  • GitHub Repository Stats

Metrics

The most important metrics provided by the GitHub integration, which are used on the pre-built dashboards, are as follows:

  • github_rate_limit
  • github_rate_remaining
  • github_repo_forks
  • github_repo_open_issues
  • github_repo_pull_request_count
  • github_repo_size_kb
  • github_repo_stars
  • github_repo_watchers

Changelog

md
# 0.0.5 - September 2023

* Update Grafana Agent configuration snippets to include filtered metrics used in gauge panels

# 0.0.4 - August 2023

* New Filter Metrics option for configuring the Grafana Agent, which saves on metrics cost by dropping any metric not used by this integration. Beware that anything custom built using metrics that are not on the snippet will stop working.
* New hostname relabel option, which applies the instance name you write on the text box to the Grafana Agent configuration snippets, making it easier and less error prone to configure this mandatory label.

# 0.0.3 - September 2022

* Update dashboard panels descriptions.

# 0.0.2 - October 2021

* Update mixin to latest version:
  - Update the datasource template variable label to 'Data Source'

# 0.0.1 - August 2021

* Initial release

Cost

By connecting your GitHub instance to Grafana Cloud, you might incur charges. To view information on the number of active series that your Grafana Cloud account uses for metrics included in each Cloud tier, see Active series and dpm usage and Cloud tier pricing.