Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions docs/data-sources/observability_instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ data "stackit_observability_instance" "example" {
- `alert_config` (Attributes) Alert configuration for the instance. (see [below for nested schema](#nestedatt--alert_config))
- `alerting_url` (String) Specifies Alerting URL.
- `dashboard_url` (String) Specifies Observability instance dashboard URL.
- `grafana_initial_admin_password` (String, Sensitive) Specifies an initial Grafana admin password.
- `grafana_initial_admin_user` (String) Specifies an initial Grafana admin username.
- `grafana_admin_enabled` (Boolean) If true, a default Grafana server admin user was created.
- `grafana_public_read_access` (Boolean) If true, anyone can access Grafana dashboards without logging in.
- `grafana_url` (String) Specifies Grafana URL.
- `id` (String) Terraform's internal data source. ID. It is structured as "`project_id`,`instance_id`".
Expand Down
3 changes: 1 addition & 2 deletions docs/resources/observability_instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {

- `acl` (Set of String) The access control list for this instance. Each entry is an IP address range that is permitted to access, in CIDR notation.
- `alert_config` (Attributes) Alert configuration for the instance. (see [below for nested schema](#nestedatt--alert_config))
- `grafana_admin_enabled` (Boolean) If true, a default Grafana server admin user is created. It's recommended to set this to false and use STACKIT SSO (Owner or Observability Grafana Server Admin role) instead. It is still possible to manually create a new Grafana admin user via the Grafana UI later.
- `logs_retention_days` (Number) Specifies for how many days the logs are kept. Default is set to `7`.
- `metrics_retention_days` (Number) Specifies for how many days the raw metrics are kept. Default is set to `90`.
- `metrics_retention_days_1h_downsampling` (Number) Specifies for how many days the 1h downsampled metrics are kept. must be less than the value of the 5m downsampling retention. Default is set to `90`.
Expand All @@ -56,8 +57,6 @@ import {

- `alerting_url` (String) Specifies Alerting URL.
- `dashboard_url` (String) Specifies Observability instance dashboard URL.
- `grafana_initial_admin_password` (String, Sensitive) Specifies an initial Grafana admin password.
- `grafana_initial_admin_user` (String) Specifies an initial Grafana admin username.
- `grafana_public_read_access` (Boolean) If true, anyone can access Grafana dashboards without logging in.
- `grafana_url` (String) Specifies Grafana URL.
- `id` (String) Terraform's internal resource ID. It is structured as "`project_id`,`instance_id`".
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ require (
github.com/stackitcloud/stackit-sdk-go/services/modelserving v0.6.3
github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.5.5
github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.4.2
github.com/stackitcloud/stackit-sdk-go/services/observability v0.15.1
github.com/stackitcloud/stackit-sdk-go/services/observability v0.16.1
github.com/stackitcloud/stackit-sdk-go/services/opensearch v0.24.4
github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.3.2
github.com/stackitcloud/stackit-sdk-go/services/rabbitmq v0.25.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.5.5 h1:tPISli81nu
github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.5.5/go.mod h1:G/UD3tzPzzu79MiFWUYqogxdLMB+YArNHR6Yqz7Cqr0=
github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.4.2 h1:nsC6oA1whA4ibxEuD+0Osngmnpz8dLdV6bv+9jYP4Eo=
github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.4.2/go.mod h1:WA6QlAAQ8aaw81W0VSVoDrxOfchGkdtmn2jQL/ub/50=
github.com/stackitcloud/stackit-sdk-go/services/observability v0.15.1 h1:zk+47GhutK2ajO4Yiek0laGm2PdXvY8BvFZc8yHFnSE=
github.com/stackitcloud/stackit-sdk-go/services/observability v0.15.1/go.mod h1:vapb/sJqbHlf+c7pZWdE9GqrbyI8wesGvUc9o7oJ1Xk=
github.com/stackitcloud/stackit-sdk-go/services/observability v0.16.1 h1:FKeW3uiMXRl6Oau3xE6yBriXh4t7CwPb8QH6PR0uQXM=
github.com/stackitcloud/stackit-sdk-go/services/observability v0.16.1/go.mod h1:RiknJnL3OuU9wb2lyb80Hu+EnlyDQMG8vejDV7B9a5U=
github.com/stackitcloud/stackit-sdk-go/services/opensearch v0.24.4 h1:ppmezCAc8XBW6sdS5lvV6Edx0FOPwC/fosvH3FEIdps=
github.com/stackitcloud/stackit-sdk-go/services/opensearch v0.24.4/go.mod h1:c509eL4M/Qdg4FGT6qTh7r4E07FtB2Ui3sbbLERUBqk=
github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.3.2 h1:uQIpj0phDRGrV78/vhtULwxaO2cBdHwqZcFKYUrH1Hs=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,10 @@ func (d *instanceDataSource) Schema(_ context.Context, _ datasource.SchemaReques
Description: "Specifies Grafana URL.",
Computed: true,
},
"grafana_initial_admin_user": schema.StringAttribute{
Description: "Specifies an initial Grafana admin username.",
"grafana_admin_enabled": schema.BoolAttribute{
Description: "If true, a default Grafana server admin user was created.",
Computed: true,
},
"grafana_initial_admin_password": schema.StringAttribute{
Description: "Specifies an initial Grafana admin password.",
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,
Expand Down
30 changes: 10 additions & 20 deletions stackit/internal/services/observability/instance/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ type Model struct {
IsUpdatable types.Bool `tfsdk:"is_updatable"`
GrafanaURL types.String `tfsdk:"grafana_url"`
GrafanaPublicReadAccess types.Bool `tfsdk:"grafana_public_read_access"`
GrafanaInitialAdminPassword types.String `tfsdk:"grafana_initial_admin_password"`
GrafanaInitialAdminUser types.String `tfsdk:"grafana_initial_admin_user"`
GrafanaAdminEnabled types.Bool `tfsdk:"grafana_admin_enabled"`
MetricsRetentionDays types.Int64 `tfsdk:"metrics_retention_days"`
MetricsRetentionDays5mDownsampling types.Int64 `tfsdk:"metrics_retention_days_5m_downsampling"`
MetricsRetentionDays1hDownsampling types.Int64 `tfsdk:"metrics_retention_days_1h_downsampling"`
Expand Down Expand Up @@ -500,20 +499,11 @@ func (r *instanceResource) Schema(_ context.Context, _ resource.SchemaRequest, r
stringplanmodifier.UseStateForUnknown(),
},
},
"grafana_initial_admin_user": schema.StringAttribute{
Description: "Specifies an initial Grafana admin username.",
Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
},
"grafana_initial_admin_password": schema.StringAttribute{
Description: "Specifies an initial Grafana admin password.",
"grafana_admin_enabled": schema.BoolAttribute{
Description: "If true, a default Grafana server admin user is created. It's recommended to set this to false and use STACKIT SSO (Owner or Observability Grafana Server Admin role) instead. It is still possible to manually create a new Grafana admin user via the Grafana UI later.",
Optional: true,
Computed: true,
Sensitive: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
Default: booldefault.StaticBool(true),
},
"traces_retention_days": schema.Int64Attribute{
Description: "Specifies for how many days the traces are kept. Default is set to `7`.",
Expand Down Expand Up @@ -1558,8 +1548,6 @@ func mapFields(ctx context.Context, r *observability.GetInstanceResponse, model
i := *r.Instance
model.GrafanaURL = types.StringPointerValue(i.GrafanaUrl)
model.GrafanaPublicReadAccess = types.BoolPointerValue(i.GrafanaPublicReadAccess)
model.GrafanaInitialAdminPassword = types.StringPointerValue(i.GrafanaAdminPassword)
model.GrafanaInitialAdminUser = types.StringPointerValue(i.GrafanaAdminUser)
model.MetricsURL = types.StringPointerValue(i.MetricsUrl)
model.MetricsPushURL = types.StringPointerValue(i.PushMetricsUrl)
model.TargetsURL = types.StringPointerValue(i.TargetsUrl)
Expand All @@ -1570,6 +1558,7 @@ func mapFields(ctx context.Context, r *observability.GetInstanceResponse, model
model.JaegerUIURL = types.StringPointerValue(i.JaegerUiUrl)
model.OtlpTracesURL = types.StringPointerValue(i.OtlpTracesUrl)
model.ZipkinSpansURL = types.StringPointerValue(i.ZipkinSpansUrl)
model.GrafanaAdminEnabled = types.BoolPointerValue(i.GrafanaAdminEnabled)
}

return nil
Expand Down Expand Up @@ -2128,9 +2117,10 @@ func toCreatePayload(model *Model) (*observability.CreateInstancePayload, error)
pa[k] = elements[k].String()
}
return &observability.CreateInstancePayload{
Name: conversion.StringValueToPointer(model.Name),
PlanId: conversion.StringValueToPointer(model.PlanId),
Parameter: &pa,
GrafanaAdminEnabled: conversion.BoolValueToPointer(model.GrafanaAdminEnabled),
Name: conversion.StringValueToPointer(model.Name),
PlanId: conversion.StringValueToPointer(model.PlanId),
Parameter: &pa,
}, nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,9 @@ func toCreatePayload(ctx context.Context, model *Model) (*observability.CreateLo
}

// toRulesPayload generates rules for create payload.
func toRulesPayload(ctx context.Context, model *Model) ([]observability.UpdateAlertgroupsRequestInnerRulesInner, error) {
func toRulesPayload(ctx context.Context, model *Model) ([]observability.CreateLogsAlertgroupsPayloadRulesInner, error) {
if model.Rules.Elements() == nil || len(model.Rules.Elements()) == 0 {
return []observability.UpdateAlertgroupsRequestInnerRulesInner{}, nil
return []observability.CreateLogsAlertgroupsPayloadRulesInner{}, nil
}

var rules []rule
Expand All @@ -423,10 +423,10 @@ func toRulesPayload(ctx context.Context, model *Model) ([]observability.UpdateAl
return nil, core.DiagsToError(diags)
}

var oarrs []observability.UpdateAlertgroupsRequestInnerRulesInner
var oarrs []observability.CreateLogsAlertgroupsPayloadRulesInner
for i := range rules {
rule := &rules[i]
oarr := observability.UpdateAlertgroupsRequestInnerRulesInner{}
oarr := observability.CreateLogsAlertgroupsPayloadRulesInner{}

if !utils.IsUndefined(rule.Alert) {
alert := conversion.StringValueToPointer(rule.Alert)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func TestToCreatePayload(t *testing.T) {
expect: &observability.CreateLogsAlertgroupsPayload{
Name: utils.Ptr("full-alertgroup"),
Interval: utils.Ptr("10m"),
Rules: &[]observability.UpdateAlertgroupsRequestInnerRulesInner{
Rules: &[]observability.CreateLogsAlertgroupsPayloadRulesInner{
{
Alert: utils.Ptr("alert"),
Annotations: &map[string]interface{}{
Expand Down Expand Up @@ -118,15 +118,15 @@ func TestToRulesPayload(t *testing.T) {
tests := []struct {
name string
input *Model
expect []observability.UpdateAlertgroupsRequestInnerRulesInner
expect []observability.CreateLogsAlertgroupsPayloadRulesInner
expectErr bool
}{
{
name: "Nil Rules",
input: &Model{
Rules: types.ListNull(types.StringType), // Simulates a lack of rules
},
expect: []observability.UpdateAlertgroupsRequestInnerRulesInner{},
expect: []observability.CreateLogsAlertgroupsPayloadRulesInner{},
expectErr: false,
},
{
Expand Down Expand Up @@ -156,7 +156,7 @@ func TestToRulesPayload(t *testing.T) {
}),
}),
},
expect: []observability.UpdateAlertgroupsRequestInnerRulesInner{
expect: []observability.CreateLogsAlertgroupsPayloadRulesInner{
{
Alert: utils.Ptr("alert"),
Expr: utils.Ptr("expr"),
Expand Down Expand Up @@ -195,7 +195,7 @@ func TestToRulesPayload(t *testing.T) {
}),
}),
},
expect: []observability.UpdateAlertgroupsRequestInnerRulesInner{
expect: []observability.CreateLogsAlertgroupsPayloadRulesInner{
{
Alert: utils.Ptr("alert1"),
Expr: utils.Ptr("expr1"),
Expand Down
Loading
Loading