Configuration backup

This page describes StackState version 4.1.

The StackState 4.1 version range is End of Life (EOL) and no longer supported. We encourage customers still running the 4.1 version range to upgrade to a more recent release.

Go to the documentation for the latest StackState release.

StackState configuration can be exported and imported. The import/export functionality can be used to automate the installation process and/or for backup purposes. An export and import can be made in the settings page of StackState's user interface by using the buttons 'Export Model' and 'Import Model'.

Export configuration

An export of the StackState configuration can be obtained from the StackState CLI or using curl commands:

# Output in terminal window
sts graph export

# Export to file
sts graph export > export.stj

Export configuration with authentication (curl)

StackState server can be configured to authenticate users when they access the application. In this case, an export curl script is required to first obtain a token before making the export request. This is not necessary when using the StackState CLI as authentication details are configured during installation.

Here is a sample sequence of curl commands to achieve this:

# Obtain session from cookie AkkaHttpPac4jSession
# Obtain token from cookie pac4jCsrfToken
curl --fail -v \
  -d "username=<MY_USERNAME>&password=<MY_PASSWORD>" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  "http://<HOST>:7070/loginCallback"

# Do actual request
export SESSION="<MY_SESSION>"; export TOKEN="<MY_TOKEN>"; \
  curl -v -X POST \
  -H 'Content-Type: application/json;charset=UTF-8' \
  -d '{}' \
  -H Cookie:AkkaHttpPac4jSession=$SESSION \
  -H X-Sts-Token:$TOKEN \
  "http://<HOST>:7070/api/export?timeoutSeconds=300" > export.stj

Import configuration

Import is intended to be a one-off action - importing multiple times might result in duplicate configuration entries. This behavior applies to importing nodes without any identifier. It is possible to clear StackState's configuration before an import.

To clear the StackState configuration and import from a file:

sts graph import < export.stj

Import or export individual configuration items

It is possible to export and import individual configuration items through the StackState user interface. For example, to export or export a component type:

  1. Go to the Settings page and click on Component Types.

  2. To export an individual component type, click on Export as config.

  3. To import a configuration item, click on Import Model.

Idempotent import/export

There is a way to use identifiers and namespaces that come with them to perform a configuration update of the specific sets of nodes idempotently. This approach does not lead to duplicates, but checks for the changes within a specified namespace and applies them to existing nodes, including removing nodes, as well as allow for creating the new ones.

Node identifiers are specified in a following pattern: urn:stackpack:{stackpack_name}:{type_name}:{object_name}. The namespace effectively used by this process is urn:stackpack:{stackpack_name}:. If every configuration node has an identifier and they are all in the same namespace, then you can perform an idempotent update using following STS CLI commands:

For export: sts graph export --namespace urn:stackpack:{stackpack_name}:

For import currently we have a curl way: curl -XPOST http://yourInstance/api/import?namespace=urn:stackpack:{stackpack_name} --data @./filename -H 'Content-Type: application/json'

Configuration Export Versioning

Available since StackState version 1.14.0

As StackState evolves versioning of the exported Node elements is necessary. The export conf contains metadata stating the Node version (_version) which is useful in order to allow an autoupgrade to a more recent version of StackState and ensure compatibility.

{
  "_version": "1.0.0",
  "timestamp": "2018-12-06T12:30:44.148Z[Etc/UTC]",
  "nodes": [
    {
      "_type": "CheckFunction",
      "name": "Metric fixed run state",
      "returnTypes": [
        "RUN_STATE"
      ],
      "description": "This check will always return the run state that is provided when a metric has been received.",
      "id": -196,
      "script": "return metricFixedRunState;",
      "parameters": [
        {
          "_type": "Parameter",
          "name": "metrics",
          "system": false,
          "id": -194,
          "multiple": false,
          "type": "METRIC_STREAM",
          "required": true
        },
        {
          "_type": "Parameter",
          "name": "metricFixedRunState",
          "system": false,
          "id": -195,
          "multiple": false,
          "type": "RUN_STATE_VALUE",
          "required": true
        }
      ]
    }
  ]
}

Supported Configuration Export version

A configuration export is supported by versions of StackState that are equal or higher than the export's version and with the same major version (see semver). The first configuration export version is 1.0.0, and effectively any Node payload with a version below or missing the version field (_version) will be interpreted and auto-upgraded to version 1.0.0.

For example:

Configuration export version 1.0.0 was introduced in StackState version 1.14.0 Later configuration export version 1.1.0 was introduced in StackState version 1.14.1 Later configuration export version 2.0.0 was introduced in StackState version 1.15.0

This means that Nodes with Configuration version 1.0.0 will work on both StackState 1.14.0 and 1.14.1 but not in 1.15.0 as a major configuration export version (2.0.0) was introduced. As well it means that configuration export version 1.1.0 can only be used from StackState version 1.14.1 but not before as in 1.14.0

Configuration export versions

The table below displays configuration export versions version and on which StackState versions they were introduced.

Configuration Export version

Introduced on StackState version

1.0.0

1.14.0

Last updated