Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Main (unreleased)

- Add htpasswd file based authentication for `otelcol.auth.basic` (@pkarakal)

- A new `otelcol.receiver.github` component which collects data from Github. (@matt-gp)

### Enhancements

- update promtail converter to use `file_match` block for `loki.source.file` instead of going through `local.file_match`. (@kalleep)
Expand Down
295 changes: 295 additions & 0 deletions docs/sources/reference/components/otelcol/otelcol.receiver.github.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,295 @@
---
canonical: https://grafana.com/docs/alloy/latest/reference/components/otelcol/otelcol.receiver.github/
description: Learn about otelcol.receiver.github
labels:
stage: experimental
products:
- oss
title: otelcol.receiver.github
---

# `otelcol.receiver.github`

{{< docs/shared lookup="stability/experimental.md" source="alloy" version="<ALLOY_VERSION>" >}}

`otelcol.receiver.github` collect metrics about repositories, pull requests, branches, and contributors. It can also be configured to receive webhook events from Github Actions and convert these into traces.

You can specify multiple `otelcol.receiver.github` components by giving them different labels.

Ensure you have the following:

- A GitHub Personal Access Token or GitHub App with appropriate permissions
- For metrics: Read access to target repositories and organizations
- For webhooks: A publicly accessible endpoint to receive GitHub webhook events
- Network connectivity to GitHub API endpoints, for example, `api.github.com` or your GitHub Enterprise instance

{{< admonition type="note" >}}
`otelcol.receiver.github` is a wrapper over the upstream OpenTelemetry Collector [`github`][] receiver.
Bug reports or feature requests will be redirected to the upstream repository, if necessary.

[`github`]: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/{{< param "OTEL_VERSION" >}}/receiver/githubreceiver
{{< /admonition >}}

## Usage

```alloy
otelcol.receiver.github "<LABEL>" {
scraper {
github_org = "<GITHUB_ORG>"
auth {
authenticator = <AUTH_HANDLER>
}
}

output {
metrics = [...]
}
}
```

## Arguments

You can use the following arguments with `otelcol.receiver.github`:

| Name | Type | Description | Default | Required |
| --------------------- | ---------- | ---------------------------------------------------- | ------- | -------- |
| `collection_interval` | `duration` | How often to scrape metrics from GitHub. | `"30s"` | no |
| `initial_delay` | `duration` | Defines how long the receiver waits before starting. | `"0s"` | no |

## Blocks

You can use the following blocks with `otelcol.receiver.github`:

| Block | Description | Required |
| -------------------------------- | -------------------------------------------------------------------------- | -------- |
| [`output`][output] | Configures where to send received telemetry data. | yes |
| [`debug_metrics`][debug_metrics] | Configures the metrics that this component generates to monitor its state. | no |
| [`scraper`][scraper] | Configures the GitHub scraper. | no |
| `scraper` > [`auth`][auth] | Configures authentication for GitHub API. | yes |
| `scraper` > [`metrics`][metrics] | Configures which metrics to collect. | no |
| [`webhook`][webhook] | Configures webhook receiver for GitHub Actions events. | no |

The > symbol indicates deeper levels of nesting.
For example, `scraper` > `auth` refers to an `auth` block defined inside a `scraper` block.

[scraper]: #scraper
[webhook]: #webhook
[output]: #output
[debug_metrics]: #debug_metrics
[auth]: #auth
[metrics]: #metrics

### `scraper`

The `scraper` block configures the GitHub metrics scraper.

The following arguments are supported:

| Name | Type | Description | Default | Required |
| -------------- | -------- | ---------------------------------------------------- | ------- | -------- |
| `github_org` | `string` | GitHub organization or user to scrape metrics from. | | yes |
| `endpoint` | `string` | GitHub API endpoint for GitHub Enterprise instances. | | no |
| `search_query` | `string` | Custom search query to filter repositories. | | no |

### `auth`

The `auth` block configures authentication for the GitHub API.

The following arguments are supported:

| Name | Type | Description | Default | Required |
| --------------- | -------------------------- | ------------------------------------------------ | ------- | -------- |
| `authenticator` | `capsule(otelcol.Handler)` | Auth handler from an `otelcol.auth.*` component. | | yes |

### `metrics`

The `metrics` block allows you to enable or disable specific metrics. Each metric is configured with a nested block.

Available metrics:

| Metric Name | Description | Default |
| ----------------------------- | ---------------------------------------------- | ------- |
| `vcs.change.count` | Number of changes (pull requests) by state. | `true` |
| `vcs.change.duration` | Time a change spent in various states. | `true` |
| `vcs.change.time_to_approval` | Time it took for a change to get approved. | `true` |
| `vcs.change.time_to_merge` | Time it took for a change to be merged. | `true` |
| `vcs.contributor.count` | Number of unique contributors to a repository. | `false` |
| `vcs.ref.count` | Number of refs (branches) in a repository. | `true` |
| `vcs.ref.lines_delta` | Number of lines changed in a ref. | `true` |
| `vcs.ref.revisions_delta` | Number of commits (revisions) in a ref. | `true` |
| `vcs.ref.time` | Time since the ref was created. | `true` |
| `vcs.repository.count` | Number of repositories in an organization. | `true` |

Each metric can be configured with:

```alloy
metrics {
vcs.change.count {
enabled = true
}
vcs.contributor.count {
enabled = false
}
}
```

### `webhook`

The `webhook` block configures webhook reception for GitHub Actions events.

When enabled, this block allows the receiver to convert GitHub Actions workflow and job events into traces.

{{< admonition type="note" >}}
Ensure your webhook endpoint is secured with a secret and protected by appropriate network security measures.
{{< /admonition >}}

The following arguments are supported:

| Name | Type | Description | Default | Required |
|---------------------|-------------------|-----------------------------------------------------------|-------------------|----------|
| `endpoint` | `string` | The `host:port` to listen for webhooks on. | `"localhost:8080"`| no |
| `path` | `string` | URL path for webhook events. | `"/events"` | no |
| `health_path` | `string` | URL path for health checks. | `"/health"` | no |
| `secret` | `string` | Secret for validating webhook signatures. | | no |
| `required_headers` | `map(string)` | Required headers that must be present on webhook requests.| | no |

### `output`

{{< badge text="Required" >}}

{{< docs/shared lookup="reference/components/output-block.md" source="alloy" version="<ALLOY_VERSION>" >}}

### `debug_metrics`

{{< docs/shared lookup="reference/components/otelcol-debug-metrics-block.md" source="alloy" version="<ALLOY_VERSION>" >}}

## Exported fields

`otelcol.receiver.github` doesn't export any fields.

## Component health

`otelcol.receiver.github` is reported as unhealthy if the GitHub API can't be reached or authentication fails.

## Debug information

`otelcol.receiver.github` doesn't expose additional debug info.

## Example

### Basic configuration

This example scrapes metrics from a GitHub organization:

```alloy
otelcol.auth.bearer "github" {
token = env("GITHUB_PAT")
}

otelcol.receiver.github "default" {
collection_interval = "5m"

scraper {
github_org = "grafana"
search_query = "org:grafana topic:observability"

auth {
authenticator = otelcol.auth.bearer.github.handler
}

metrics {
vcs.change.count {
enabled = true
}
vcs.change.time_to_merge {
enabled = true
}
vcs.repository.count {
enabled = true
}
vcs.contributor.count {
enabled = true
}
}
}

output {
metrics = [otelcol.exporter.prometheus.default.input]
}
}

otelcol.exporter.prometheus "default" {
forward_to = [prometheus.remote_write.default.receiver]
}

prometheus.remote_write "default" {
endpoint {
url = "https://prometheus.example.com/api/v1/write"
}
}
```

### With webhook for GitHub Actions traces

This example adds webhook support to receive GitHub Actions workflow events as traces:

```alloy
otelcol.auth.bearer "github" {
token = env("GITHUB_PAT")
}

otelcol.receiver.github "default" {
scraper {
github_org = "my-org"
auth {
authenticator = otelcol.auth.bearer.github.handler
}
}

webhook {
endpoint = "0.0.0.0:8080"
path = "/github/webhooks"
health_path = "/health"
secret = env("GITHUB_WEBHOOK_SECRET")
}

output {
metrics = [otelcol.exporter.otlphttp.default.input]
traces = [otelcol.exporter.otlphttp.default.input]
}
}

otelcol.exporter.otlphttp "default" {
client {
endpoint = "https://otlp.example.com"
}
}
```

### GitHub Enterprise

For GitHub Enterprise instances, specify the custom endpoint:

```alloy
otelcol.auth.bearer "github_enterprise" {
token = env("GHE_PAT")
}

otelcol.receiver.github "enterprise" {
scraper {
github_org = "my-enterprise-org"
endpoint = "https://github.mycompany.com"

auth {
authenticator = otelcol.auth.bearer.github_enterprise.handler
}
}

output {
metrics = [otelcol.exporter.prometheus.default.input]
}
}
```

<!-- START GENERATED COMPATIBLE COMPONENTS -->
<!-- END GENERATED COMPATIBLE COMPONENTS -->
18 changes: 8 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,6 @@ require (
github.com/ProtonMail/go-crypto v1.1.6 // indirect
github.com/Shopify/sarama v1.38.1 // indirect
github.com/Showmax/go-fqdn v1.0.0 // indirect
github.com/Workiva/go-datastructures v1.1.6 // indirect
github.com/alecthomas/participle/v2 v2.1.4 // indirect
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
github.com/andybalholm/brotli v1.2.0 // indirect
Expand Down Expand Up @@ -499,14 +498,11 @@ require (
github.com/aws/aws-sdk-go-v2/service/storagegateway v1.34.8 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.38.9 // indirect
github.com/aws/smithy-go v1.23.1 // indirect
github.com/axiomhq/hyperloglog v0.2.5 // indirect
github.com/bahlo/generic-list-go v0.2.0 // indirect
github.com/bboreham/go-loser v0.0.0-20230920113527-fcc2c21820a3 // indirect
github.com/beevik/ntp v1.3.0 // indirect
github.com/benbjohnson/clock v1.3.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.22.0 // indirect
github.com/bits-and-blooms/bloom/v3 v3.7.0 // indirect
github.com/bmatcuk/doublestar/v4 v4.9.1 // indirect
github.com/caarlos0/env/v9 v9.0.0
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
Expand Down Expand Up @@ -539,7 +535,6 @@ require (
github.com/dennwc/ioctl v1.0.0 // indirect
github.com/dennwc/varint v1.0.0 // indirect
github.com/denverdino/aliyungo v0.0.0-20190125010748-a747050bb1ba // indirect
github.com/dgryski/go-metro v0.0.0-20180109044635-280f6062b5bc // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/digitalocean/godo v1.165.1 // indirect
github.com/distribution/reference v0.6.0 // indirect
Expand Down Expand Up @@ -627,7 +622,6 @@ require (
github.com/grafana/jvmtools v0.0.3 // indirect
github.com/grafana/otel-profiling-go v0.5.1 // indirect
github.com/grobie/gomemcache v0.0.0-20230213081705-239240bbc445 // indirect
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.2 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2 // indirect
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
github.com/hashicorp/cronexpr v1.1.3 // indirect
Expand Down Expand Up @@ -667,7 +661,6 @@ require (
github.com/influxdata/influxdb-observability/influx2otel v0.5.12 // indirect
github.com/influxdata/line-protocol v0.0.0-20200327222509-2487e7298839 // indirect
github.com/influxdata/line-protocol/v2 v2.2.1 // indirect
github.com/influxdata/tdigest v0.0.2-0.20210216194612-fc98d27c9e8b // indirect
github.com/ionos-cloud/sdk-go/v6 v6.3.4 // indirect
github.com/itchyny/timefmt-go v0.1.7 // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
Expand All @@ -691,8 +684,6 @@ require (
github.com/joyent/triton-go v1.8.5 // indirect
github.com/jpillora/backoff v1.0.0 // indirect
github.com/jsimonetti/rtnetlink v1.4.2 // indirect
github.com/julienschmidt/httprouter v1.3.0 // indirect
github.com/kamstrup/intmap v0.5.1 // indirect
github.com/karrick/godirwalk v1.17.0 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/klauspost/asmfmt v1.3.2 // indirect
Expand Down Expand Up @@ -975,6 +966,11 @@ require (
sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect
)

require (
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awss3receiver v0.139.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/githubreceiver v0.138.0
)

require (
cyphar.com/go-pathrs v0.2.1 // indirect
github.com/DataDog/datadog-agent/comp/api/api/def v0.73.0-devel.0.20251030121902-cd89eab046d6 // indirect
Expand All @@ -991,6 +987,7 @@ require (
github.com/DataDog/datadog-agent/pkg/opentelemetry-mapping-go/otlp/rum v0.73.0-devel.0.20251030121902-cd89eab046d6 // indirect
github.com/DataDog/datadog-agent/pkg/util/defaultpaths v0.69.3 // indirect
github.com/DataDog/datadog-agent/pkg/util/quantile v0.73.0-devel.0.20251030121902-cd89eab046d6 // indirect
github.com/Khan/genqlient v0.8.1 // indirect
github.com/aws/aws-sdk-go-v2/service/sqs v1.42.11 // indirect
github.com/digitalocean/go-metadata v0.0.0-20250129100319-e3650a3df44b // indirect
github.com/go-openapi/swag/cmdutils v0.25.1 // indirect
Expand All @@ -1004,12 +1001,13 @@ require (
github.com/go-openapi/swag/stringutils v0.25.1 // indirect
github.com/go-openapi/swag/typeutils v0.25.1 // indirect
github.com/go-openapi/swag/yamlutils v0.25.1 // indirect
github.com/google/go-github/v76 v76.0.0 // indirect
github.com/linode/go-metadata v0.2.2 // indirect
github.com/mitchellh/hashstructure v1.1.0 // indirect
github.com/open-telemetry/opamp-go v0.22.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/extension/opampcustommessages v0.139.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awss3receiver v0.139.0 // indirect
github.com/twmb/franz-go/pkg/kadm v1.17.1 // indirect
github.com/vektah/gqlparser/v2 v2.5.22 // indirect
golang.org/x/telemetry v0.0.0-20251008203120-078029d740a8 // indirect
)

Expand Down
Loading