API usage with the Observability CLI
Prerequisites:
Section titled “Prerequisites:”- You have created a STACKIT project
- You have created a service account and access token
- You have already created an Observability Service and your Service shows the Ready state.
(See: Creating a service Observability)
How to install Observability CLI
Section titled “How to install Observability CLI”There are two methods installing the Observability CLI:
- If you have Go installed on your machine, you can directly install it by running:
Go install
go install github.com/stackitcloud/stackit-observability-cli/cmd/stackit-observability-cli@latestBased 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.
How to configure Observability CLI
Section titled “How to configure Observability CLI”You can configure the Observability CLI by running:
Configure
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.
How to use Observability CLI
Section titled “How to use Observability CLI”All API usages are supported by the CLI. You can list all available commands and flags by running:
Usage
stackit-observability-cliThere are four main commands:
Get Scrape Configs
Section titled “Get Scrape Configs”The get command supports multiple output formats, which can be selected using the -o flag.
Available Output Styles
Section titled “Available Output Styles”Default (Simple Tabulative Output)
Section titled “Default (Simple Tabulative Output)”This is the default output format if no -o flag is specified.

Table Output (-o table)
Section titled “Table Output (-o table)”Displays the result in a structured table format.
stackit-observability-cli get scrape-configs -o table
Extended Output (-o wide / -o wide-table)
Section titled “Extended Output (-o wide / -o wide-table)”Shows additional fields and more detailed information for each resource.
stackit-observability-cli get scrape-configs -o wideor
stackit-observability-cli get scrape-configs -o wide-tableStructured Output (-o json | -o yaml)
Section titled “Structured Output (-o json | -o yaml)”Useful for automation, scripting, or debugging.
stackit-observability-cli get scrape-configs -o jsonstackit-observability-cli get scrape-configs -o yamlCreate a Scrape Config
Section titled “Create a Scrape Config”Use the create command to create a new scrape configuration from a file.
stackit-observability-cli create scrape-config -f test.jsonUpdate a Scrape Config
Section titled “Update a Scrape Config”Use the update command to modify an existing scrape configuration.
stackit-observability-cli update scrape-configs job2 -f test.yamlDelete a Scrape Config
Section titled “Delete a Scrape Config”Use the delete command to remove an existing scrape configuration.
stackit-observability-cli delete scrape-config job2Summary
Section titled “Summary”| Command | Description |
|---|---|
| get | Retrieve scrape configs |
| create | Create a new scrape config |
| update | Update an existing scrape config |
| delete | Delete 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.