Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README.md: add example for monitoring the github runner #671

Closed
wants to merge 1 commit into from
Closed
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
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ ToC:
- [Stateful Runners](#stateful-runners)
- [Software Installed in the Runner Image](#software-installed-in-the-runner-image)
- [Common Errors](#common-errors)
- [Monitoring](#monitoring)
- [Contributing](#contributing)

## Motivation
Expand Down Expand Up @@ -1132,6 +1133,36 @@ spec:
value: "2" # Remember! env var values must be strings.
```

# Monitoring

The github actions runner API can be used to external monitor
if your github actions runner are online.
The endpoint for an organisation is `https://api.github.com/orgs/<ORG>/actions/runners`,
where `ORG` is the name of the origanisation.
Accessing the API requires github token of a github account that has admin access in the organisation (admin:org scope).
It can be generated here: https://github.com/settings/tokens

The following [telegraf](https://github.com/influxdata/telegraf/) configuration will periodically poll this API endpoint:

```toml
[inputs.http]
# file that contains the github token generated above (starts with `gph_`)
bearer_token = "/var/lib/telegraf/github-token"
data_format = "json"
fielddrop = ["labels_*", "id"]
json_query = "runners"
json_string_fields = ["status", "busy"]
tag_keys = ["os", "name"]
# Replace <ORG> here with the actual github origanisation
urls = ["https://api.github.com/orgs/<ORG>/actions/runners"]
```

From telegraf it can be exported to prometheus or influxdb.

The following example alert condition in prometheus checks if there at least two
online github runner: `count(http_busy{status="online"}) >= 2`


# Contributing

For more details on contributing to the project (including requirements) please check out [Getting Started with Contributing](CONTRIBUTING.md).
For more details on contributing to the project (including requirements) please check out [Getting Started with Contributing](CONTRIBUTING.md).