Sloctl is a command-line interface (CLI) for Nobl9.
You can use sloctl to manage multiple Nobl9 configuration objects
such as SLOs,
Projects
or 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 🔥
Usage
Sloctl includes built-in documentation for each command, to access it, run:
sloctl <command> --help
Help uses Markdown formatting and wraps prose to the terminal width.
Code examples keep their original line breaks.
Redirected output stays plain, as does terminal output when NO_COLOR has a
nonempty value or TERM=dumb.
If you want to learn how to fully tame the sloctl's potential, see
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.
# 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
go install github.com/nobl9/sloctl/cmd/sloctl@latest
Homebrew
brew tap nobl9/sloctl
brew trust nobl9/sloctl
brew install sloctl
Update notifications
In an interactive terminal,
sloctl checks for a newer GitHub release before running the requested command
and caches completed checks for 24 hours.
The notice includes release highlights when available
and a link to the full release notes.
It does not check in CI, for development builds,
for shell completion commands,
when standard input or standard error is not a terminal,
or when SLOCTL_NO_NOTIFICATIONS has a nonempty value.
On supported terminals outside Windows,
Homebrew and go install installations offer to run
their corresponding update command.
Press Enter to skip the update and run the requested command.
Choosing Update exits after a successful update.
If the update or notification fails, sloctl continues with the requested command.
On Windows, and for other installation methods,
sloctl shows the same notice and continues without an update prompt.
Choosing Skip until next version stores the release tag
in the operating system's user cache.
If the preference cannot be saved,
sloctl reports the error and may show the notification again.
Create a sample Project object and save it to project.yaml file.
cat << EOF > project.yaml
apiVersion: n9/v1alpha
kind: Project
metadata:
displayName: My Project
name: my-project
spec:
description: Just and example Project :)
EOF
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.
yq is wrapper over jq,
it extends jq's capabilities with YAML support.
Filter out SLOs with specific integration (prometheus in this example):
sloctl get slos -A --jq '
[ .[] | select(
.spec.objectives[] |
(.rawMetric and .rawMetric.query["prometheus"])
or
(.countMetrics and .countMetrics.total["prometheus"])
)]'