Skip to content

Commit ef134d0

Browse files
Cloud Stack: Add traces and graphite attributes (#612)
Closes #566
1 parent f8649fb commit ef134d0

File tree

4 files changed

+77
-4
lines changed

4 files changed

+77
-4
lines changed

docs/data-sources/cloud_stack.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ available at “https://<stack_slug>.grafana.net".
4040
- `alertmanager_url` (String) Base URL of the Alertmanager instance configured for this stack.
4141
- `alertmanager_user_id` (Number) User ID of the Alertmanager instance configured for this stack.
4242
- `description` (String) Description of stack.
43+
- `graphite_name` (String)
44+
- `graphite_status` (String)
45+
- `graphite_url` (String)
46+
- `graphite_user_id` (Number)
4347
- `id` (String) The stack id assigned to this stack by Grafana.
4448
- `logs_name` (String)
4549
- `logs_status` (String)
@@ -54,9 +58,13 @@ available at “https://<stack_slug>.grafana.net".
5458
- `prometheus_remote_write_endpoint` (String) Use this URL to send prometheus metrics to Grafana cloud
5559
- `prometheus_status` (String) Prometheus status for this instance.
5660
- `prometheus_url` (String) Prometheus url for this instance.
57-
- `prometheus_user_id` (Number) Promehteus user ID. Used for e.g. remote_write.
61+
- `prometheus_user_id` (Number) Prometheus user ID. Used for e.g. remote_write.
5862
- `region_slug` (String) The region this stack is deployed to.
5963
- `status` (String) Status of the stack.
64+
- `traces_name` (String)
65+
- `traces_status` (String)
66+
- `traces_url` (String)
67+
- `traces_user_id` (Number)
6068
- `url` (String) Custom URL for the Grafana instance. Must have a CNAME setup to point to `.grafana.net` before creating the stack
6169

6270

docs/resources/cloud_stack.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ Changing region will destroy the existing stack and create a new one in the desi
4545
- `alertmanager_status` (String) Status of the Alertmanager instance configured for this stack.
4646
- `alertmanager_url` (String) Base URL of the Alertmanager instance configured for this stack.
4747
- `alertmanager_user_id` (Number) User ID of the Alertmanager instance configured for this stack.
48+
- `graphite_name` (String)
49+
- `graphite_status` (String)
50+
- `graphite_url` (String)
51+
- `graphite_user_id` (Number)
4852
- `id` (String) The stack id assigned to this stack by Grafana.
4953
- `logs_name` (String)
5054
- `logs_status` (String)
@@ -58,8 +62,12 @@ Changing region will destroy the existing stack and create a new one in the desi
5862
- `prometheus_remote_write_endpoint` (String) Use this URL to send prometheus metrics to Grafana cloud
5963
- `prometheus_status` (String) Prometheus status for this instance.
6064
- `prometheus_url` (String) Prometheus url for this instance.
61-
- `prometheus_user_id` (Number) Promehteus user ID. Used for e.g. remote_write.
65+
- `prometheus_user_id` (Number) Prometheus user ID. Used for e.g. remote_write.
6266
- `status` (String) Status of the stack.
67+
- `traces_name` (String)
68+
- `traces_status` (String)
69+
- `traces_url` (String)
70+
- `traces_user_id` (Number)
6371

6472
## Import
6573

grafana/resource_cloud_stack.go

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,12 @@ Changing region will destroy the existing stack and create a new one in the desi
125125
Computed: true,
126126
Description: "Status of the stack.",
127127
},
128+
129+
// Hosted Metrics
128130
"prometheus_user_id": {
129131
Type: schema.TypeInt,
130132
Computed: true,
131-
Description: "Promehteus user ID. Used for e.g. remote_write.",
133+
Description: "Prometheus user ID. Used for e.g. remote_write.",
132134
},
133135
"prometheus_url": {
134136
Type: schema.TypeString,
@@ -155,6 +157,8 @@ Changing region will destroy the existing stack and create a new one in the desi
155157
Computed: true,
156158
Description: "Prometheus status for this instance.",
157159
},
160+
161+
// Alerting
158162
"alertmanager_user_id": {
159163
Type: schema.TypeInt,
160164
Computed: true,
@@ -175,6 +179,8 @@ Changing region will destroy the existing stack and create a new one in the desi
175179
Computed: true,
176180
Description: "Status of the Alertmanager instance configured for this stack.",
177181
},
182+
183+
// Hosted Logs
178184
"logs_user_id": {
179185
Type: schema.TypeInt,
180186
Computed: true,
@@ -191,6 +197,42 @@ Changing region will destroy the existing stack and create a new one in the desi
191197
Type: schema.TypeString,
192198
Computed: true,
193199
},
200+
201+
// Traces
202+
"traces_user_id": {
203+
Type: schema.TypeInt,
204+
Computed: true,
205+
},
206+
"traces_name": {
207+
Type: schema.TypeString,
208+
Computed: true,
209+
},
210+
"traces_url": {
211+
Type: schema.TypeString,
212+
Computed: true,
213+
},
214+
"traces_status": {
215+
Type: schema.TypeString,
216+
Computed: true,
217+
},
218+
219+
// Graphite
220+
"graphite_user_id": {
221+
Type: schema.TypeInt,
222+
Computed: true,
223+
},
224+
"graphite_name": {
225+
Type: schema.TypeString,
226+
Computed: true,
227+
},
228+
"graphite_url": {
229+
Type: schema.TypeString,
230+
Computed: true,
231+
},
232+
"graphite_status": {
233+
Type: schema.TypeString,
234+
Computed: true,
235+
},
194236
},
195237
}
196238
}
@@ -316,10 +358,10 @@ func FlattenStack(d *schema.ResourceData, stack gapi.Stack) error {
316358
d.Set("prometheus_url", stack.HmInstancePromURL)
317359
d.Set("prometheus_name", stack.HmInstancePromName)
318360
reURL, err := appendPath(stack.HmInstancePromURL, "/api/prom")
319-
d.Set("prometheus_remote_endpoint", reURL)
320361
if err != nil {
321362
return err
322363
}
364+
d.Set("prometheus_remote_endpoint", reURL)
323365
rweURL, err := appendPath(stack.HmInstancePromURL, "/api/prom/push")
324366
if err != nil {
325367
return err
@@ -337,6 +379,16 @@ func FlattenStack(d *schema.ResourceData, stack gapi.Stack) error {
337379
d.Set("alertmanager_url", stack.AmInstanceURL)
338380
d.Set("alertmanager_status", stack.AmInstanceStatus)
339381

382+
d.Set("traces_user_id", stack.HtInstanceID)
383+
d.Set("traces_name", stack.HtInstanceName)
384+
d.Set("traces_url", stack.HtInstanceURL)
385+
d.Set("traces_status", stack.HtInstanceStatus)
386+
387+
d.Set("graphite_user_id", stack.HmInstanceGraphiteID)
388+
d.Set("graphite_name", stack.HmInstanceGraphiteName)
389+
d.Set("graphite_url", stack.HmInstanceGraphiteURL)
390+
d.Set("graphite_status", stack.HmInstanceGraphiteStatus)
391+
340392
return nil
341393
}
342394

grafana/resource_cloud_stack_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ func TestResourceCloudStack_Basic(t *testing.T) {
4040
resource.TestCheckResourceAttr("grafana_cloud_stack.test", "status", "active"),
4141
resource.TestCheckResourceAttr("grafana_cloud_stack.test", "prometheus_remote_endpoint", "https://prometheus-prod-01-eu-west-0.grafana.net/api/prom"),
4242
resource.TestCheckResourceAttr("grafana_cloud_stack.test", "prometheus_remote_write_endpoint", "https://prometheus-prod-01-eu-west-0.grafana.net/api/prom/push"),
43+
resource.TestCheckResourceAttrSet("grafana_cloud_stack.test", "prometheus_user_id"),
44+
resource.TestCheckResourceAttrSet("grafana_cloud_stack.test", "alertmanager_user_id"),
45+
resource.TestCheckResourceAttrSet("grafana_cloud_stack.test", "logs_user_id"),
46+
resource.TestCheckResourceAttrSet("grafana_cloud_stack.test", "traces_user_id"),
47+
resource.TestCheckResourceAttrSet("grafana_cloud_stack.test", "graphite_user_id"),
4348
),
4449
},
4550
{

0 commit comments

Comments
 (0)