feat(observability): add logs and traces retentions days (#1032)
* feat(observability): add logs and traces retentions days * feat(observability): add inputs to acceptance test * feat(observability): add inputs to example * feat(observability): fix docs * feat(observability): fix ModifyPlan checks after review * feat(observability): fix acceptance test max values * feat(observability): fix lint issues * feat(observability): apply suggestion
This commit is contained in:
parent
e4e2e55e94
commit
10eced46c7
8 changed files with 366 additions and 5 deletions
|
|
@ -132,6 +132,14 @@ func (d *instanceDataSource) Schema(_ context.Context, _ datasource.SchemaReques
|
|||
Computed: true,
|
||||
Sensitive: true,
|
||||
},
|
||||
"traces_retention_days": schema.Int64Attribute{
|
||||
Description: "Specifies for how many days the traces are kept. Default is set to `7`.",
|
||||
Computed: true,
|
||||
},
|
||||
"logs_retention_days": schema.Int64Attribute{
|
||||
Description: "Specifies for how many days the logs are kept. Default is set to `7`.",
|
||||
Computed: true,
|
||||
},
|
||||
"metrics_retention_days": schema.Int64Attribute{
|
||||
Description: "Specifies for how many days the raw metrics are kept. Default is set to `90`.",
|
||||
Computed: true,
|
||||
|
|
@ -454,6 +462,44 @@ func (d *instanceDataSource) Read(ctx context.Context, req datasource.ReadReques
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
// Handle Logs Retentions
|
||||
logsRetentionResp, err := d.client.GetLogsConfigs(ctx, instanceId, projectId).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading instance", fmt.Sprintf("Calling API to get logs retention: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
err = mapLogsRetentionField(logsRetentionResp, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading instance", fmt.Sprintf("Processing API response for the logs retention: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
diags = setLogsRetentions(ctx, &resp.State, &model)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
// Handle Traces Retentions
|
||||
tracesRetentionResp, err := d.client.GetTracesConfigs(ctx, instanceId, projectId).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading instance", fmt.Sprintf("Calling API to get traces retention: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
err = mapTracesRetentionField(tracesRetentionResp, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading instance", fmt.Sprintf("Processing API response for the traces retention: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
diags = setTracesRetentions(ctx, &resp.State, &model)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// There are plans where no alert matchers and receivers are present e.g. like Observability-Metrics-Endpoint-100k-EU01
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue