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
  • Setup
  • What's in the StackPack?
  • Building the StackPack
  • Importing the StackPack
  • Installing the StackPack
  • Seeing the topology in StackState
  • Making a change to the StackPack
  • Exporting the changed template
  • Updating the StackPack
  • Building a new version of the StackPack
  • Upgrading the StackPack
  • Cleaning your StackState instance
  1. Develop
  2. Tutorials

Create a simple StackPack

StackState Self-hosted v5.1.x

PreviousTutorialsNextPush data to StackState from an external system

Last updated 2 years ago

This tutorial shows you how to create a basic StackPack to configure StackState. See the for more information.

Setup

contains a sample project that containing a very basic StackPack. Clone the repository to your laptop to get started.

The repository contains a StackPack that configures StackState to receive external data and turn that into topology. The main configuration of the StackPack is in the src folder.

What's in the StackPack?

The tutorial StackPack is fairly basic. It includes configuration information that configure StackState to receive a specific data format and turn this into topology.

Specifically, the StackPack has:

  • A provisioning script that installs the components of the StackPack (TutorialProvision.groovy)

  • A component and relation template that tell StackState how to process incoming data into components and relations (tutorial-component-template.json.handlebars and tutorial-relation-template.json.handlebars)

  • component and relation ID extractor scripts that tell StackState how to extract the identifiers from the incoming data (Tutorial component id extractor.groovy and Tutorial relation id extractor.groovy)

  • files and images that are shown in the StackState GUI when users interact with the StackPack (in the resources directory)

  • A configuration file that describes all components of the StackPack (stackpack.conf)

Take a moment to locate these files in the src/main/stackpack folder of the project.

Building the StackPack

The first step is to build the StackPack into a binary file with extension .sts that we can send to StackState. Since the .sts file is essentially a ZIP archive, you can build the StackPack from the directory stackpack-tutorial/src/main/stackpack in the sample repository using the command:

zip -r ./tutorial-stackpack-0.0.1.sts stackpack.conf provisioning resources

Importing the StackPack

The following command installs our new tutorial StackPack in StackState:

From StackState v5.0, the old sts CLI has been renamed to stac and there is a new sts CLI. The command(s) provided here are for use with the new sts CLI.

sts stackpack upload tutorial-stackpack-0.0.1.sts
stac stackpack upload tutorial-stackpack-0.0.1.sts

⚠️ From StackState v5.0, the old sts CLI is called stac. The old CLI is now deprecated.

The new sts CLI replaces the stac CLI. It's advised to install the new sts CLI and upgrade any installed instance of the old sts CLI to stac. For details see:

The StackState CLI requires a conf.d configuration folder in the directory it's running from. This may require you to run the CLI from a different location. If so, remember to use an absolute path to refer to the StackPack binary.

We are now ready to install our tutorial StackPack.

Installing the StackPack

Open the StackState application in your browser and log in. Navigate to the StackPacks page that lists all available StackPacks. You should see our Tutorial StackPack in the list of StackPacks.

If you don't see the Tutorial StackPack, or you see an older version of the StackPack than you uploaded, try refreshing the page.

Open the Tutorial StackPack page. Here you see the installation instructions that are part of the StackPack (in the src/main/stackpack/resources directory). Install the StackPack with the Install button.

If all goes well, your StackPack should be installed and in the Waiting for data stage. This means the StackPack is ready to receive data, but hasn't yet received any. The StackState GUI tells you how to send data into the StackPack.

If you want to use the manual approach, copy the JSON listed in the StackPack page to your laptop and use the supplied curl command to send it to StackState.

The JSON and curl command shown in StackState contain data fields specific to your StackState installation, such as your API key and StackState URL.

When the StackPack has received your data, it will show a message indicating success and allowing you to explore your data.

Seeing the topology in StackState

When you log into your StackState instance, go to the Explore Mode. Using the topology filter, select all topology with the tutorial label. This should result in a topology similar to the following:

Note that the components you see are constructed from the JSON data you sent in. The components appear in the Tutorial Domain domain and Tutorial Components layers.

Select a component to display detailed information about it in the right panel details tab - Component details. You'll see the component's labels and other meta-data you sent.

Making a change to the StackPack

Now we are going to make a change to the tutorial StackPack. Let's say you want to add a telemetry stream to all of the components that the StackPack creates. This requires a change to the StackPack's component template. We are going to make this change in StackState and then update the StackPack with our changes.

Select the myDummyApp component to display detailed information about it in the right panel tab - Component details. Find the triple dots menu in the top-right corner. There, select the Edit template option. This brings up the Template Editor.

In the Template Editor you can edit the template used to create components based on data coming in from your sample check. It shows the following information:

  • Input parameters - The data sent by our curl command that's processed by StackState

  • Template function - The template that uses the input parameters to create a component

  • Component preview - A preview of the component produced by applying the input parameters to the template function

Check out the Template Examples tab in the Template Editor to learn how to create templates.

In the Template function, replace the streams part with the following code:

"streams": [{
  "_type": "MetricStream",
  "dataSource": {{ get "urn:stackpack:common:data-source:stackstate-metrics"  }},
  "dataType": "METRICS",
  "id": -11,
  "name": "test",
  "query": {
    "_type": "MetricTelemetryQuery",
    "aggregation": "MEAN",
    "conditions": [{
      "key": "tags.related",
      "value": "{{ element.externalId }}"
    }],
    "id": -13,
    "metricField": "example.gauge"
  },
  "syncCreated": false
}],

Use the Preview button to see what the resulting component will look like.

Exporting the changed template

Now we are going to export the changed component template so we can include it in our StackPack.

Navigate to the Settings page and find the Topology Synchronization section. In that section, find the Component Templates page. Here you will find all component templates that StackState has loaded.

Locate the tutorial StackPack template (tutorial-tutorial://tutorial-1-component-template) among the templates. Check the checkbox in front of the template and use the Export Component Template Function button to export it.

Updating the StackPack

The exported component template will replace the tutorial-component-template.json.handlebarsfile in your StackPack. The export has a different structure than the file in our StackPack so we need to edit the file before updating the original. Specifically, the file in our StackPack has only the handlebarsTemplate property in the export.

Open the exported file in an editor and make the following changes:

  • Replace the entire file with the contents of the handlebarsTemplate property

  • Replace escaped newlines () with newline characters

  • Replace escaped quotes (\") with quote characters (")

After your edits, the exported file should look like this:

{
    "_type": "Component",
    "checks": [],
"streams": [{
  "_type": "MetricStream",
  "dataSource": \{{ get "urn:stackpack:common:data-source:stackstate-metrics"  \}},
  "dataType": "METRICS",
  "id": -11,
  "name": "test",
  "query": {
    "_type": "MetricTelemetryQuery",
    "aggregation": "MEAN",
    "conditions": [{
      "key": "tags.related",
      "value": "\{{ element.externalId \}}"
    }],
    "id": -13,
    "metricField": "example.gauge"
  },
  "syncCreated": false
}],
    "labels": [
        \{{#if element.data.labels \}}
            \{{# join element.data.labels "," "" "," \}}
            {
            "_type": "Label",
            "name": "\{{ this \}}"
            }
            \{{/ join \}}
        \{{/if\}}
        {
            "_type": "Label",
            "name": "tutorial:tutorial://tutorial-1"
        }
        \{{#if element.data.tags \}}
            \{{# join element.data.tags "," "," "" \}}
            {
              "_type": "Label",
              "name": "\{{ this \}}"
            }
            \{{/ join \}}
        \{{/if\}}
    ],
    "name": "\{{#if element.data.name\}}\{{ element.data.name \}}\{{else\}}\{{ element.externalId \}}\{{/if\}}",
    \{{#if element.data.description\}}
    "description": "\{{ element.data.description \}}",
    \{{/if\}}
    "type" : \{{ resolveOrCreate "ComponentType" element.type.name "Tutorial Component" \}},
    "version": "\{{ element.data.version \}}",
    "layer": \{{ resolveOrCreate "Layer" element.data.layer "Tutorial Components" \}},
    "domain": \{{ resolveOrCreate "Domain" element.data.domain "Tutorial Domain" \}},
    "environments": [
        \{{ resolveOrCreate "Environment" element.data.environment "Tutorial Environment" \}}
    ]
}

Now replace the file in your StackPack with the above JSON.

If you want to change the Groovy scripts, beware that the Groovy script files contain only the Groovy code and no JSON wrappers.

The tutorial-template.stj has a DataSource and Synchronization and includes the contents of the separate templates and Groovy script files into a single JSON

Building a new version of the StackPack

We are going to build a new version of our StackPack with our changed template.

zip -r ./stackpack-0.0.2.sts stackpack.conf provisioning resources

This should produce a 0.0.2 version of the StackPack. Upload the StackPack to StackState using the CLI.

Upgrading the StackPack

Navigate to the StackPacks page in StackState and find the Tutorial StackPack. If the StackPack is still installed, you should see that there is a new version available. This is what that message looks like:

If you don't see the Tutorial StackPack, or you see an older version of the StackPack than you uploaded, try refreshing the page.

You can use the Upgrade now button to upgrade the StackPack to the new version. StackState will perform the upgrade, but because you have unlocked a template earlier, you will see the following warning:

Push the Overwrite button to overwrite your local modifications with those in the new version of the StackPack. The component template will be locked again after the upgrade.

Pass the Waiting for data stage again with the curl command we used earlier and your upgrade is complete.

If you navigate to your myDummyApp component, you should now see the stream you added to the template:

Cleaning your StackState instance

When you are done with this tutorial, you can remove the configuration from your StackState instance as follows:

  • Uninstall the Tutorial StackPack. This will remove the configuration and data received (topology) from StackState.

The StackPack must be imported into StackState before it can be installed. This can be done using the . Please make sure it's installed and configured to connect with your StackState instance.

➡️

The describes in more detail how to create this check.

Go ahead and save the template. Be aware that you may need to it before this succeeds.

It's also possible to install and upgrade a StackPack using the CLI, see the for more information.

📖
StackPacks documentation
This GitHub repository
Groovy
Groovy
Markdown
StackState CLI
Comparison between the CLIs
Push Integration tutorial
CLI documentation
Check which version of the sts CLI you are running
Which version of the sts CLI am I running?
Install the new sts CLI and upgrade the old sts CLI to stac
unlock