-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresource.tf
More file actions
176 lines (163 loc) · 3.99 KB
/
resource.tf
File metadata and controls
176 lines (163 loc) · 3.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# examples/resources/groundcover_dashboard/resource.tf
terraform {
required_providers {
groundcover = {
source = "registry.terraform.io/groundcover-com/groundcover"
version = ">= 1.0.0"
}
}
}
provider "groundcover" {
# Configure API key and Backend ID via environment variables
# export GROUNDCOVER_API_KEY="YOUR_API_KEY"
# export GROUNDCOVER_BACKEND_ID="YOUR_BACKEND_ID"
api_key = var.groundcover_api_key
backend_id = var.groundcover_backend_id
# api_url = "..." # Optional: Override default API URL
}
variable "groundcover_api_key" {
type = string
description = "groundcover API Key"
sensitive = true
}
variable "groundcover_backend_id" {
type = string
description = "groundcover Backend ID"
}
# Example Dashboard: Basic metrics dashboard
resource "groundcover_dashboard" "metrics_dashboard" {
name = "Terraform Example - Metrics Dashboard"
description = "Example dashboard showing system metrics"
team = "platform"
# Dashboard preset contains the JSON configuration
preset = jsonencode({
duration = "Last 1 hour"
layout = [
{
id = "A"
x = 0
y = 0
w = 12
h = 4
minH = 2
},
{
id = "B"
x = 0
y = 4
w = 6
h = 4
minH = 2
},
{
id = "C"
x = 6
y = 4
w = 6
h = 4
minH = 2
}
]
widgets = [
{
id = "A"
type = "widget"
name = "CPU Usage"
queries = [
{
id = "A"
expr = "avg(rate(container_cpu_usage_seconds_total[5m])) * 100"
dataType = "metrics"
step = null
editorMode = "builder"
}
]
visualizationConfig = {
type = "time-series"
}
},
{
id = "B"
type = "widget"
name = "Memory Usage"
queries = [
{
id = "B"
expr = "avg(container_memory_usage_bytes)"
dataType = "metrics"
step = null
editorMode = "builder"
}
]
visualizationConfig = {
type = "gauge"
}
},
{
id = "C"
type = "text"
html = "<h3>System Metrics</h3><p>This dashboard shows key system metrics including CPU and memory usage.</p>"
}
]
variables = {}
schemaVersion = 3
})
}
# Example Dashboard: Simple monitoring dashboard
resource "groundcover_dashboard" "simple_dashboard" {
name = "Simple Dashboard"
preset = jsonencode({
duration = "Last 30 minutes"
layout = [
{
id = "widget1"
x = 0
y = 0
w = 12
h = 6
minH = 3
}
]
widgets = [
{
id = "widget1"
type = "widget"
name = "Request Rate"
queries = [
{
id = "query1"
expr = "sum(rate(http_requests_total[5m]))"
dataType = "metrics"
step = null
editorMode = "code"
}
]
visualizationConfig = {
type = "time-series"
config = {
showLegend = true
unit = "ops"
}
}
}
]
variables = {}
schemaVersion = 3
})
}
output "metrics_dashboard_id" {
description = "The UUID of the metrics dashboard"
value = groundcover_dashboard.metrics_dashboard.id
}
output "metrics_dashboard_owner" {
description = "The owner of the metrics dashboard"
value = groundcover_dashboard.metrics_dashboard.owner
}
output "simple_dashboard_id" {
description = "The UUID of the simple dashboard"
value = groundcover_dashboard.simple_dashboard.id
}
output "simple_dashboard_owner" {
description = "The owner of the simple dashboard"
value = groundcover_dashboard.simple_dashboard.owner
}