Skip to content

Commit d3de24b

Browse files
Synthetic Monitoring: Allow filtering out deprecated probes (#332)
* Synthetic Monitoring: Allow filtering out deprecated probes I'd like to only use the current ones instead of the whole list * Default `filter_deprecated` to true * Remove deprecated probes from check resource
1 parent d10843b commit d3de24b

File tree

10 files changed

+44
-25
lines changed

10 files changed

+44
-25
lines changed

docs/data-sources/synthetic_monitoring_probes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ data "grafana_synthetic_monitoring_probes" "main" {}
2121

2222
### Optional
2323

24+
- **filter_deprecated** (Boolean) If true, only probes that are not deprecated will be returned. Defaults to `true`.
2425
- **id** (String) The ID of this resource.
2526

2627
### Read-Only

docs/resources/synthetic_monitoring_check.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ resource "grafana_synthetic_monitoring_check" "dns" {
5454
target = "grafana.net"
5555
enabled = false
5656
probes = [
57-
data.grafana_synthetic_monitoring_probes.main.probes.Chicago,
58-
data.grafana_synthetic_monitoring_probes.main.probes.LosAngeles,
57+
data.grafana_synthetic_monitoring_probes.main.probes.Frankfurt,
58+
data.grafana_synthetic_monitoring_probes.main.probes.London,
5959
]
6060
labels = {
6161
foo = "baz"
@@ -249,8 +249,8 @@ resource "grafana_synthetic_monitoring_check" "ping" {
249249
target = "grafana.net"
250250
enabled = false
251251
probes = [
252-
data.grafana_synthetic_monitoring_probes.main.probes.Chicago,
253-
data.grafana_synthetic_monitoring_probes.main.probes.LosAngeles,
252+
data.grafana_synthetic_monitoring_probes.main.probes.Frankfurt,
253+
data.grafana_synthetic_monitoring_probes.main.probes.London,
254254
]
255255
labels = {
256256
foo = "baz"
@@ -296,8 +296,8 @@ resource "grafana_synthetic_monitoring_check" "tcp" {
296296
target = "grafana.com:443"
297297
enabled = false
298298
probes = [
299-
data.grafana_synthetic_monitoring_probes.main.probes.Chicago,
300-
data.grafana_synthetic_monitoring_probes.main.probes.LosAngeles,
299+
data.grafana_synthetic_monitoring_probes.main.probes.Frankfurt,
300+
data.grafana_synthetic_monitoring_probes.main.probes.London,
301301
]
302302
labels = {
303303
foo = "baz"
@@ -390,8 +390,8 @@ resource "grafana_synthetic_monitoring_check" "traceroute" {
390390
frequency = 120000
391391
timeout = 30000
392392
probes = [
393-
data.grafana_synthetic_monitoring_probes.main.probes.Chicago,
394-
data.grafana_synthetic_monitoring_probes.main.probes.LosAngeles,
393+
data.grafana_synthetic_monitoring_probes.main.probes.Frankfurt,
394+
data.grafana_synthetic_monitoring_probes.main.probes.London,
395395
]
396396
labels = {
397397
foo = "baz"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
data "grafana_synthetic_monitoring_probes" "main" {
2+
filter_deprecated = false
3+
}

examples/resources/grafana_synthetic_monitoring_check/dns_complex.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ resource "grafana_synthetic_monitoring_check" "dns" {
55
target = "grafana.net"
66
enabled = false
77
probes = [
8-
data.grafana_synthetic_monitoring_probes.main.probes.Chicago,
9-
data.grafana_synthetic_monitoring_probes.main.probes.LosAngeles,
8+
data.grafana_synthetic_monitoring_probes.main.probes.Frankfurt,
9+
data.grafana_synthetic_monitoring_probes.main.probes.London,
1010
]
1111
labels = {
1212
foo = "baz"

examples/resources/grafana_synthetic_monitoring_check/ping_complex.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ resource "grafana_synthetic_monitoring_check" "ping" {
55
target = "grafana.net"
66
enabled = false
77
probes = [
8-
data.grafana_synthetic_monitoring_probes.main.probes.Chicago,
9-
data.grafana_synthetic_monitoring_probes.main.probes.LosAngeles,
8+
data.grafana_synthetic_monitoring_probes.main.probes.Frankfurt,
9+
data.grafana_synthetic_monitoring_probes.main.probes.London,
1010
]
1111
labels = {
1212
foo = "baz"

examples/resources/grafana_synthetic_monitoring_check/tcp_complex.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ resource "grafana_synthetic_monitoring_check" "tcp" {
55
target = "grafana.com:443"
66
enabled = false
77
probes = [
8-
data.grafana_synthetic_monitoring_probes.main.probes.Chicago,
9-
data.grafana_synthetic_monitoring_probes.main.probes.LosAngeles,
8+
data.grafana_synthetic_monitoring_probes.main.probes.Frankfurt,
9+
data.grafana_synthetic_monitoring_probes.main.probes.London,
1010
]
1111
labels = {
1212
foo = "baz"

examples/resources/grafana_synthetic_monitoring_check/traceroute_complex.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ resource "grafana_synthetic_monitoring_check" "traceroute" {
77
frequency = 120000
88
timeout = 30000
99
probes = [
10-
data.grafana_synthetic_monitoring_probes.main.probes.Chicago,
11-
data.grafana_synthetic_monitoring_probes.main.probes.LosAngeles,
10+
data.grafana_synthetic_monitoring_probes.main.probes.Frankfurt,
11+
data.grafana_synthetic_monitoring_probes.main.probes.London,
1212
]
1313
labels = {
1414
foo = "baz"

grafana/data_source_synthetic_monitoring_probes.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ func dataSourceSyntheticMonitoringProbes() *schema.Resource {
1212
Description: "Data source for retrieving all probes.",
1313
ReadContext: dataSourceSyntheticMonitoringProbesRead,
1414
Schema: map[string]*schema.Schema{
15+
"filter_deprecated": {
16+
Type: schema.TypeBool,
17+
Description: "If true, only probes that are not deprecated will be returned.",
18+
Optional: true,
19+
Default: true,
20+
},
1521
"probes": {
1622
Description: "Map of probes with their names as keys and IDs as values.",
1723
Type: schema.TypeMap,
@@ -34,7 +40,9 @@ func dataSourceSyntheticMonitoringProbesRead(ctx context.Context, d *schema.Reso
3440

3541
probes := make(map[string]interface{}, len(prbs))
3642
for _, p := range prbs {
37-
probes[p.Name] = p.Id
43+
if !p.Deprecated || !d.Get("filter_deprecated").(bool) {
44+
probes[p.Name] = p.Id
45+
}
3846
}
3947

4048
d.SetId("probes")

grafana/data_source_synthetic_monitoring_probes_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,16 @@ func TestAccDataSourceSyntheticMonitoringProbes(t *testing.T) {
1616
{
1717
Config: testAccExample(t, "data-sources/grafana_synthetic_monitoring_probes/data-source.tf"),
1818
Check: resource.ComposeTestCheckFunc(
19+
resource.TestCheckNoResourceAttr("data.grafana_synthetic_monitoring_probes.main", "probes.Seol"),
1920
resource.TestCheckResourceAttr("data.grafana_synthetic_monitoring_probes.main", "probes.Atlanta", "1"),
2021
),
2122
},
23+
{
24+
Config: testAccExample(t, "data-sources/grafana_synthetic_monitoring_probes/with-deprecated.tf"),
25+
Check: resource.ComposeTestCheckFunc(
26+
resource.TestCheckResourceAttr("data.grafana_synthetic_monitoring_probes.main", "probes.Seol", "9"),
27+
),
28+
},
2229
},
2330
})
2431
}

grafana/resource_synthetic_monitoring_check_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ func TestAccResourceSyntheticMonitoringCheck_dns(t *testing.T) {
3737
resource.TestCheckResourceAttrSet("grafana_synthetic_monitoring_check.dns", "tenant_id"),
3838
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.dns", "job", "DNS Updated"),
3939
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.dns", "target", "grafana.net"),
40-
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.dns", "probes.0", "2"),
41-
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.dns", "probes.1", "3"),
40+
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.dns", "probes.0", "14"),
41+
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.dns", "probes.1", "19"),
4242
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.dns", "labels.foo", "baz"),
4343
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.dns", "settings.0.dns.0.ip_version", "Any"),
4444
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.dns", "settings.0.dns.0.server", "8.8.4.4"),
@@ -142,8 +142,8 @@ func TestAccResourceSyntheticMonitoringCheck_ping(t *testing.T) {
142142
resource.TestCheckResourceAttrSet("grafana_synthetic_monitoring_check.ping", "tenant_id"),
143143
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.ping", "job", "Ping Updated"),
144144
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.ping", "target", "grafana.net"),
145-
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.ping", "probes.0", "2"),
146-
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.ping", "probes.1", "3"),
145+
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.ping", "probes.0", "14"),
146+
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.ping", "probes.1", "19"),
147147
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.ping", "labels.foo", "baz"),
148148
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.ping", "settings.0.ping.0.ip_version", "Any"),
149149
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.ping", "settings.0.ping.0.payload_size", "20"),
@@ -181,8 +181,8 @@ func TestAccResourceSyntheticMonitoringCheck_tcp(t *testing.T) {
181181
resource.TestCheckResourceAttrSet("grafana_synthetic_monitoring_check.tcp", "tenant_id"),
182182
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.tcp", "job", "TCP Defaults"),
183183
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.tcp", "target", "grafana.com:443"),
184-
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.tcp", "probes.0", "2"),
185-
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.tcp", "probes.1", "3"),
184+
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.tcp", "probes.0", "14"),
185+
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.tcp", "probes.1", "19"),
186186
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.tcp", "labels.foo", "baz"),
187187
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.tcp", "settings.0.tcp.0.ip_version", "V6"),
188188
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.tcp", "settings.0.tcp.0.tls", "true"),
@@ -228,8 +228,8 @@ func TestAccResourceSyntheticMonitoringCheck_traceroute(t *testing.T) {
228228
resource.TestCheckResourceAttrSet("grafana_synthetic_monitoring_check.traceroute", "tenant_id"),
229229
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.traceroute", "job", "Traceroute complex"),
230230
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.traceroute", "target", "grafana.net"),
231-
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.traceroute", "probes.0", "2"),
232-
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.traceroute", "probes.1", "3"),
231+
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.traceroute", "probes.0", "14"),
232+
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.traceroute", "probes.1", "19"),
233233
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.traceroute", "labels.foo", "baz"),
234234
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.traceroute", "settings.0.traceroute.0.max_hops", "25"),
235235
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.traceroute", "settings.0.traceroute.0.max_unknown_hops", "10"),

0 commit comments

Comments
 (0)