rootlyhq / cli

A command-line interface for Rootly
https://rootly.com
GNU General Public License v3.0
5 stars 1 forks source link
rootly
logo

rootly cli

GitHub release (latest by date) GitHub go.mod Go version Golang report card
build lint release test

A command-line interface for rootly

👋 Getting Started

The rootly command-line tool allows you to interact with rootly in your terminal, CI environment, or anything that can run a simple program. At the moment the main purpose of the cli is to send pulses right from the command line. This is great for sending a pulse at the end of a deploy script for example. You can also send pulses based on the exit status of a given command to run.

🚀 Install

🍎 macOS

Simply run the command below:

brew install rootlyhq/homebrew-tap/rootly

🐧 Linux and đŸ–Ĩī¸ Windows

You can grab the binary from the latest release or run the command below.

curl -fsSL https://raw.githubusercontent.com/rootlyhq/cli/main/install.sh | sh

If you have golang installed you can also just install the binary using the following command. Keep in mind that this will go in ~/go/bin/ by default which might not be in your path.

go install github.com/rootlyhq/cli@latest

📟 Commands

ℹī¸ rootly pulse

rootly pulse allows you to send a pulse right from the command-line. The summary for the pulse, which is required, goes at the end of the command as a normal argument.

Flag Name Description Examples Required Environment Variable
api-key A rootly api key --api-key "ABC123" Yes ROOTLY_API_KEY
api-host Host URL for the rootly api. Default is https://api.rootly.com --api-host "https://rootly.hello.com" No ROOTLY_API_HOST
labels Key value pair labels (separated with commas with no spaces around =) --labels "version=2, attempt=1" No ROOTLY_LABELS
services Services associated with the pulse (separated with commas) --services "elasticsearch-prod" No ROOTLY_SERVICES
environments Environments associated with the pulse (separated with commas) --environments "staging, production" No ROOTLY_ENVIRONMENTS
source Source of the pulse --source "k8s" No ROOTLY_SOURCE
refs Refs associated with the pulse. Separate each item with a comma. Key-value pair separated with an equal sign (= with no surrounding spaces) --refs "sha=cd62148cbc5eb42168fe99fdb50a364e12b206ac" No ROOTLY_ENVIRONMENTS
debug If extra logs should be outputted for debugging --debug No ROOTLY_DEBUG
quiet If all logs should be suppressed --quiet No ROOTLY_QUIET

Here are some examples:

🏃 rootly pulse-run

rootly pulse-run allows you to wrap a terminal command and send a pulse with a label of the exit code. The summary for the pulse is a flag and if no value is provided it will use the command. The command goes at the end of the command as a normal argument.

Flag Name Description Examples Required Environment Variable
api-key A rootly api key --api-key "ABC123" Yes ROOTLY_API_KEY
api-host Host URL for the rootly api. Default is https://api.rootly.com --api-host "https://rootly.hello.com" No ROOTLY_API_HOST
summary Summary for the pulse. Default is just the command --summary "Deployed Website" No ROOTLY_SUMMARY
labels Key value pair labels (separated with commas with no spaces around =) --labels "Version=2, Attempt=1" No ROOTLY_LABELS
services Services associated with the pulse (separated with commas) --services "elasticsearch-prod" No ROOTLY_SERVICES
environments Environments associated with the pulse (separated with commas) --environments "staging, production" No ROOTLY_ENVIRONMENTS
source Source of the pulse --source "k8s" No ROOTLY_SOURCE
refs Refs associated with the pulse. Separate each item with a comma. Key-value pair separated with an equal sign (= with no surrounding spaces) --refs "sha=cd62148cbc5eb42168fe99fdb50a364e12b206ac" No ROOTLY_ENVIRONMENTS
debug If extra logs should be outputted for debugging --debug No ROOTLY_DEBUG
quiet If all logs should be suppressed (command will still output) --quiet No ROOTLY_QUIET

Here are some examples:

đŸ“Ļ Running in CI

When using the rootly CLI in a CI environment there are some useful features to make the process easier. Every single flag can use an environment variable instead. The api-key flag for example could use the environment variable ROOTLY_API_KEY instead. To get the environment variable for a certain flag just replace all hyphens (-) with underscores (_), make all letters uppercase, and add ROOTLY_ to the front.

🤖 GitHub Action

There is also a GitHub action for rootly pulse that makes it easy to use in a GitHub actions environment. See the rootlyhq/pulse-action repository for more information. Here is a short little example:

name: Deploy Website

on: push

jobs:
  pulse:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: make deploy
      - name: rootly-pulse
        uses: rootlyhq/pulse-action@main
        with:
          api_key: ${{ secrets.ROOTLY_API_KEY }} # Required
          summary: Deploy Website # Required
          environments: production # Not required
          services: elasticsearch-prod # Not required
          labels: platform=ubuntu,version=2 # Not required
          source: k8s # Not required
          refs: sha=cd62148cbc5eb42168fe99fdb50a364e12b206ac, image=registry.rootly.com/rootly/my-service:cd6214 # Not required