Skip to content

Commit ffcc024

Browse files
authored
[Feat] v1.23.0 (#223)
* drop metrics: Add `drop_policy` field * Update group_1.txt
1 parent 57429ff commit ffcc024

File tree

11 files changed

+91
-13
lines changed

11 files changed

+91
-13
lines changed

.github/test-groups/group_1.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ TestAccLogzioDropMetric_UpdateDropMetrics
2929
TestAccLogzioDropMetric_UpdateDropMetricsWithName
3030
TestAccLogzioDropMetric_UpdateDropMetricsEnable
3131
TestAccLogzioDropMetric_UpdateDropMetricsDisable
32+
TestAccLogzioDropMetric_CreateDropMetricWithDropPolicy
3233
TestAccDataSourceDropMetric
3334
TestAccDataSourceDropMetricById
3435
TestAccDataSourceDropMetricWithName

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
# Changes by Version
22

33
<!-- next version -->
4-
## v1.21.1
4+
## v1.23.0
5+
- Upgrade `logzio_client_terraform` to `1.27.4`.
6+
- Metrics Drop Filters: Add optional `drop_policy` field with values `DROP_BEFORE_PROCESSING` (default) and `DROP_BEFORE_STORING`.
7+
- Metrics Drop Filters: Remove name length validation - the name field no longer has a 256-character limit.
8+
9+
## v1.22.0
510
- Upgrade `logzio_client_terraform` to `1.27.3`.
611
- Metrics Rollup Rules: Support all aggregation types for `MEASUREMENT`
712

docs/resources/drop_metrics.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ provider "logzio" {
1818
resource "logzio_drop_metrics" "test_filter" {
1919
name = test_filter
2020
account_id = 1234
21+
drop_policy = "DROP_BEFORE_STORING"
2122
filters {
2223
name = "__name__"
2324
value = "my_metric_name"
@@ -34,7 +35,8 @@ resource "logzio_drop_metrics" "test_filter" {
3435
## Argument Reference
3536
* `account_id` - (Required) The Logz.io metrics account ID to which the drop filter applies.
3637
* `active` - (Optional) If true, the drop filter is active and metrics that match the filter are dropped before indexing. If false, the drop filter is disabled. Defaults to true.
37-
* `name` - (Optional) name for the drop metric.
38+
* `name` - (Optional) Name for the drop metric filter.
39+
* `drop_policy` - (Optional) When to drop the metrics. Valid values are `DROP_BEFORE_PROCESSING` (default) and `DROP_BEFORE_STORING`. `DROP_BEFORE_PROCESSING` drops metrics before any processing, while `DROP_BEFORE_STORING` drops metrics after processing but before storage.
3840
* `filter` - (Required) The filter object that defines the drop filter criteria. See below for nested schema.
3941
* `name` - (Required) The name of the metric label to filter on.
4042
* `value` - (Required) The value of the metric label to match against.

examples/drop_metric/main.tf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,11 @@ resource "logzio_drop_metrics" "simple_metric_drop" {
3535

3636
# Complex drop metrics example - drop metrics based on multiple conditions
3737
resource "logzio_drop_metrics" "complex_metric_drop" {
38-
account_id = var.account_id
39-
name = "Drop Staging HTTP Requests with 2xx Status"
40-
active = true
41-
operator = "AND"
38+
account_id = var.account_id
39+
name = "Drop Staging HTTP Requests with 2xx Status"
40+
active = true
41+
drop_policy = "DROP_BEFORE_STORING"
42+
operator = "AND"
4243

4344
filters {
4445
name = "__name__"

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require (
77
github.com/hashicorp/go-cty v1.5.0
88
github.com/hashicorp/terraform-plugin-log v0.9.0
99
github.com/hashicorp/terraform-plugin-sdk/v2 v2.37.0
10-
github.com/logzio/logzio_terraform_client v1.27.3
10+
github.com/logzio/logzio_terraform_client v1.27.4
1111
github.com/stoewer/go-strcase v1.3.1
1212
github.com/stretchr/testify v1.10.0
1313
)

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
126126
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
127127
github.com/logzio/logzio_terraform_client v1.27.3 h1:Sf58iy88N4H4JBMiyl90joWpHUrDcoUCdB/WEnGnZbU=
128128
github.com/logzio/logzio_terraform_client v1.27.3/go.mod h1:pzXrr7gGIi6tU1mk2vTtg8dr6ttKMlt03kz6asC53o4=
129+
github.com/logzio/logzio_terraform_client v1.27.4 h1:IEu7h4XymUXKp8PLNaOJEUDc/TQX1yE60guDbOb+7jo=
130+
github.com/logzio/logzio_terraform_client v1.27.4/go.mod h1:pzXrr7gGIi6tU1mk2vTtg8dr6ttKMlt03kz6asC53o4=
129131
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
130132
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
131133
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=

logzio/datasource_drop_metrics.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ func dataSourceDropMetrics() *schema.Resource {
6969
Optional: true,
7070
Computed: true,
7171
},
72+
dropMetricsDropPolicy: {
73+
Type: schema.TypeString,
74+
Optional: true,
75+
Computed: true,
76+
ValidateFunc: validation.StringInSlice(
77+
[]string{drop_metrics.DropPolicyBeforeProcessing, drop_metrics.DropPolicyBeforeStoring},
78+
false),
79+
},
7280
dropMetricsFilters: {
7381
Type: schema.TypeSet,
7482
Optional: true,

logzio/datasource_drop_metrics_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ func TestAccDataSourceDropMetric(t *testing.T) {
4242
datasourceDropMetricMatchingResource(datasourceFilterName, accountId),
4343
Check: resource.ComposeAggregateTestCheckFunc(
4444
resource.TestCheckResourceAttr(datasourceName, dropMetricsAccountId, accountId),
45+
resource.TestCheckResourceAttr(datasourceName, dropMetricsDropPolicy, "DROP_BEFORE_PROCESSING"),
4546
resource.TestCheckResourceAttr(datasourceName, dropMetricsFilters+".#", "2"),
4647
resource.TestCheckResourceAttr(datasourceName, dropMetricsFilterOperator, "AND"),
4748
resource.TestCheckResourceAttr(datasourceName, dropMetricsActive, "true"),

logzio/resource_drop_metrics.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const (
2020
dropMetricsAccountId = "account_id"
2121
dropMetricsName = "name"
2222
dropMetricsActive = "active"
23+
dropMetricsDropPolicy = "drop_policy"
2324
dropMetricsFilters = "filters"
2425
dropMetricsFilterOperator = "operator"
2526
dropMetricsExpressionLabelName = "name"
@@ -82,15 +83,22 @@ func resourceDropMetrics() *schema.Resource {
8283
Required: true,
8384
},
8485
dropMetricsName: {
85-
Type: schema.TypeString,
86-
Optional: true,
87-
ValidateFunc: validation.StringLenBetween(0, 256),
86+
Type: schema.TypeString,
87+
Optional: true,
8888
},
8989
dropMetricsActive: {
9090
Type: schema.TypeBool,
9191
Optional: true,
9292
Default: true,
9393
},
94+
dropMetricsDropPolicy: {
95+
Type: schema.TypeString,
96+
Optional: true,
97+
Default: drop_metrics.DropPolicyBeforeProcessing,
98+
ValidateFunc: validation.StringInSlice(
99+
[]string{drop_metrics.DropPolicyBeforeProcessing, drop_metrics.DropPolicyBeforeStoring},
100+
false),
101+
},
94102
dropMetricsFilters: {
95103
Type: schema.TypeSet,
96104
Required: true,
@@ -208,9 +216,10 @@ func createCreateUpdateDropMetricsFromSchema(d *schema.ResourceData) drop_metric
208216
activePtr := &activeVal
209217

210218
return drop_metrics.CreateUpdateDropMetric{
211-
AccountId: int64Attr(d, dropMetricsAccountId),
212-
Name: d.Get(dropMetricsName).(string),
213-
Active: activePtr,
219+
AccountId: int64Attr(d, dropMetricsAccountId),
220+
Name: d.Get(dropMetricsName).(string),
221+
Active: activePtr,
222+
DropPolicy: d.Get(dropMetricsDropPolicy).(string),
214223
Filter: drop_metrics.FilterObject{
215224
Operator: d.Get(dropMetricsFilterOperator).(string),
216225
Expression: schemaToDropMetricsFilterExpression(d),
@@ -224,6 +233,7 @@ func setDropMetrics(d *schema.ResourceData, dropMetric *drop_metrics.DropMetric)
224233
d.Set(dropMetricsAccountId, int(dropMetric.AccountId))
225234
d.Set(dropMetricsName, dropMetric.Name)
226235
d.Set(dropMetricsActive, dropMetric.Active)
236+
d.Set(dropMetricsDropPolicy, dropMetric.DropPolicy)
227237
d.Set(dropMetricsCreatedAt, dropMetric.CreatedAt)
228238
d.Set(dropMetricsCreatedBy, dropMetric.CreatedBy)
229239
d.Set(dropMetricsModifiedAt, dropMetric.ModifiedAt)

logzio/resource_drop_metrics_test.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const (
1515
dropMetricResourceCreateSimple = "create_drop_metrics_simple"
1616
dropMetricResourceCreateComplex = "create_drop_metrics_complex"
1717
dropMetricResourceCreateWithName = "create_drop_metrics_with_name"
18+
dropMetricResourceCreateWithDropPolicy = "create_drop_metrics_with_drop_policy"
1819
dropMetricResourceCreateNoLabelName = "create_drop_metrics_missing_label_name"
1920
dropMetricResourceCreateNoValue = "create_drop_metrics_missing_value"
2021
dropMetricResourceCreateEmptyCondition = "create_drop_metrics_empty_condition"
@@ -43,6 +44,7 @@ func TestAccLogzioDropMetric_CreateDropMetricSimple(t *testing.T) {
4344
Check: resource.ComposeTestCheckFunc(
4445
resource.TestCheckResourceAttr(resourceName, dropMetricsAccountId, accountId),
4546
resource.TestCheckResourceAttr(resourceName, dropMetricsName, ""),
47+
resource.TestCheckResourceAttr(resourceName, dropMetricsDropPolicy, "DROP_BEFORE_PROCESSING"),
4648
resource.TestCheckResourceAttr(resourceName, dropMetricsFilters+".#", "1"),
4749
resource.TestCheckResourceAttr(resourceName, dropMetricsFilterOperator, "AND"),
4850
resource.TestCheckResourceAttr(resourceName, dropMetricsActive, "true"),
@@ -372,6 +374,41 @@ func TestAccLogzioDropMetric_UpdateDropMetricsWithName(t *testing.T) {
372374
})
373375
}
374376

377+
func TestAccLogzioDropMetric_CreateDropMetricWithDropPolicy(t *testing.T) {
378+
filterName := "test_create_drop_metrics_with_drop_policy"
379+
resourceName := "logzio_drop_metrics." + filterName
380+
accountId := os.Getenv(envLogzioMetricsAccountId)
381+
382+
defer utils.SleepAfterTest()
383+
384+
resource.Test(t, resource.TestCase{
385+
PreCheck: func() {
386+
testAccPreCheckApiToken(t)
387+
testAccPreCheckMetricsAccountId(t)
388+
},
389+
ProviderFactories: testAccProviderFactories,
390+
Steps: []resource.TestStep{
391+
{
392+
Config: resourceTestDropMetrics(filterName, dropMetricResourceCreateWithDropPolicy, accountId),
393+
Check: resource.ComposeTestCheckFunc(
394+
resource.TestCheckResourceAttr(resourceName, dropMetricsAccountId, accountId),
395+
resource.TestCheckResourceAttr(resourceName, dropMetricsName, "test-drop-metrics-with-policy"),
396+
resource.TestCheckResourceAttr(resourceName, dropMetricsDropPolicy, "DROP_BEFORE_STORING"),
397+
resource.TestCheckResourceAttr(resourceName, dropMetricsFilters+".#", "1"),
398+
resource.TestCheckResourceAttr(resourceName, dropMetricsFilterOperator, "AND"),
399+
resource.TestCheckResourceAttr(resourceName, dropMetricsActive, "true"),
400+
),
401+
},
402+
{
403+
Config: resourceTestDropMetrics(filterName, dropMetricResourceCreateWithDropPolicy, accountId),
404+
ResourceName: resourceName,
405+
ImportState: true,
406+
ImportStateVerify: true,
407+
},
408+
},
409+
})
410+
}
411+
375412
func resourceTestDropMetrics(name, path, accountId string) string {
376413
content, err := os.ReadFile(fmt.Sprintf("testdata/fixtures/%s.tf", path))
377414
if err != nil {

0 commit comments

Comments
 (0)