Prometheus: 4. Create the service
This documentation is part of the Automate with the CLI guide. View the full guide here: Start Prometheus, retrieve its credentials, and change its configuration programmatically with the Stackhero CLI.
👋 Welcome to the Stackhero documentation!
Stackhero delivers a fully managed Prometheus cloud platform designed for reliability and simplicity:
Alert Manageris built in, so you can route alerts directly toSlack,Mattermost,PagerDuty, and other popular destinations.- A dedicated email server lets you send unlimited email alerts without extra setup.
Blackboxis included, allowing you to probeHTTP,ICMP,TCP, and other protocols for comprehensive monitoring.- Configure your instance quickly using the online configuration file editor. There is no need to manage YAML by hand.
- Apply updates with a single click. Stackhero handles the upgrade process for you, minimizing downtime and manual intervention.
- High performance and strong security are built in, thanks to your own private, dedicated infrastructure.
Get up and running in about 5 minutes. Stackhero takes care of the setup so you can focus on monitoring, not maintenance. Try Prometheus cloud hosting on Stackhero to streamline your monitoring and alerting workflows.
Here is a sample script that creates a stack, adds your Prometheus service to it, waits for it to start, retrieves its configuration (including generated credentials), and then applies a new configuration.
#!/bin/bash
set -e
export STACKHERO_TOKEN="usr-xxxxxx:your-token"
serviceStore="prometheus" # The Prometheus service store name (see step 2)
instance="..." # An instance size from step 3
region="europe" # A region name from step 3
# Create a stack for your service (uses your default organization; add --organization if needed)
stackId=$(stackhero --format=script stack-create \
--name="My Prometheus stack")
echo "Stack created: ${stackId}"
# Add Prometheus to the stack (names are resolved automatically)
serviceId=$(stackhero --format=script service-add \
--stack="My Prometheus stack" \
--service-store="${serviceStore}" \
--instance="${instance}" \
--region="${region}")
echo "Service added: prometheus"
# Wait for the service to be fully running (this may take a couple of minutes)
stackhero service-wait-for --service="prometheus"
# Retrieve the service configuration, including generated credentials
stackhero service-configuration-get --service="prometheus" --format=json