-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresource.tf
More file actions
740 lines (639 loc) · 18.8 KB
/
resource.tf
File metadata and controls
740 lines (639 loc) · 18.8 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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
terraform {
required_providers {
groundcover = {
source = "groundcover-com/groundcover"
}
}
}
# Configure the groundcover Provider
provider "groundcover" {
# api_key can be set via the GROUNDCOVER_API_KEY environment variable
# backend_id can be set via the GROUNDCOVER_BACKEND_ID environment variable
# api_url can be set via the GROUNDCOVER_API_URL environment variable (optional)
}
# Example: CloudWatch DataIntegration
# For a full list of supported AWS metrics and statistics, visit the official CloudWatch documentation:
# https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/aws-services-cloudwatch-metrics.html
resource "groundcover_dataintegration" "cloudwatch_example" {
type = "cloudwatch"
config = jsonencode({
name = "test-cloudwatch"
version = 1
stsRegion = "us-east-1"
regions = ["us-east-1", "us-east-2"]
roleArn = "arn:aws:iam::123456789012:role/test-role"
# use awsNamespaces to pull all metrics from a namespace, or awsMetrics to pull specific metrics
awsNamespaces = ["AWS/ApplicationELB"]
awsMetrics = [
{
namespace = "AWS/EC2"
metrics = [
{
name = "CPUUtilization"
statistics = ["Average"]
}
]
}
]
labelSettings = {
extraLabels = { env = "prod" }
}
# use this parameter to enrich with resource labels
withContextTagsOnInfoMetrics = true
scrapeInterval = 300000000000
exporters = ["prometheus"]
})
is_paused = false
}
# Example: GCP Metrics DataIntegration
# For a full list of supported GCP metrics, visit the official GCP documentation:
# https://cloud.google.com/monitoring/api/metrics_gcp
resource "groundcover_dataintegration" "gcp_example" {
type = "gcpmetrics"
config = jsonencode({
name = "test-gcp"
version = 1
enabled = true
targetServiceAccount = "demo@gcp-demo-project.iam.gserviceaccount.com"
regions = ["us-west1"]
metricPrefixes = ["cloudsql.googleapis.com", "compute.googleapis.com"]
projectIDs = ["gcp-demo-project"]
scrapeInterval = 300000000000
exporters = ["prometheus"]
labelSettings = {
extraLabels = { env = "prod" }
}
})
is_paused = false
}
# Example: Azure Metrics DataIntegration
# For a full list of supported Azure metrics, visit the official Azure Monitor documentation:
# https://learn.microsoft.com/en-us/azure/azure-monitor/reference/metrics-index
resource "groundcover_dataintegration" "azure_example" {
type = "azuremetrics"
config = jsonencode({
name = "Azure demo"
version = 1
subscriptions = ["b3128f7e-54df-4d2e-9c3e-93a4f1f8c9a0"]
regions = ["australiaeast"]
azureMetrics = [
{
resourceType = "Microsoft.Compute/virtualMachines"
metrics = [
{ name = "Available Memory Bytes" }
]
aggregations = ["Average", "Maximum", "Minimum"]
}
]
azureCloudEnvironment = "AzurePublicCloud"
scrapeInterval = 300000000000
labelSettings = {
extraLabels = { env = "prod" }
}
exporters = ["prometheus"]
})
is_paused = false
}
# Example: Prometheus Static Targets
resource "groundcover_dataintegration" "prometheus_static_example" {
type = "prometheusscrape"
config = jsonencode({
version = 1
enabled = true
name = "prometheus-static-config"
scheme = "https"
metricsPath = "/metrics"
scrapeInterval = 30000000000
scrapeTimeout = 10000000000
staticTargets = [
"prometheus-target.example.com:9090"
]
exporters = [
"prometheus"
]
metricsRelabels = {
# List of regex of metrics to keep. All other metrics will be dropped.
keepRegex = [
"[*]cpu[*]"
]
# List of regex of metrics to drop
dropRegex = [
"DB1[*]"
]
raw = <<-EOT
# additional relabeling rules that can be applied such as adding a prefix
- action: labelmap
replacement: "groundcover_$1"
EOT
}
labelSettings = {
extraLabels = {
env = "prod"
}
}
authentication = {
basicAuth = {
username = "prometheus-user"
# refer to groundcover_secret to create a secret
password = "secretRef::store::d1fc037f11f8ce58"
}
}
})
is_paused = false
}
# Example: Prometheus HTTPs Target Discovery
resource "groundcover_dataintegration" "prometheus_discovery_example" {
type = "prometheusscrape"
config = jsonencode({
version = 1
enabled = true
name = "Target discovery scraping example"
exporters = [
"prometheus"
]
# Durations are numeric (nanoseconds), preserved as-is
scrapeInterval = 30000000000
scrapeTimeout = 10000000000
metricsPath = "/metrics"
scheme = "http"
# provide the host details for discovery
httpDiscovery = {
url = "https://cloud.mongodb.com/prometheus/v1.0/groups/example"
# Please refer to the groundcover_secret doc on how to create a secret
authentication = { # Authentication for the discovery endpoint
basicAuth = {
username = "prom_user_6909b9ab19480f045c1f2eca"
password = "secretRef::store::5219731e4bc798eb"
}
}
}
# Relabeling options on discovered targets. keepRegex - drop all targets which don't comply with this rule. dropRegex - drop all targets which comply with this rule.
targetsRelabels = {
keepRegex = [
".*shard-00-02.*"
]
dropRegex = [
".*shard-00-01.*"
]
}
authentication = { # Authentication for scraping discovered targets
basicAuth = {
username = "prom_user_6909b9ab19480f045c1f2eca"
password = "secretRef::store::15e1b4b9c0ce0a45"
}
}
metricsRelabels = {
# List of regex of metrics to keep. All other metrics will be dropped.
keepRegex = [
"[*]cpu[*]"
]
dropRegex = [
"DB1[*]"
]
raw = <<-EOT
# additional relabeling rules that can be applied such as adding a prefix
- action: labelmap
replacement: "groundcover_$1"
EOT
}
labelSettings = {
extraLabels = {
env = "prod"
}
}
})
is_paused = false
}
# Example: MongoDB Atlas
resource "groundcover_dataintegration" "mongodb_atlas_example" {
type = "mongoatlasscrape"
config = jsonencode({
version = 1
enabled = true
name = "MongoDB Atlas example"
exporters = [
"prometheus"
]
# Durations are numeric (nanoseconds), preserved as-is
scrapeInterval = 30000000000
scrapeTimeout = 10000000000
metricsPath = "/metrics"
scheme = "http"
# provide the host details for discovery
httpDiscovery = {
url = "https://cloud.mongodb.com/prometheus/v1.0/groups/example/discovery"
# Please refer to the groundcover_secret doc on how to create a secret
authentication = { # Authentication for the discovery endpoint
basicAuth = {
username = "prom_user_6909b9ab19480f045c1f2eca"
password = "secretRef::store::5219731e4bc798eb"
}
}
}
# Relabeling options on discovered targets. keepRegex - drop all targets which don't comply with this rule. dropRegex - drop all targets which comply with this rule.
targetsRelabels = {
keepRegex = [
".*shard-00-02.*"
]
dropRegex = [
".*shard-00-01.*"
]
}
authentication = { # Authentication for scraping discovered targets
basicAuth = {
username = "prom_user_6909b9ab19480f045c1f2eca"
password = "secretRef::store::15e1b4b9c0ce0a45"
}
}
metricsRelabels = {
# List of regex of metrics to keep. All other metrics will be dropped.
keepRegex = []
dropRegex = [
"[*]catalogStats[*]"
]
raw = <<-EOT
# additional relabeling rules that can be applied such as adding a prefix
- action: labelmap
replacement: "groundcover_$1"
EOT
}
labelSettings = {
extraLabels = {
env = "prod"
}
}
})
is_paused = false
}
# Example: RabbitMQ
resource "groundcover_dataintegration" "rabbitmq_example" {
type = "rabbitscrape"
config = jsonencode({
version = 1
enabled = true
name = "RabbitMQ example"
exporters = [
"prometheus"
]
# Durations are numeric (nanoseconds), preserved as-is
scrapeInterval = 30000000000
scrapeTimeout = 10000000000
metricsPath = "/metrics"
scheme = "https"
# provide the list of hosts to scrape from
staticTargets = [
"myserver1:9090",
"myserver2:9090"
]
# Relabeling options on discovered targets. keepRegex - drop all targets which don't comply with this rule. dropRegex - drop all targets which comply with this rule.
targetsRelabels = {
keepRegex = [
".*shard-00-02.*"
]
dropRegex = [
".*shard-00-01.*"
]
}
authentication = {
basicAuth = {
username = "prom_user_6909b9ab19480f045c1f2eca"
password = "secretRef::store::15e1b4b9c0ce0a45"
}
}
metricsRelabels = {
# List of regex of metrics to keep. All other metrics will be dropped.
keepRegex = []
dropRegex = [
"[*]catalogStats[*]"
]
raw = <<-EOT
# additional relabeling rules that can be applied such as adding a prefix
- action: labelmap
replacement: "groundcover_$1"
EOT
}
labelSettings = {
extraLabels = {
env = "prod"
}
}
})
is_paused = false
}
# Example: Redis Cloud
resource "groundcover_dataintegration" "rediscloud_example" {
type = "rediscloudscrape"
config = jsonencode({
version = 1
enabled = true
name = "Redis Cloud example"
exporters = [
"prometheus"
]
# Durations are numeric (nanoseconds), preserved as-is
scrapeInterval = 30000000000
scrapeTimeout = 10000000000
metricsPath = "/metrics"
scheme = "https"
# provide the host details for discovery
staticTargets = [
"https://your-redis-cloud-address:8070"
]
# Relabeling options on discovered targets. keepRegex - drop all targets which don't comply with this rule. dropRegex - drop all targets which comply with this rule.
targetsRelabels = {
keepRegex = [
".*shard-00-02.*"
]
dropRegex = [
".*shard-00-01.*"
]
}
authentication = {
headerAuth = {
key = "bearer_token"
value = "secretRef::store::15e1b4b9c0ce0a45"
}
}
metricsRelabels = {
# List of regex of metrics to keep. All other metrics will be dropped.
keepRegex = []
dropRegex = [
"[*]catalogStats[*]"
]
raw = <<-EOT
# additional relabeling rules that can be applied such as adding a prefix
- action: labelmap
replacement: "groundcover_$1"
EOT
}
labelSettings = {
extraLabels = {
env = "prod"
}
}
})
is_paused = false
}
# Example: ClickHouse - Query Log & Custom Metrics
resource "groundcover_dataintegration" "clickhouse_demo" {
type = "clickhousedbm"
is_paused = false
config = jsonencode({
authentication = {
basicAuth = {
username = "default"
# use the groundcover_secret resource to create a secret
password = "secretRef::k8s::groundcover::groundcover-clickhouse::admin-password"
}
}
clusterMode = true # true if your ClickHouse is running in cluster mode; false for a single node
clusterName = "clustername" # the name of the cluster. Relevant if clusterMode=true
database = "your clickhouse db name"
dialTimeout = "10s"
enabled = true
host = "your clickhouse host details"
name = "clickhouse demo integration"
port = 9000
skipVerify = false
version = 1
labelSettings = {
extraLabels = {
env = "prod"
}
}
# Optional - generate metrics from custom sql's.
# metricsColumns - the list of metrics to be created
customMetricQueries = {
collectionInterval = "5m"
queries = [
{
name = "test query"
metricPrefix = "gc_clickhouse"
extraLabels = {}
metricsColumns = [
{
name = "accounts_count"
metricName = "total"
type = "counter"
}
]
query = <<EOT
SELECT
tier,
count() as accounts_count
FROM my_accounts
GROUP BY tier
EOT
}
]
}
# Optional - fetch query performance traces.
tables = {
queryLog = {
enabled = true
filterInserts = true
}
queryViewsLog = {
enabled = true
}
}
})
}
# Example: ClickHouse System Metrics DataIntegration
resource "groundcover_dataintegration" "clickhouse_system_metrics_example" {
type = "clickhousescrape"
config = jsonencode({
version = 1
enabled = true
name = "clickhouse-system-metrics-config"
scheme = "https"
metricsPath = "/metrics"
scrapeInterval = 30000000000
scrapeTimeout = 10000000000
staticTargets = [
"clickhouse-target.example.com:9090"
]
metricsRelabels = {
# List of regex of metrics to keep. All other metrics will be dropped.
keepRegex = [
"[*]cpu[*]"
]
# List of regex of metrics to drop
dropRegex = [
"DB1[*]"
]
raw = <<-EOT
# additional relabeling rules that can be applied such as adding a prefix
- action: labelmap
replacement: "groundcover_$1"
EOT
}
labelSettings = {
extraLabels = {
env = "prod"
}
}
authentication = {
basicAuth = {
username = "clickhouse-user"
# refer to groundcover_secret to create a secret
password = "secretRef::store::d1fc037f11f8ce58"
}
}
})
is_paused = false
}
# Example: PostgreSQL - Slow Queries & Custom Metrics
resource "groundcover_dataintegration" "postgresql_demo" {
type = "postgresqldbm"
is_paused = false
config = jsonencode({
authentication = {
basicAuth = {
username = "postgres"
# use the groundcover_secret resource to create a secret
password = "secretRef::k8s::groundcover::groundcover-postgresql::admin-password"
}
}
database = "your postgresql db name"
dialTimeout = "10s"
enabled = true
host = "your postgres host details"
name = "postgres demo integration"
port = 5432
secure = true
skipVerify = false
version = 1
labelSettings = {
extraLabels = {
env = "prod"
}
}
# Optional - generate metrics from custom sql's.
# metricsColumns - the list of metrics to be created
customMetricQueries = {
collectionInterval = "5m"
queries = [
{
name = "test query"
metricPrefix = "gc_postgres"
metricsColumns = [
{
name = "accounts_count"
metricName = "total"
type = "counter"
}
]
query = <<EOT
SELECT
tier,
count(*) as accounts_count
FROM my_accounts
GROUP BY tier
EOT
}
]
}
# Optional - fetch query performance traces.
tables = {
pgStatStatements = {
enabled = true
filterInserts = false
maxQueries = 200
}
}
})
}
# Example: PostgreSQL System Metrics DataIntegration
resource "groundcover_dataintegration" "postgresql_system_metrics_example" {
type = "postgresscrape"
config = jsonencode({
version = 1
enabled = true
name = "postgresql-system-metrics-config"
scheme = "https"
metricsPath = "/metrics"
scrapeInterval = 30000000000
scrapeTimeout = 10000000000
staticTargets = [
"postgresql-target.example.com:9090"
]
metricsRelabels = {
# List of regex of metrics to keep. All other metrics will be dropped.
keepRegex = [
"[*]cpu[*]"
]
# List of regex of metrics to drop
dropRegex = [
"DB1[*]"
]
raw = <<-EOT
# additional relabeling rules that can be applied such as adding a prefix
- action: labelmap
replacement: "groundcover_$1"
EOT
}
labelSettings = {
extraLabels = {
env = "prod"
}
}
authentication = {
basicAuth = {
username = "postgresql-user"
# refer to groundcover_secret to create a secret
password = "secretRef::store::d1fc037f11f8ce58"
}
}
})
is_paused = false
}
# Output the data integration IDs for reference
output "cloudwatch_dataintegration_id" {
description = "The ID of the CloudWatch data integration"
value = groundcover_dataintegration.cloudwatch_example.id
}
output "gcpmetrics_dataintegration_id" {
description = "The ID of the GCP Metrics data integration"
value = groundcover_dataintegration.gcp_example.id
}
output "azuremetrics_dataintegration_id" {
description = "The ID of the Azure Metrics data integration"
value = groundcover_dataintegration.azure_example.id
}
output "prometheus_static_dataintegration_id" {
description = "The ID of the Prometheus Static Targets data integration"
value = groundcover_dataintegration.prometheus_static_example.id
}
output "prometheus_discovery_dataintegration_id" {
description = "The ID of the Prometheus Target Discovery data integration"
value = groundcover_dataintegration.prometheus_discovery_example.id
}
output "mongodb_atlas_dataintegration_id" {
description = "The ID of the MongoDB Atlas data integration"
value = groundcover_dataintegration.mongodb_atlas_example.id
}
output "rabbitmq_dataintegration_id" {
description = "The ID of the RabbitMQ data integration"
value = groundcover_dataintegration.rabbitmq_example.id
}
output "rediscloud_dataintegration_id" {
description = "The ID of the Redis Cloud data integration"
value = groundcover_dataintegration.rediscloud_example.id
}
output "clickhouse_demo_dataintegration_id" {
description = "The ID of the ClickHouse Query Log & Custom Metrics data integration"
value = groundcover_dataintegration.clickhouse_demo.id
}
output "clickhouse_system_metrics_dataintegration_id" {
description = "The ID of the ClickHouse System Metrics data integration"
value = groundcover_dataintegration.clickhouse_system_metrics_example.id
}
output "postgresql_demo_dataintegration_id" {
description = "The ID of the PostgreSQL Slow Queries & Custom Metrics data integration"
value = groundcover_dataintegration.postgresql_demo.id
}
output "postgresql_system_metrics_dataintegration_id" {
description = "The ID of the PostgreSQL System Metrics data integration"
value = groundcover_dataintegration.postgresql_system_metrics_example.id
}