https://github.com/nobl9/sloctl
A command line tool to cast SLO spells 🪄
https://github.com/nobl9/sloctl
cli go golang nobl9 reliability slo sre
Last synced: 12 days ago
JSON representation
A command line tool to cast SLO spells 🪄
- Host: GitHub
- URL: https://github.com/nobl9/sloctl
- Owner: nobl9
- License: mpl-2.0
- Created: 2021-02-02T19:57:29.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2026-01-12T15:48:27.000Z (about 2 months ago)
- Last Synced: 2026-01-12T19:48:08.676Z (about 2 months ago)
- Topics: cli, go, golang, nobl9, reliability, slo, sre
- Language: Go
- Homepage: https://docs.nobl9.com/sloctl-user-guide
- Size: 765 MB
- Stars: 39
- Watchers: 4
- Forks: 2
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
Sloctl is a command-line interface (CLI) for [Nobl9](https://www.nobl9.com/).
You can use sloctl to manage multiple Nobl9 configuration objects
such as [SLOs](https://docs.nobl9.com/getting-started/nobl9-resources/slo),
[Projects](https://docs.nobl9.com/getting-started/nobl9-resources/projects)
or [Alert Policies](https://docs.nobl9.com/getting-started/nobl9-resources/alert-policies).
The web user interface is available to give you an easy way to create
and update SLOs and other resources, while sloctl aims to provide a
systematic and automated approach to maintaining SLOs as code.
You can use it in CI/CD or your terminal power-user workflows :fire:
## Usage
Sloctl includes built-in documentation for each command, to access it, run:
```shell
sloctl --help
```
For more details check out
[sloctl user guide](https://docs.nobl9.com/sloctl-user-guide).
If you want to learn how to fully tame the sloctl's potential, see
[recipes](#recipes) section below.
## Install
### Script
The script requires bash and a minimal set of GNU utilities.
On Windows it will work with either MinGW or Cygwin.
You can either pipe it directly into bash or download the file and run it manually.
```bash
# Using curl:
curl -fsSL https://raw.githubusercontent.com/nobl9/sloctl/main/install.bash | bash
# On systems where curl is not available:
wget -O - -q https://raw.githubusercontent.com/nobl9/sloctl/main/install.bash | bash
# If you prefer to first download the script, inspect it and then run it:
curl -fsSL -o install.bash https://raw.githubusercontent.com/nobl9/sloctl/main/install.bash
# Or with wget:
wget -O install.bash -q https://raw.githubusercontent.com/nobl9/sloctl/main/install.bash
# Once downloaded, set execution permissions:
chmod 700 install.bash
# The script is well documented and comes with additional options.
# You can display the help message by running:
./install.bash --help
```
### Prebuilt Binaries
The binaries are available at
[Releases](https://github.com/nobl9/sloctl/releases/latest) page.
### Go install
```shell
go install github.com/nobl9/sloctl/cmd/sloctl@latest
```
### Homebrew
```shell
brew tap nobl9/sloctl
brew install sloctl
```
### Docker
Sloctl official images are hosted on [hub.docker.com](https://hub.docker.com/r/nobl9/sloctl).
Here's an example workflow for managing Project object:
1. Export sloctl access keys through environment variables.
```shell
export SLOCTL_CLIENT_ID=
export SLOCTL_CLIENT_SECRET=
```
2. Create a sample Project object and save it to `project.yaml` file.
```shell
cat << EOF > project.yaml
apiVersion: n9/v1alpha
kind: Project
metadata:
displayName: My Project
name: my-project
spec:
description: Just and example Project :)
EOF
```
3. Apply the project from `project.yaml`.
To keep STDIN open and allow piping the contents of `project.yaml` into
the `docker run` command, use interactive mode with `docker run`.
```shell
cat project.yaml | docker run --rm -i \
-e SLOCTL_CLIENT_ID=${SLOCTL_CLIENT_ID} \
-e SLOCTL_CLIENT_SECRET=${SLOCTL_CLIENT_SECRET} \
nobl9/sloctl apply -f -
```
4. Fetch the applied Project.
```shell
docker run --rm \
-e SLOCTL_CLIENT_ID=${SLOCTL_CLIENT_ID} \
-e SLOCTL_CLIENT_SECRET=${SLOCTL_CLIENT_SECRET} \
nobl9/sloctl get project my-project
```
5. Remove the Project.
```shell
docker run --rm \
-e SLOCTL_CLIENT_ID=${SLOCTL_CLIENT_ID} \
-e SLOCTL_CLIENT_SECRET=${SLOCTL_CLIENT_SECRET} \
nobl9/sloctl delete project my-project
```
### Build Docker image locally
1. Download Dockerfile and latest linux sloctl binary from the Releases page.
Make sure they are in your working directory.
2. Build the image:
```shell
docker build -t .
```
3. Set environment variables if you plan to use them for authenticating with SLOCTL.
Reference the [sloctl environment variables Doc](https://docs.nobl9.com/sloctl-user-guide/#configure-sloctl-with-environmental-variables).
4. Run the image:
```shell
docker run
-e SLOCTL_CLIENT_ID=$SLOCTL_CLIENT_ID \
-e SLOCTL_CLIENT_SECRET=$SLOCTL_CLIENT_SECRET \
get slos --no-config-file
```
### Recipes
Prerequisites:
- [jq](https://github.com/jqlang/jq), a popular command-line JSON processor.
- [yq](https://github.com/kislyuk/yq) is wrapper over jq,
it extends jq's capabilities with YAML support.
1. Filter out SLOs with specific integration (_prometheus_ in this example):
```shell
sloctl get slos -A --jq '
[ .[] | select(
.spec.objectives[] |
(.rawMetric and .rawMetric.query["prometheus"])
or
(.countMetrics and .countMetrics.total["prometheus"])
)]'
```
2. Count SLOs per integration:
```shell
sloctl get slo -A -o json --jq '
.[] |
first(.. | (.query? // .total?) |
select(type == "object") |
keys[0])
' |
sort |
uniq -c |
sort -nr
```