Skip to content
/ cli Public

The command line tool for interacting with OpsLevel

License

Notifications You must be signed in to change notification settings

OpsLevel/cli

Repository files navigation

License Go Report Card Release Stability: Experimental Contributors Activity Downloads

Overall

The CLI for interacting with OpsLevel

Prerequisite

  • jq version 1.7
  • OpsLevel API Token
    • Generate token by clicking Create API Token and providing a description
    • Export the API Token for cli access:
      > export OPSLEVEL_API_TOKEN=<api_token>

Installation

MacOS

brew install opslevel/tap/cli

Curl Download

# Note: you can also run without `sudo` and move the binary yourself
curl -sLS https://raw.githubusercontent.com/OpsLevel/cli/main/install.sh | sudo sh

Docker

The docker container is hosted on AWS Public ECR

Quickstart

# Create
> opslevel create category Chaos
Z2lkOi8vb3BzbGV2ZWwvQ2F0ZWdvcnkvOTY8
# Get
> opslevel get category Z2lkOi8vb3BzbGV2ZWwvQ2F0ZWdvcnkvOTY8
{
  "id": "Z2lkOi8vb3BzbGV2ZWwvQ2F0ZWdvcnkvOTY8",
  "Name": "Chaos"
}
# List
> opslevel list category
NAME            ID                                    
Performance     Z2lkOi8vb3BzbGV2ZWwvQ2F0ZWdvcnkvOTY1  
Infrastructure  Z2lkOi8vb3BzbGV2ZWwvQ2F0ZWdvcnkvOTY2  
Observability   Z2lkOi8vb3BzbGV2ZWwvQ2F0ZWdvcnkvOTY3  
Reliability     Z2lkOi8vb3BzbGV2ZWwvQ2F0ZWdvcnkvOTY4  
Scalability     Z2lkOi8vb3BzbGV2ZWwvQ2F0ZWdvcnkvOTY5  
Security        Z2lkOi8vb3BzbGV2ZWwvQ2F0ZWdvcnkvOTY6  
Quality         Z2lkOi8vb3BzbGV2ZWwvQ2F0ZWdvcnkvOTY7  
Chaos           Z2lkOi8vb3BzbGV2ZWwvQ2F0ZWdvcnkvOTY8  
# Delete
> opslevel delete category Z2lkOi8vb3BzbGV2ZWwvQ2F0ZWdvcnkvOTY8
This tool is still in beta.

Enable shell autocompletion

We have the ability to generate autocompletion scripts for the shell's bash, zsh, fish and powershell. To generate the completion script for macOS zsh:

opslevel completion zsh > /usr/local/share/zsh/site-functions/_opslevel

Make sure you have zsh completion turned on by having the following as one of the first few lines in your .zshrc file

echo "autoload -U compinit; compinit" >> ~/.zshrc

Troubleshooting

List all my tier 1 services

> opslevel list services -o json | jq '[.[] | if .tier.Alias == "tier_1" then {(.name) : (.tier.Alias)} else empty end]' 
[
  {
    "Catalog Service": "tier_1"
  },
  {
    "Shopping Cart Service": "tier_1"
  },
  {
    "Website Aggregator": "tier_1"
  }
]