Giter Site home page Giter Site logo

nobl9 / sloctl Goto Github PK

View Code? Open in Web Editor NEW
32.0 5.0 1.0 766.07 MB

A command line tool to cast SLO spells

License: Mozilla Public License 2.0

Dockerfile 0.28% Makefile 5.45% Go 67.32% Shell 24.49% Smarty 0.45% JavaScript 1.83% Awk 0.19%
cli go nobl9 reliability slo sre golang

sloctl's Introduction

N9

checks tests vulnerabilities

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

For more details check out sloctl user guide.

If you want to learn how to fully tame the sloctl's potential, see recipes section below.

Install

Prebuilt Binaries

The binaries are available at Releases page.

Go install

go install github.com/nobl9/sloctl/cmd/sloctl@latest

Homebrew

brew tap nobl9/sloctl
brew install sloctl

Docker

Sloctl official images are hosted on hub.docker.com.

Here's an example workflow for managing Project object:

  1. Export sloctl access keys through environment variables.

    export SLOCTL_CLIENT_ID=<your-client-id>
    export SLOCTL_CLIENT_SECRET=<your-client-secret>
  2. 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
  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.

    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.

    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.

    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:

    docker build -t <NAME_YOUR_IMAGE> .
  3. Set environment variables if you plan to use them for authenticating with SLOCTL. Reference the sloctl environment variables Doc.

  4. Run the image:

    docker run
    -e SLOCTL_CLIENT_ID=$SLOCTL_CLIENT_ID \
    -e SLOCTL_CLIENT_SECRET=$SLOCTL_CLIENT_SECRET \
    <YOUR_IMAGE_NAME> get slos --no-config-file

Recipes

Prerequisites:

  • jq, a popular command-line JSON processor.
  • yq is wrapper over jq, it extends jq's capabilities with YAML support.
  1. Filter out SLOs with specific integration (prometheus in this example):
sloctl get slos -A |
  yq -Y \
  --arg source_type "prometheus" \
  '[ .[] | select(
    .spec.objectives[] |
      (.rawMetric and .rawMetric.query[$source_type])
      or
      (.countMetrics and .countMetrics.total[$source_type])
  )]'

sloctl's People

Contributors

a-hales avatar bsski avatar greg-agacinski avatar jakubpieta avatar kgreczka9 avatar kubaceg avatar lukasz-dobek avatar marcinlawnik avatar mkaras-nobl9 avatar natalialanga avatar nieomylnieja avatar nikodemrafalski avatar patrykdabrowski-nobl9 avatar renovate[bot] avatar skrolikiewicz avatar triluch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

zacnickens

sloctl's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • chore: Update module github.com/nobl9/nobl9-go to v0.84.0-rc5

Detected dependencies

dockerfile
Dockerfile
  • golang 1.23-alpine3.20
test/docker/Dockerfile.e2e
  • bats/bats 1.11.0
test/docker/Dockerfile.unit
  • bats/bats 1.11.0
github-actions
.github/workflows/checks.yml
  • actions/checkout v4
  • actions/setup-go v5
  • actions/setup-node v4
  • actions/cache v4
.github/workflows/e2e-tests.yml
  • actions/checkout v4
  • actions/setup-go v5
.github/workflows/pr-title.yml
  • Slashgear/action-check-pr-title v4.3.0
.github/workflows/release-candidate.yml
  • actions/checkout v4
  • actions/setup-go v5
  • goreleaser/goreleaser-action v6
.github/workflows/release-drafter.yml
  • actions/checkout v4
  • release-drafter/release-drafter v6
.github/workflows/release.yml
  • actions/checkout v4
  • actions/setup-go v5
  • docker/setup-qemu-action v3
  • docker/setup-buildx-action v3
  • docker/login-action v3
  • docker/login-action v3
  • docker/metadata-action v5
  • goreleaser/goreleaser-action v6
  • docker/build-push-action v6
.github/workflows/unit-tests.yml
  • actions/checkout v4
  • actions/setup-go v5
.github/workflows/vulns.yml
  • actions/checkout v4
  • actions/setup-go v5
gomod
go.mod
  • go 1.22
  • github.com/go-playground/validator/v10 v10.22.0
  • github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db@d06e56a500db
  • github.com/nobl9/go-yaml v1.0.1
  • github.com/nobl9/nobl9-go v0.84.0-rc4
  • github.com/pkg/errors v0.9.1
  • github.com/schollz/progressbar/v3 v3.14.6
  • github.com/spf13/cobra v1.8.1
  • github.com/stretchr/testify v1.9.0
  • golang.org/x/sync v0.8.0
npm
package.json
  • cspell 8.14.2
  • markdownlint-cli 0.41.0
  • yaml 2.5.0
  • yarn 1.22.22
regex
Makefile
  • securego/gosec v2.20.0
  • golangci/golangci-lint v1.60.2
  • golang.org/x/vuln/cmd/govulncheck v1.1.3
  • golang.org/x/tools/cmd/goimports v0.24.0

  • Check this box to trigger a request for Renovate to run again on this repository

brew install for sloctl-macos-0.0.77 results in ENOENT error, no such file found

on Monterrey 12.6 running brew update and upgrade results in error on sloctl.

==> Downloading https://github.com/nobl9/sloctl/releases/download/v0.0.77/sloctl-macos-0.0.77
Already downloaded: /Users/zcn/Library/Caches/Homebrew/downloads/6fc4b13f2c68084177eeed7a9353af51434cd8d02cda7f6d2c872a07687f5a18--sloctl-macos-0.0.77
==> Installing sloctl from nobl9/sloctl
Error: An exception occurred within a child process:
  Errno::ENOENT: No such file or directory - sloctl

sloctl does not resolve to environment variables SLOCTL_CLIENT_ID SLOCTL_CLIENT_SECRET when running as root in version 0.0.87

Steps to reproduce

As root user

export SLOCTL_CLIENT_ID="xxxx"
export SLOCTL_CLIENT_SECRET="xxxx"
sloctl get slos

Results in error

No context was set in the current configuration file.
At least one context must be provided and set as default in the current configuration file.
Run 'sloctl config add-context' or indicate the path to the file using '--config' flag.
Sloctl also accepts configuration via environmental variables, set 'SLOCTL_CLIENT_ID' and 'SLOCTL_CLIENT_SECRET'.
Visit sloctl documentation for more details: https://docs.nobl9.com/sloctl-user-guide.

Error: context "default" is not present in the config file /root/.config/nobl9/config.toml

[FEAT] Improve VERSION file management

Is your feature request related to a problem? Please describe.

Currently sloctl maintainers have to manually increment VERSION file before each release.
It's a step that's easy to miss/forget.

Describe the solution you'd like

I see two solutions:

  • Automate the VERSION file incrementing (harder).
    • Automating this during each push, security wise, would be rather unwanted changed. We'd have to commit directly to main.
    • Maybe the best/only viable solution is to commit to PR branches on each PR?
  • Drop and error if VERSION file is not incremented during release (easier).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.