GitHub Metrics

This document contains instructions on how to monitor the GitHub Repos using GitHub Receiver to scrape metrics using GitHub GraphQL and REST APIs.

Prerequisites

Access token is required for scraping the metrics which can be generated in 2 ways.

Setup

Step 1. Setup OTel Collector

The OpenTelemetry (OTel) Collector helps collect telemetry data such as logs, traces and metrics from your application. Please follow the documentation here to setup the OpenTelmetry Collector in your VM. Make sure to use the latest OTel Collector release.

Step 2. Setup GitHub Receiver

Update the config.yaml file that you created in otelcol-contrib folder while setting up OTel Collector to include the github receiver under the receivers section.

/otelcol-contrib/config.yaml

receivers:
  github:
    log_level: debug
    initial_delay: 1s
    collection_interval: 60s
    timeout: 30s
    scrapers:
      scraper:
        github_org: <github-org>
        metrics:
          vcs.contributor.count:
            enabled: true
        auth:
          authenticator: bearertokenauth/github

processors:
  resource/github:
    attributes:
      - key: service.name
        value: <service-name>
        action: insert

extensions:
  bearertokenauth/github:
    token: ${GH_PAT}

  • <github-org>: Your GitHub Org.
  • <service-name>: Specifies the service that emits the metrics, making it easier to identify and filter metrics related to a specific GitHub integration.
  • GH_PAT: This environment variable, which you will create in Step 4, contains your GitHub access token.

Step 3. Add GitHub Receiver to pipelines

In the config.yaml file, under the service section, locate the pipelines block. Within the metrics pipeline, add github to the list of receivers.

/otelcol-contrib/config.yaml
...
service:
  extensions: [bearertokenauth/github]
  pipelines:
    metrics:
      receivers: [github]
      processors: [resource/github]
      exporters: [otlp,debug]
...

Step 4. Run the OTel Collector

Set an environment variable named GH_PAT. Inside otelcol-contrib folder, run the otelcol-contrib command.

export GH_PAT=<access-token>
./otelcol-contrib --config ./config.yaml
  • <access-token>: Your GitHub access token.

Validate Metrics in SigNoz

  • The following default metrics are scraped and can be viewed under the Metrics tab in the SigNoz UI.
GitHub Metrics
Scraped Metrics from GitHub
  • Refer this link for more info on metrics.

Was this page helpful?