Zum Inhalt springen

API usage with the Observability CLI

  1. You have created a STACKIT project
  2. You have created a service account and access token
  3. You have already created an Observability Service and your Service shows the Ready state.
    (See: Creating a service Observability)

There are two methods installing the Observability CLI:

  1. If you have Go installed on your machine, you can directly install it by running:
    Go install
Terminal window
go install github.com/stackitcloud/stackit-observability-cli/cmd/stackit-observability-cli@latest

Based on your Go configuration the stackit-observability-cli binary can be found in $GOPATH/bin or $HOME/go/bin in case $GOPATH is not set. Make sure to add the respective directory to your $PATH. For more information see the Go docs. Run go env to view your current configuration. 2. From the released binaries by downloading the desired version for your operating system and processor architecture from the STACKIT Observability CLI. Make the file executable and place it in a directory available in your $PATH.

You can configure the Observability CLI by running:

Configure

Terminal window
stackit-observability-cli configure

After that configuration file(.stackit-observability-cli.yaml) will be generated in your $HOME directory. You can change the configurations in the file directly or by running configure command again. The file also contains a base url of an API call, that is stated to the default value. In order to change it you should set it up in the configuration file directly.

All API usages are supported by the CLI. You can list all available commands and flags by running:

Usage

Terminal window
stackit-observability-cli

There are four main commands:

The get command supports multiple output formats, which can be selected using the -o flag.

This is the default output format if no -o flag is specified.

Displays the result in a structured table format.

Terminal window
stackit-observability-cli get scrape-configs -o table

Shows additional fields and more detailed information for each resource.

Terminal window
stackit-observability-cli get scrape-configs -o wide

or

Terminal window
stackit-observability-cli get scrape-configs -o wide-table

Useful for automation, scripting, or debugging.

Terminal window
stackit-observability-cli get scrape-configs -o json
Terminal window
stackit-observability-cli get scrape-configs -o yaml

Use the create command to create a new scrape configuration from a file.

Terminal window
stackit-observability-cli create scrape-config -f test.json

Use the update command to modify an existing scrape configuration.

Terminal window
stackit-observability-cli update scrape-configs job2 -f test.yaml

Use the delete command to remove an existing scrape configuration.

Terminal window
stackit-observability-cli delete scrape-config job2
CommandDescription
getRetrieve scrape configs
createCreate a new scrape config
updateUpdate an existing scrape config
deleteDelete a scrape config

In most cases update- and create- commands require file, that contains a body of the request. Both JSON and YAML files can be used as a request body file. The CLI will convert it to JSON format with proper naming.