github-exporter
by lola.2lannoy
Prometheus exporter for GitHub repository, organization and build status metrics (github-exporter) running as a hardened Deployment
About this chart
github-exporter
Prometheus exporter for GitHub repository, organization and build status metrics (github-exporter) running as a hardened Deployment
Runs github-exporter as a single
Deployment. It polls the GitHub API with a token and exports metrics for the
repositories you list (or those of the organizations you list): repository
statistics, open pull requests and issues, and, for the branches you list,
workflow runs, check runs and build status. Each replica would poll GitHub on
its own with the same token and export duplicate series, so keep
replicaCount at 1.
Install
The exporter needs a GitHub token and something to export (github.repos
and/or github.orgs).
The chart never creates the token Secret: the token stays out of Helm values, release history and Git. Create it, then install:
kubectl create namespace github-exporter
kubectl -n github-exporter create secret generic github-exporter --from-literal=token=<token>
helm install github-exporter oci://ghcr.io/spnngl/charts/github-exporter --version <version> -n github-exporter \
--set 'github.repos[0]=spnngl/charts'
The Secret is named after the release (github.existingSecret.name to
override, github.existingSecret.key defaults to token). Without it the pod
stays in CreateContainerConfigError (secret "github-exporter" not found)
until the Secret exists.
Use a dedicated token. Before each rate limit reset the exporter spends
80% of what the token has left (github.rateLimitBuffer), which starves every
other tool sharing the token. The token needs read access to the repositories
it exports (and to Actions and checks when github.branches is set); the
chart was not tested against a real token. For a shared token lower
github.rateLimitBuffer or set github.refreshInterval.
github.repos and github.orgs:
github.repostakesowner/nameentries, or"*"for every repository the token can see.github.orgslists the repositories of each organization.- At least one of them is required: the exporter exits at startup otherwise,
and the chart refuses to render.
github.reposdefaults to a placeholder (d0ugal/github-exporter) that keeps the default render valid. Helm replaces lists instead of merging them, so when you setgithub.orgsonly, also setgithub.repos: [], or the placeholder stays.NOTES.txtwarns while it is there.
The token is visible in the container environment (upstream has no token-file option) and is read at startup: after rotating it, restart the pod,
kubectl -n github-exporter rollout restart deployment/github-exporter
or let Reloader do it with
podAnnotations: {reloader.stakater.com/auto: "true"}.
Image
The default image is appVersion pinned by the digest recorded in the
artifacthub.io/images annotation of Chart.yaml (Renovate updates both
together, weekly). Setting image.tag drops that digest; add image.digest to
pin the tag again (image.digest without image.tag is an error).
The upstream image is not signed (no cosign signature, no attestations beyond the build ones, checked on v0.5.73). The digest pin only guarantees that the same bytes are pulled every time, not who built them.
Configuration
-
Upstream ignores the
server,logging,metrics,tracingandprofilingkeys of its YAML configuration file (an upstream bug: the embedded base configuration is not inlined), and its/page only shows those ignored defaults. The chart therefore has no configuration file: every setting is an environment variable, built from the values. Settings without a value (GITHUB_EXPORTER_GITHUB_TIMEOUT, tracingTRACING_*, profilingPROFILING_*) go throughextraEnv; names the chart owns are rejected. OTLP headers cannot be set at all. -
Entries of
github.orgs,github.repos,github.branchesandgithub.workflowsare joined with commas: they cannot contain commas (workflow names can contain spaces, the others cannot contain whitespace). -
Build status (
github.branches) costs API calls per repository and branch every cycle, and the open pull request counts use the Search API, which allows 30 requests per minute: with more than about 30 repositories the exporter hits that limit on every cycle (github_api_errors_totalwithendpoint="search_issues"; the chart's alert leaves it out for that reason). -
The refresh interval is computed from the remaining rate limit unless you set
github.refreshInterval; it does not account for the Search API limit or for the repositories behindgithub.orgs. -
The exporter never forgets a series. A deleted or renamed repository, and a workflow run
conclusionthat changed, keep their last value until the pod restarts. Alert and graph ongithub_branch_build_status(noconclusionlabel, the worst status of the branch wins), not ongithub_workflow_run_status. -
github_check_run_statushas one series per repository, branch, check and conclusion: with many repositories it dominates the cardinality. Drop it withmetrics.serviceMonitor.metricRelabelings(orpodMonitor) when you do not need it:metricRelabelings: - sourceLabels: [__name__] regex: github_check_run_status action: drop -
The exporter logs every HTTP request at
info, probes and scrapes included;logLevel: warnsilences them. -
/healthanswers 200 once the server listens, whatever GitHub does: a GitHub outage or a bad token never restarts or unreadies the pod. Watchgithub_api_errors_total(or the alerts below) instead.
Resources
Requests 10m CPU / 32Mi memory and a 128Mi memory limit, no CPU limit.
These are estimates, not measurements under a real collection: tune them for
your repository count. With a memory limit set, GOMEMLIMIT follows it, and a
memory resize restarts the container so the value never goes stale.
Security
Defaults satisfy the restricted Pod Security Standard: non-root uid/gid 1000,
read-only root filesystem, all capabilities dropped, no privilege escalation,
RuntimeDefault seccomp, no ServiceAccount token, no Service environment
variables. The exporter writes nothing to disk.
User namespaces
hostUsers: false (default) runs the pod in a user namespace: uid 1000 in the
pod maps to an unprivileged host uid, which limits what a container escape
gains. Nodes need a container runtime with user namespace support (containerd
2.0+ or CRI-O), runc 1.2+ or crun, and a Linux kernel 6.3+; see the Kubernetes
documentation on user namespaces. On other nodes the pod sandbox cannot be
created (FailedCreatePodSandBox event): set hostUsers: true.
Network
-
Warning: upstream cannot turn off its web interface, and the metrics port serves it at
/: it lists the metrics and basic server settings (no token, no repository names; its footer even links to another exporter). The NetworkPolicy (networkPolicy.enabled, on by default) restricts ingress to port 8080, but withnetworkPolicy.metrics.from: []any in-cluster source is allowed: set it to your Prometheus namespace / pods. -
networkPolicy.egress.enabled(off by default) allows DNS, HTTPS to GitHub (api.github.com) andnetworkPolicy.egress.extraEgress(for example a tracing endpoint). GitHub has no stable address, soegress.github.todefaults to any address. Narrow it to GitHub's published ranges (regional/32s serve clusters outside the US and EU):curl -s https://api.github.com/meta | jq '[.api[]] | unique'The list changes over time: refresh it. Override
dns.tofor NodeLocal DNSCache or a non-default DNS namespace. -
metrics.serviceMonitorormetrics.podMonitor(not both) integrate with the Prometheus Operator; a PodMonitor needs no Service. The ClusterIP Service<fullname>-metricson port 8080 is rendered with a ServiceMonitor, or withmetrics.service.enabled. -
metrics.prometheusRuleadds alerts and needs one of the monitors (the rules select thejoblabel it sets; do not rewritejobinrelabelings):GitHubExporterDown(critical, also fires withreplicaCount: 0or a Pending pod),GitHubExporterAPIErrorsandGitHubExporterRateLimitLow(warning). Silence some withmetrics.prometheusRule.disabled. The exporter spends most of the remaining quota before each reset, so the rate limit gauge dips right before it by design: keeprateLimitLowForabove 10 minutes. -
helm testcalls/healththrough the Service. It works with a fake token because/healthdoes not depend on GitHub, so it checks the wiring, not the token. It exists only with the Service and whenreplicaCount> 0, and fails whennetworkPolicy.metrics.fromdoes not allow the test pod.
Compatibility
The values schema is strict: unknown keys fail the install. A breaking change to values bumps the chart MAJOR version; deprecations are announced one MINOR version ahead. Requires Kubernetes 1.33 or later.
Maintainers
| Name | Url | |
|---|---|---|
| spnngl | https://github.com/spnngl |
Source Code
Requirements
Kubernetes: >=1.33.0-0
Values
| Key | Type | Default | Description |
|---|---|---|---|
| affinity | object | {} | Affinity. Empty on purpose: a single replica has nothing to spread. |
| dnsConfig | object | {"options":[{"name":"ndots","value":"2"}]} | DNS config. |
| dnsConfig.options | list | [{"name":"ndots","value":"2"}] | DNS options (fewer search-list lookups for api.github.com). |
| extraEnv | list | [] | Extra environment variables (EnvVar list) for settings without a value: GITHUB_EXPORTER_GITHUB_TIMEOUT, tracing (TRACING_*) and profiling (PROFILING_*). Names the chart owns are rejected. Rendered after GOMEMLIMIT. |
| extraVolumeMounts | list | [] | Extra volume mounts for the exporter container. |
| extraVolumes | list | [] | Extra volumes. |
| fullnameOverride | string | "" | Override the full resource name (default <release>-<chart>). |
| github.branches | list | [] | Branches whose workflow and check run status is exported (github_branch_build_status, github_workflow_run_*, github_check_run_status). Empty: no build status. Each repository and branch costs 2 API calls per cycle, and needs a token that can read Actions and checks. |
| github.existingSecret.key | string | "token" | Key of the token in the Secret. |
| github.existingSecret.name | string | "" | Name of an existing Secret holding the GitHub token. Empty: <fullname>. The chart never creates it: upstream reads the token from its environment only (no file option), so the chart passes it with a secretKeyRef. |
| github.orgs | list | [] | Organizations to export: their repositories are listed and exported. With repos empty and only orgs set, also set repos: [] (the default below is a placeholder). Entries cannot contain commas or whitespace (they are passed comma-separated in an environment variable). |
| github.rateLimitBuffer | float | 0.8 | Share of the remaining API rate limit the exporter may spend before the next reset. With a shared token the exporter starves its other users at the default; lower it, or set refreshInterval. |
| github.refreshInterval | string | "" | Fixed time between collections, a Go duration (5m). Empty: computed from the remaining API rate limit, between 30s and 1h (upstream ignores the Search API limit and the repositories listed through orgs in that computation). Set it when the token is shared with other tools. |
| github.repos | list | ["d0ugal/github-exporter"] | Repositories to export, owner/name, or "*" for every repository the token can see. At least one of orgs and repos is required: the exporter exits at startup without them, and the chart refuses to render. The default is a placeholder that keeps the default render valid and polls a public repository: replace it, or set repos: [] when you use orgs only. |
| github.workflows | list | [] | Workflow names to export. Empty: every workflow. Names can contain spaces but not commas. |
| hostUsers | bool | false | Run the pod in a user namespace (false: uid 1000 maps to an unprivileged host uid). Needs node support (containerd 2.0+ or CRI-O, runc 1.2+, kernel 6.3+); pods fail to start otherwise. true uses host users. |
| image.digest | string | "" | Image digest, only valid together with image.tag. |
| image.pullPolicy | string | "IfNotPresent" | Image pull policy. |
| image.repository | string | "ghcr.io/d0ugal/github-exporter" | Image repository. |
| image.tag | string | "" | Image tag. Empty: appVersion pinned by the digest recorded in Chart.yaml. When set, the chart digest is not applied; add image.digest to pin it. |
| imagePullSecrets | list | [] | Image pull secrets (list of {name: <secret>}). |
| livenessProbe | object | {"failureThreshold":3,"httpGet":{"path":"/health","port":"http-metrics"},"periodSeconds":10} | Liveness probe, /health. A GitHub outage or an invalid token never restarts the pod. |
| logFormat | string | "json" | Log format. |
| logLevel | string | "info" | Log level. |
| metrics.podMonitor.enabled | bool | false | Create a Prometheus Operator PodMonitor (no Service needed). Exclusive with serviceMonitor. |
| metrics.podMonitor.interval | string | "" | Scrape interval (empty: Prometheus default). |
| metrics.podMonitor.labels | object | {} | Extra labels. |
| metrics.podMonitor.metricRelabelings | list | [] | Metric relabelings. |
| metrics.podMonitor.relabelings | list | [] | Relabelings. |
| metrics.podMonitor.scrapeTimeout | string | "" | Scrape timeout (empty: Prometheus default). |
| metrics.prometheusRule.apiErrorsFor | string | "15m" | `GitHubExpo |
Deploy github-exporter with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has github-exporter on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartgithub-exporter is pinned at v0.1.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply