UI - script API

Functions that control the StackState user-interface.

These functions only work in the context of scripts that are executed by a user from the user-interface. Component actions are an example of scripts that can trigger actions in the user-interface.

Function: baseUrl

Returns the baseUrl of the StackState instance as configured in the application.conf or values.yaml.


Return the base URL from the StackState configuration.


Function: createUrl

Creates a URL builder that can be used to generate URLs that can be linked back in Stackstate.


No arguments.

Return type:


Builder methods:

  • view() - returns a ViewUrlBuilder for the specified view with the following methods:

    • at(time: instant) - specifies a time for which the view query should be executed.

    • withComponent(component) - creates a view URL with the specified component in focus.

    • url() - gives the final URL of the view.


Create a URL to a view at a specific time.

View.getAll().then { views ->

Function: redirectToURL

Opens a new tab in the user's browser to some URL.


  • url - the URL to redirect the browser to.

Return type:

  • Async: URLRedirectResponse


Open the stackstate.com website in a new tab in the browser.


Function: showReport

Shows a report in the user-interface. The user-interface will open a dialog with the report in it. You can also see the result of these reports in the preview of the analytics environment.


  • reportName - Name of the report. In a dialog with the report, the name of the report will be in the title bar.

  • stmlContent - The report markup. See StackState Markup Language for more information on how to format a report.

  • Optional data - A map with data elements that can be referenced by the STML.

Return type:

  • Async: ShowStmlReport


The following example will show a nice shopping list report:

"My shopping list",
"""# To buy
| Bring *report*.
| * Apples
| * Oranges

Please note the .stripMargin() call. This is a Groovy function for strings that strips leading whitespace/control characters followed by '|' from every line. This way, indenting can be retained without introducing leading whitespace in the STML.

Function: showTopologyByQuery

Sets the user-interface to the Topology Perspective and changes the SQTL query.

If the user is currently in an unsaved view, the user receives a prompt dialog asking whether they are okay in navigating to another part of the topology. If the user continues the action they will loose their current view.


  • query - STQL query that selects what part of the topology is shown.

Return type:

  • Async: ShowTopologyByQuery


Redirects the user-interface to show the Azure topology.

UI.showTopologyByQuery('domain IN ("Azure")')

Create a URL to a view focussing on a component.

View.getAll().then { views ->
Component.withId(component).get().then { component ->