LogoLogo
StackState.comDownloadSupportExplore playground
StackState v5.1
StackState v5.1
  • Welcome to the StackState docs!
  • StackState self-hosted v5.1 docs
  • Getting Started
  • 🚀Setup
    • Install StackState
      • Requirements
      • Kubernetes / OpenShift
        • Kubernetes install
        • OpenShift install
        • Required Permissions
        • Non-high availability setup
        • Override default configuration
        • Configure storage
        • Configure Ingress
        • Install from custom image registry
        • Migrate from Linux install
      • Linux
        • Before you install
        • Download
        • Install StackState
        • Install with production configuration
        • Install with development configuration
        • Install with POC configuration
        • Set up a reverse proxy
        • Set up TLS without reverse proxy
      • Initial run guide
      • Troubleshooting
    • Upgrade StackState
      • Steps to upgrade
      • Version specific upgrade instructions
      • StackPack versions
      • StackState release notes
    • StackState Agent
      • About StackState Agent V3
      • Docker
      • Kubernetes / OpenShift
      • Linux
      • Windows
      • Advanced Agent configuration
      • Use an HTTP/HTTPS proxy
      • Agent V1 (legacy)
      • Migrate Agent V1 to Agent V2
        • Linux
        • Docker
    • StackState CLI
      • CLI: sts
      • CLI: stac (deprecated)
      • Comparison between CLIs
    • Data management
      • Backup and Restore
        • Kubernetes backup
        • Linux backup
        • Configuration backup
      • Data retention
      • Clear stored data
  • 👤Use
    • Concepts
      • The 4T data model
      • Components
      • Relations
      • Health state
      • Layers, Domains and Environments
      • Perspectives
      • Anomaly detection
      • StackState architecture
    • StackState UI
      • Explore mode
      • Filters
      • Views
        • About views
        • Configure the view health
        • Create and edit views
        • Visualization settings
      • Perspectives
        • Topology Perspective
        • Events Perspective
        • Traces Perspective
        • Metrics Perspective
      • Timeline and time travel
      • Analytics
      • Keyboard shortcuts
    • Checks and monitors
      • Checks
      • Add a health check
      • Anomaly health checks
      • Monitors
      • Manage monitors
    • Problem analysis
      • About problems
      • Problem lifecycle
      • Investigate a problem
      • Problem notifications
    • Metrics
      • Telemetry streams
      • Golden signals
      • Top metrics
      • Add a telemetry stream
      • Browse telemetry
      • Set telemetry stream priority
    • Events
      • About events
      • Event notifications
      • Manage event handlers
    • Glossary
  • 🧩StackPacks
    • About StackPacks
    • Add-ons
      • Autonomous Anomaly Detector
      • Health Forecast
    • Integrations
      • About integrations
      • 💠StackState Agent V2
      • 💠AWS
        • AWS
        • AWS ECS
        • AWS X-ray
        • StackState/Agent IAM role: EC2
        • StackState/Agent IAM role: EKS
        • Policies for AWS
        • AWS (legacy)
        • Migrate AWS (legacy) to AWS
      • 💠Dynatrace
      • 💠Kubernetes
      • 💠OpenShift
      • 💠OpenTelemetry
        • About instrumentations
        • AWS NodeJS Instrumentation
        • Manual Instrumentation
          • Prerequisites
          • Tracer and span mappings
          • Relations between components
          • Span health state
          • Merging components
          • Code examples
      • 💠ServiceNow
      • 💠Slack
      • 💠Splunk
        • Splunk
        • Splunk Events
        • Splunk Health
        • Splunk Metrics
        • Splunk Topology
      • 💠VMWare vSphere
      • Apache Tomcat
      • Azure
      • Cloudera
      • Custom Synchronization
      • DotNet APM
      • Elasticsearch
      • Humio
      • Java APM
      • JMX
      • Logz.io
      • MySQL
      • Nagios
      • OpenMetrics
      • PostgreSQL
      • Prometheus
      • SAP
      • SCOM
      • SolarWinds
      • Static Health
      • Static Topology
      • Traefik
      • WMI
      • Zabbix
    • Develop your own StackPacks
  • 🔧Configure
    • Topology
      • Component actions
      • Identifiers
      • Topology naming guide
      • Topology sources
      • Create a topology manually
      • Configure topology synchronizations
      • Enable email event notifications
      • Send topology data over HTTP
      • Set the topology filtering limit
      • Use a proxy for event handlers
      • Use tags
      • Tune topology synchronization
      • Debug topology synchronization
    • Telemetry
      • Add telemetry during topology synchronization
      • Data sources
        • Elasticsearch
        • Prometheus mirror
      • Send events over HTTP
      • Send metrics data over HTTP
      • Set the default telemetry interval
      • Debug telemetry synchronization
    • Traces
      • Set up traces
      • Advanced configuration for traces
    • Health
      • Health synchronization
      • Send health data over HTTP
        • Send health data
        • Repeat Snapshots JSON
        • Repeat States JSON
        • Transactional Increments JSON
      • Debug health synchronization
    • Anomaly Detection
      • Export anomaly feedback
      • Scale the AAD up and down
      • The AAD status UI
    • Security
      • Authentication
        • Authentication options
        • File based
        • LDAP
        • Open ID Connect (OIDC)
        • KeyCloak
        • Service tokens
      • RBAC
        • Role-based Access Control
        • Permissions
        • Roles
        • Scopes
        • Subjects
      • Secrets management
      • Self-signed certificates
      • Set up a security backend for Linux
      • Set up a security backend for Windows
    • Logging
      • Kubernetes logs
      • Linux logs
      • Enable logging for functions
  • 📖Develop
    • Developer guides
      • Agent checks
        • About Agent checks
        • Agent check API
        • Agent check state
        • How to develop Agent checks
        • Connect an Agent check to StackState
      • Custom functions and scripts
        • StackState functions
        • Check functions
        • Component actions
        • Event handler functions
        • ID extractor functions
        • Mapping functions
        • Monitor functions
        • Propagation functions
        • Template functions
        • View health state configuration functions
      • Custom Synchronization StackPack
        • About the Custom Synchronization StackPack
        • How to customize elements created by the Custom Synchronization StackPack
        • How to configure a custom synchronization
      • Integrate external services
      • Mirroring Telemetry
      • Monitors
        • Create monitors
        • Monitor STJ file format
      • StackPack development
        • How to create a StackPack
        • Packaging
        • How to get a template file
        • How to make a multi-instance StackPack
        • Prepare a multi-instance provisioning script
        • Upload a StackPack file
        • Prepare a shared template
        • Customize a StackPack
        • Prepare instance template files
        • Prepare a StackPack provisioning script
        • Resources in a StackPack
        • StackState Common Layer
      • Synchronizations and templated files
    • Reference
      • StackState OpenAPI docs
      • StackState Template JSON (STJ)
        • Using STJ
        • Template functions
      • StackState Markup Language (STML)
        • Using STML
        • STML Tags
      • StackState Query Language (STQL)
      • StackState Scripting Language (STSL)
        • Scripting in StackState
        • Script result: Async
        • Script result: Streaming
        • Time in scripts
        • Script APIs
          • Async - script API
          • Component - script API
          • HTTP - script API
          • Prediction - script API
          • StackPack - script API
          • Telemetry - script API
          • Time - script API
          • Topology - script API
          • UI - script API
          • View - script API
    • Tutorials
      • Create a simple StackPack
      • Push data to StackState from an external system
      • Send events to StackState from an external system
      • Set up a mirror to pull telemetry data from an external system
Powered by GitBook
LogoLogo

Legal notices

  • Privacy
  • Cookies
  • Responsible disclosure
  • SOC 2/SOC 3
On this page
  • Overview
  • Install the new sts CLI
  • Configure the new sts CLI
  • Quick start
  • Authentication
  • Manage multiple contexts
  • Configuration options
  • Upgrade
  • Uninstall
  • Open source
  1. Setup
  2. StackState CLI

CLI: sts

StackState Self-hosted v5.1.x

PreviousStackState CLINextCLI: stac (deprecated)

Last updated 1 year ago

Overview

The new StackState sts CLI provides easy access to the functionality provided by the StackState APIs. It can be used for automate using StackState data, configure StackState and to develop StackPacks.

  • The new sts CLI replaces the , however, not all commands are currently supported. For an overview of the differences and overlap between the new sts CLI and the stac CLI, see the .

  • In the meantime, you can install and run as the new sts CLI on the same machine as the stac CLI.

Install the new sts CLI

The new sts CLI works with StackState version 5.0 and above.

If you are running an older version of StackState, use the .

  1. If it's installed, upgrade the old sts CLI to stac:

    • .

    • .

  2. Follow the steps below to install the new sts CLI:

Open a Powershell terminal (version 5.1 or later), change the <URL> and <API-TOKEN> and run the command below. After installation, the sts command will be available for the current user on both the Powershell terminal and the command prompt (cmd.exe).

. { iwr -useb https://dl.stackstate.com/stackstate-cli/install.ps1 } | iex; install -StsUrl "<URL>" -StsApiToken "<API-TOKEN>"

Alternatively, go to the CLI page in the StackState UI and copy the Quick installation command for Windows - this is pre-filled with the correct <URL> and <API-TOKEN> for your StackState instance.

Open a Powershell terminal (version 5.1 or later) and run the steps below. This can be done one step at a time, or joined together as a single script. After installation, the sts command will be available for the current user on both the Powershell terminal and the command prompt (cmd.exe).

  1. Set the source version and target path for the CLI:

    $CLI_PATH = $env:USERPROFILE +"\stackstate-cli"
    If (!(test-path $CLI_PATH)) { md $CLI_PATH }
    Invoke-WebRequest https://dl.stackstate.com/stackstate-cli/LATEST_VERSION -OutFile $CLI_PATH\VERSION
    $VERSION=type $CLI_PATH\VERSION
    $VERSION=$VERSION -replace "[v]"
    $CLI_DL = "https://dl.stackstate.com/stackstate-cli/v$VERSION/stackstate-cli-$VERSION.windows-x86_64.zip"
    echo "Installing StackState CLI v$VERSION to: $CLI_PATH"
  2. Download and unpack the CLI to the target CLI path. Remove remaining artifacts:

    Invoke-WebRequest $CLI_DL -OutFile $CLI_PATH\stackstate-cli.zip
    Expand-Archive -Path "$CLI_PATH\stackstate-cli.zip" -DestinationPath $CLI_PATH -Force
    rm $CLI_PATH\stackstate-cli.zip, $CLI_PATH\VERSION
  3. Register the CLI path to the current user's PATH. This will make the sts command available everywhere:

     $PATH = (Get-ItemProperty -Path "Registry::HKEY_CURRENT_USER\Environment" -Name PATH).Path
     if ( $PATH -notlike "*$CLI_PATH*" ) {
       $PATH = "$PATH;$CLI_PATH"
       (Set-ItemProperty -Path "Registry::HKEY_CURRENT_USER\Environment" -Name PATH –Value $PATH)
       $MACHINE_PATH = (Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment" -Name PATH).path
       $env:Path = "$PATH;$MACHINE_PATH"
     }
  4. Verify that the CLI works:

    sts version

Open a terminal, change the <URL> and <API-TOKEN> and run the command below.

  • The default install location is /usr/local/bin, which might require sudo permissions depending on the version of your machine.

  • You can specify an install location by adding STS_CLI_LOCATION to the command, as shown below. Note that the path provided must be available in your OS Path or the script might fail to complete.

After installation, the sts command will be available for the current user.

# Install in default location `/usr/local/bin`
curl -o- https://dl.stackstate.com/stackstate-cli/install.sh | STS_URL="<URL>" STS_API_TOKEN="<API-TOKEN>" bash

# Install in a specified location
curl -o- https://dl.stackstate.com/stackstate-cli/install.sh | STS_URL="<URL>" STS_API_TOKEN="<API-TOKEN>" STS_CLI_LOCATION="<INSTALL-PATH>" bash

Alternatively, go to the CLI page in the StackState UI and copy the Quick installation command for MacOS - this is pre-filled with the correct <URL> and <API-TOKEN> for your StackState instance and will install the CLI at the default location.

Open a terminal and run the steps below. This can be done one step at a time, or all together as a single script. After installation, the sts command will be available for the current user.

  1. Download the latest CLI version for x86_64 (Intel) or arm64 (M1).

    (VERSION=`curl https://dl.stackstate.com/stackstate-cli/LATEST_VERSION` &&
      VERSION=${VERSION#v} &&
      ARCH=`uname -m` &&
      curl https://dl.stackstate.com/stackstate-cli/v$VERSION/stackstate-cli-$VERSION.darwin-$ARCH.tar.gz | tar xz --directory /usr/local/bin)
  2. Verify that the CLI works:

    sts version

Open a terminal, change the <URL> and <API-TOKEN> and run the command below. After installation, the sts command will be available for the current user.

curl -o- https://dl.stackstate.com/stackstate-cli/install.sh | STS_URL="<URL>" STS_API_TOKEN="<API-TOKEN>" bash

Alternatively, go to the CLI page in the StackState UI and copy the Quick installation command for Linux - this is pre-filled with the correct <URL> and <API-TOKEN> for your StackState instance.

Open a terminal and run the steps below. This can be done one step at a time, or all together as a single script. After installation, the sts command will be available for the current user.

  1. Download and unpack the latest version for x86_64:

    (VERSION=`curl https://dl.stackstate.com/stackstate-cli/LATEST_VERSION` && VERSION=${VERSION#v} &&
    curl https://dl.stackstate.com/stackstate-cli/v$VERSION/stackstate-cli-$VERSION.linux-x86_64.tar.gz | tar xz --directory /usr/local/bin)
  2. Verify that the CLI works:

    sts version

To run the latest version of the CLI using Docker execute:

docker run stackstate/stackstate-cli2

Alternatively, go to the CLI page in the StackState UI and copy the Quick installation command for Docker - this is pre-filled with the correct <URL> and <API-TOKEN> required to configure the CLI for your StackState instance.

You can now run CLI commands by adding appending them to the end of the docker run command (for example, docker run stackstate/stackstate-cli2 version).

Configure the new sts CLI

Quick start

The most secure way to use your API token is through an environment variable. You can store the API token with a secrets manager and inject it as an environment variable into your shell.

Linux, macOS and Windows

  1. In the StackState UI, go to Main menu > CLI and copy your API token.

  2. Run the command below, where <URL> is the URL to your StackState instance and <API-TOKEN> is the API token you copied from the CLI page in the StackState UI:

    sts context save --name <NAME> --url <URL> --api-token <API-TOKEN>
  3. The connection to your StackState instance will be tested and a configuration file stored at ~/.config/stackstate-cli/config.yaml.

Docker

The Docker version of the CLI can't be configured with a config file. Specify the configuration of your StackState instance using environment variables and pass these to Docker:

  • STS_CLI_URL - the URL to your StackState instance.

  • STS_CLI_API_TOKEN - the API token taken from the StackState UI Main menu > CLI page.

For example:

docker run \
   -e STS_CLI_URL \
   -e STS_CLI_API_TOKEN \
   stackstate/stackstate-cli2 settings list --type Layer

Authentication

API token

By default, the CLI will authenticate using the API token that you provided when the CLI configuration was saved.

Service tokens

You can optionally use the CLI to create one or more service tokens to authenticate with the StackState Base and Admin APIs. For example, a service token can be used to authenticate in CI (Continuous Integration) scenarios where no real user is doing the operations on the StackState instance.

To create a service token, run the command below:

sts service-token create --name <NAME> --roles <ROLE(s)> [--expiration <yyyy-MM-dd>]

This will create a new service token and print it. The --expiration parameter is optional and can be used to set the expiration date of the service token.

Once you have this, you can configure the CLI to use it:

sts context save --name <NAME> --service-token <TOKEN> --url <URL>

Manage multiple contexts

The new sts CLI supports configuration and management of different (authentication) contexts. This enables you to easily switch between an administrative and regular user, or to switch between different StackState instances. For example, you could use a different context for a test and production instance of StackState. You can list, save, delete, set and validate contexts in the new sts CLI. Run sts context -h for details of the available commands and their usage.

Configuration options

You don't need a configuration file to run the new sts CLI. You can also configure the CLI through a combination of environment variables and flags.

If multiple types of configuration are presented to the CLI the order of processing will be:

  1. Flags

  2. Environment variables

  3. Config file

Environment variable
Flag
Description

STS_CLI_URL

--url

URL to your StackState instance.

STS_CLI_API_TOKEN

--api-token

API token to your StackState instance. The most secure way to use your API token is through an environment variable. You can store the API token with a secrets manager and inject it as an environment variable into your shell.

STS_CLI_SERVICE_TOKEN

--service-token

A service token to your StackState instance. The most secure way to use your service token is through an environment variable. You can store the service token with a secrets manager and inject it as an environment variable into your shell.

STS_CLI_API_PATH

n/a

The path appended to the end of the URL to get the API endpoint. (Defaults to /api)

STS_CLI_CONTEXT

--context

The name of the context to use.

Next to overriding specific parts of the config file, it's also possible to override the default config file location. This is done through the --config <PATH> flag.

Upgrade

You can check the version of the sts CLI that you are currently running with the command sts version.

Uninstall

Follow the instructions below to uninstall the StackState CLI.

Open a Powershell terminal and run:

. { iwr -useb https://dl.stackstate.com/stackstate-cli/install.ps1 } | iex; uninstall

The new sts CLI and all associated configuration are now removed for the current user.

Open a Powershell terminal and run each step one-by-one or all at once. The new sts CLI and all associated configuration will be removed for the current user.

  1. Remove binary:

    $CLI_PATH = $env:USERPROFILE+"\stackstate-cli"
    rm -R $CLI_PATH 2>1  > $null
  2. Remove config:

    rm -R $env:USERPROFILE+"\.config\stackstate-cli" 2>1  > $null
  3. Remove the CLI from the environment path:

    $PATH = (Get-ItemProperty -Path ‘Registry::HKEY_CURRENT_USER\Environment’ -Name PATH).Path
    $i = $PATH.IndexOf(";$CLI_PATH")
    if ($i -ne -1) {
      $PATH = $PATH.Remove($i, $CLI_PATH.Length+1)
      (Set-ItemProperty -Path 'Registry::HKEY_CURRENT_USER\Environment' -Name PATH –Value $PATH)
    }

Open a terminal and run:

curl -o- https://dl.stackstate.com/stackstate-cli/uninstall.sh | bash

The new sts CLI and all associated configuration are now removed for the current user.

To manually uninstall the new sts CLI, follow the steps below.

  1. Open a terminal.

  2. To remove the new sts CLI, run the command:

    rm -r /usr/local/bin/sts
  3. To remove configuration for the new sts CLI, run the command:

    rm -r ~/.config/stackstate-cli

The new sts CLI and all associated configuration are now removed for the current user.

Open a terminal and run:

curl -o- https://dl.stackstate.com/stackstate-cli/uninstall.sh | bash

The new sts CLI and all associated configuration are now removed for the current user.

To manually uninstall the new sts CLI, follow the steps below.

  1. Open a terminal.

  2. To remove the new sts CLI, run the command:

    rm -r /usr/local/bin/sts
  3. To remove configuration for the new sts CLI, run the command:

    rm -r ~/.config/stackstate-cli

The new sts CLI and all associated configuration are now removed for the current user.

To remove the CLI image and containers run:

docker rmi -f stackstate/stackstate-cli2

Open source

The StackState sts CLI is open source and can be found on GitHub at:

To upgrade to the latest version of the new sts CLI, .

🚀
https://github.com/stackvista/stackstate-cli
run the install command again
stac CLI
CLI comparison page
stac CLI
Check if the old sts CLI is installed
Upgrade the old sts CLI to stac