Terraform provider for managing dashboards, alerts, and saved searches on ClickStack (HyperDX on ClickHouse Cloud).
Requirements
Installation
terraform {
required_providers {
clickstack = {
source = "registry.terraform.io/teamlapse/clickstack"
version = "~> 0.1"
}
}
}
Local Development
go install .
The binary will be installed to $GOPATH/bin/terraform-provider-clickstack.
Authentication
The provider authenticates with the ClickHouse Cloud API using an API key pair. You can configure credentials via provider arguments or environment variables:
| Provider Argument |
Environment Variable |
Description |
organization_id |
CLICKSTACK_ORGANIZATION_ID |
ClickHouse Cloud organization ID |
service_id |
CLICKSTACK_SERVICE_ID |
ClickStack service ID |
api_key_id |
CLICKSTACK_API_KEY_ID |
API key ID |
api_key_secret |
CLICKSTACK_API_KEY_SECRET |
API key secret |
base_url |
CLICKSTACK_BASE_URL |
API base URL (default: https://api.clickhouse.cloud) |
provider "clickstack" {
organization_id = var.clickstack_organization_id
service_id = var.clickstack_service_id
api_key_id = var.clickstack_api_key_id
api_key_secret = var.clickstack_api_key_secret
}
Resources
clickstack_dashboard — Manage observability dashboards with tiles, filters, and queries.
clickstack_alert — Manage threshold-based alerts from dashboard tiles or saved searches.
clickstack_saved_search — Manage reusable search queries.
Data Sources
clickstack_sources — List available data sources (log, trace, metric, session).
clickstack_webhooks — List configured webhooks (Slack, PagerDuty, etc.).
Quick Start
data "clickstack_sources" "all" {}
# Create a saved search for error logs
resource "clickstack_saved_search" "errors" {
name = "API Errors"
source_id = data.clickstack_sources.all.sources[0].id
where = "ServiceName:api-gateway AND SeverityText:ERROR"
order_by = "Timestamp DESC"
}
# Alert when errors exceed threshold
resource "clickstack_alert" "high_errors" {
name = "High Error Rate"
source = "saved_search"
saved_search_id = clickstack_saved_search.errors.id
threshold = 50
threshold_type = "above"
interval = "5m"
num_consecutive_windows = 3
channel {
type = "email"
email_recipients = ["oncall@example.com"]
}
}
num_consecutive_windows is optional and must be at least 1. Omit it to retain single-window alert evaluation.
See the examples/ directory for more complete usage.
Development
Building
go build -o terraform-provider-clickstack .
Testing
Acceptance tests require a live ClickStack instance. Set the environment variables above, then:
TF_ACC=1 go test ./... -v
Generating Documentation
go generate ./...
This runs tfplugindocs to regenerate the docs/ directory from schema descriptions and example files.
License
This project is licensed under the Mozilla Public License 2.0.