diff --git a/coralogix/resource_coralogix_alert.go b/coralogix/resource_coralogix_alert.go index 2b6bc046..c19a2962 100644 --- a/coralogix/resource_coralogix_alert.go +++ b/coralogix/resource_coralogix_alert.go @@ -1189,7 +1189,7 @@ func (r *AlertResource) Schema(_ context.Context, _ resource.SchemaRequest, resp Optional: true, Computed: true, PlanModifiers: []planmodifier.List{ - ComputedForMetricAlerts{}, + ComputedForSomeAlerts{}, }, Validators: []validator.List{ //imidiate, new value, tracing-immidiate, @@ -1293,10 +1293,6 @@ func (r *AlertResource) Schema(_ context.Context, _ resource.SchemaRequest, resp } } -func timeZoneSchema() { - panic("todo") -} - type GroupByValidator struct { } @@ -1328,18 +1324,18 @@ func (g GroupByValidator) ValidateList(ctx context.Context, request validator.Li } } -type ComputedForMetricAlerts struct { +type ComputedForSomeAlerts struct { } -func (c ComputedForMetricAlerts) Description(ctx context.Context) string { +func (c ComputedForSomeAlerts) Description(ctx context.Context) string { return "Computed for metric alerts." } -func (c ComputedForMetricAlerts) MarkdownDescription(ctx context.Context) string { +func (c ComputedForSomeAlerts) MarkdownDescription(ctx context.Context) string { return "Computed for metric alerts." } -func (c ComputedForMetricAlerts) PlanModifyList(ctx context.Context, request planmodifier.ListRequest, response *planmodifier.ListResponse) { +func (c ComputedForSomeAlerts) PlanModifyList(ctx context.Context, request planmodifier.ListRequest, response *planmodifier.ListResponse) { paths, diags := request.Plan.PathMatches(ctx, path.MatchRoot("type_definition")) if diags.HasError() { response.Diagnostics.Append(diags...) @@ -1352,14 +1348,18 @@ func (c ComputedForMetricAlerts) PlanModifyList(ctx context.Context, request pla return } + // special case for metric alerts var typeDefinitionStr string if !objIsNullOrUnknown(typeDefinition.MetricThreshold) { typeDefinitionStr = "metric_threshold" } else if !objIsNullOrUnknown(typeDefinition.MetricAnomaly) { typeDefinitionStr = "metric_anomaly" + } else if !objIsNullOrUnknown(typeDefinition.LogsNewValue) { + typeDefinitionStr = "logs_new_value" } - if typeDefinitionStr != "" { + switch typeDefinitionStr { + case "metric_threshold", "metric_anomaly": paths, diags = request.Plan.PathMatches(ctx, path.MatchRoot("type_definition").AtName(typeDefinitionStr).AtName("metric_filter").AtName("promql")) if diags.HasError() { response.Diagnostics.Append(diags...) @@ -1388,8 +1388,36 @@ func (c ComputedForMetricAlerts) PlanModifyList(ctx context.Context, request pla } return } - } + case "logs_new_value": // keypath_to_track values end up in the group_by attribute + paths, diags = request.Plan.PathMatches(ctx, path.MatchRoot("type_definition").AtName(typeDefinitionStr).AtName("rules")) + if diags.HasError() { + response.Diagnostics.Append(diags...) + return + } + + var rulesPlan types.Set + diags = request.Plan.GetAttribute(ctx, paths[0], &rulesPlan) + if diags.HasError() { + response.Diagnostics.Append(diags...) + return + } + + var rulesState types.Set + diags = request.State.GetAttribute(ctx, paths[0], &rulesState) + if diags.HasError() { + response.Diagnostics.Append(diags...) + return + } + if request.ConfigValue.IsUnknown() || request.ConfigValue.IsNull() { + if !rulesState.Equal(rulesPlan) { + response.PlanValue = types.ListUnknown(types.StringType) + } else { + response.PlanValue = request.StateValue + } + return + } + } response.PlanValue = request.ConfigValue } @@ -1778,19 +1806,6 @@ func extractNotificationGroup(ctx context.Context, notificationGroupObject types return notificationGroup, nil } -func expandNotificationTargetSettings(ctx context.Context, notificationGroupModel NotificationGroupModel, notificationGroup *cxsdk.AlertDefNotificationGroup) (*cxsdk.AlertDefNotificationGroup, diag.Diagnostics) { - notificationGroup.Webhooks = []*cxsdk.AlertDefWebhooksSettings{} - if webhooksSettings := notificationGroupModel.WebhooksSettings; !(webhooksSettings.IsNull() || webhooksSettings.IsUnknown()) { - notifications, diags := extractWebhooksSettings(ctx, webhooksSettings) - if diags.HasError() { - return nil, diags - } - notificationGroup.Webhooks = notifications - } - - return notificationGroup, nil -} - func extractWebhooksSettings(ctx context.Context, webhooksSettings types.Set) ([]*cxsdk.AlertDefWebhooksSettings, diag.Diagnostics) { if webhooksSettings.IsNull() || webhooksSettings.IsUnknown() { return nil, nil @@ -3342,14 +3357,14 @@ func extractAlertDef(ctx context.Context, def types.Object) (*cxsdk.FlowStagesGr func (r *AlertResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { var state *AlertResourceModel diags := req.State.Get(ctx, &state) + //Get refreshed Alert value from Coralogix + id := state.ID.ValueString() + log.Printf("[INFO] Reading Alert: %s", id) resp.Diagnostics.Append(diags...) if resp.Diagnostics.HasError() { return } - //Get refreshed Alert value from Coralogix - id := state.ID.ValueString() - log.Printf("[INFO] Reading Alert: %s", id) getAlertReq := &cxsdk.GetAlertDefRequest{Id: wrapperspb.String(id)} getAlertResp, err := r.client.Get(ctx, getAlertReq) if err != nil { @@ -4905,13 +4920,6 @@ func alertScheduleActiveOnAttr() map[string]attr.Type { } } -func timeOfDayAttr() map[string]attr.Type { - return map[string]attr.Type{ - "hours": types.Int64Type, - "minutes": types.Int64Type, - } -} - func logsTimeRelativeAttr() map[string]attr.Type { return map[string]attr.Type{ "logs_filter": types.ObjectType{AttrTypes: logsFilterAttr()}, diff --git a/docs/data-sources/alert.md b/docs/data-sources/alert.md index 2a7c2fec..de8a321e 100644 --- a/docs/data-sources/alert.md +++ b/docs/data-sources/alert.md @@ -24,7 +24,7 @@ Coralogix Alert. For more info please review - https://coralogix.com/docs/gettin - `deleted` (Boolean) - `description` (String) Alert description. - `enabled` (Boolean) Alert enabled status. True by default. -- `group_by` (Set of String) Group by fields. +- `group_by` (List of String) Group by fields. - `incidents_settings` (Attributes) (see [below for nested schema](#nestedatt--incidents_settings)) - `labels` (Map of String) - `name` (String) Alert name. @@ -56,7 +56,7 @@ Read-Only: Read-Only: -- `group_by_keys` (Set of String) +- `group_by_keys` (List of String) - `webhooks_settings` (Attributes Set) (see [below for nested schema](#nestedatt--notification_group--webhooks_settings)) diff --git a/docs/guides/alerts-migration-guide.md b/docs/guides/alerts-migration-guide.md new file mode 100644 index 00000000..8817ce38 --- /dev/null +++ b/docs/guides/alerts-migration-guide.md @@ -0,0 +1,141 @@ +--- +page_title: "Migration Guide for Alerts (from pre 2.0)" +--- + +# Guide to Using the Terraform Migration Script + +!> Before following this guide, please reach out to your customer support representative for more information. + +This guide provides step-by-step instructions on how to use the Terraform migration scripts effectively. + +--- + +## Prerequisites +0. **Get the scripts**: + - Download from [https://github.com/coralogix/coralogix-management-sdk/tree/master/tools/terraform-importer]() +1. **Terraform Installed**: + - Ensure you have Terraform installed. You can download it [here](https://www.terraform.io/downloads). +2. **Go Installed**: + - Install Go from [golang.org](https://golang.org/dl/). +3. **Python Installed**: + - The script uses Python 3 for JSON processing, so make sure you have Python 3 installed. +4. **`hcl2json` Installed**: + - Install the `hcl2json` utility. You can find it [here](https://github.com/tmccombs/hcl2json). + +--- + +## Usage + +### 1. Script Purpose +The script allows you to: +- Migrate Terraform configurations based on: + - A folder containing a `terraform.tfstate` file. + - A specific resource type (e.g., `alert`, `dashboard`). +- Generate a migration folder with cleaned and updated configurations. +- Specify the provider version interactively during the process. + +--- + +### 2. Running the Script +Before running the script, ensure you defined the required environment variables - +`CORALOGIX_API_KEY` and `CORALOGIX_ENV` or `CORALOGIX_DOMAIN`. + +Use the script as follows: +```bash +./generate_and_migrate.sh +``` + +--- + +### 3. Interactive Steps + +#### Step 1: Select Migration Type +You will be prompted to choose the migration type: +- **Option 1**: Migrate based on a folder containing a `terraform.tfstate` file. + - Provide the path to the folder. + - The script ensures that the folder contains a valid `terraform.tfstate` file. +- **Option 2**: Migrate based on a specific resource type. + - A list of resource types will be displayed. Choose from options like: + - `alert`, `dashboard`, `archive_logs`, `events2metrics`, etc. + - Select the desired resource type from the list. + +#### Step 2: Specify Provider Version +After selecting the migration type, you will be prompted to specify the Terraform provider version: +- Example: `~>1.19.0`. +- The script will default to `>=2.0.0` if no input is provided. + +--- + +### 4. What Happens Next + +#### Step 3: Generate Migration Folder +- The script creates a new migration folder based on your input: + - For a folder, it appends `_migration` to the folder name. + - For a resource type, it creates a folder like `./_migration`. + +#### Step 4: Run `generate_imports.go` +- The script runs a Go program (`generate_imports.go`) to generate an `imports.tf` file inside the migration folder. + +#### Step 5: Generate `provider.tf` +- A `provider.tf` file is generated in the migration folder with the specified provider version. + +#### Step 6: Run `terraform init` +- The script initializes Terraform inside the migration folder using `terraform init`. + +#### Step 7: Run `terraform plan` +- The script runs `terraform plan` with the `-generate-config-out` flag to generate a new configuration file (`generated.tf`). + +#### Step 8: Remove Null Values +- Python is used to clean the JSON file by removing null values, generating a cleaned JSON file (`cleaned_config.json`). + +#### Step 9: Apply the Configuration +- The script applies the cleaned configuration using `terraform apply`. +**Note**: The script will prompt you to confirm the apply action and will override your existing resources with the new configuration. +If you choose not to apply, the script will exit. + +#### Step 10: Cleanup +- Temporary files are deleted. + +--- + +### 5. Example Outputs + +#### Migration Type Selection +```plaintext +[INFO] Select the migration type: +[INFO] 1) Migrate based on a folder containing terraform.tfstate +[INFO] 2) Migrate based on a specific resource name +Enter your choice (1 or 2): 2 +``` + +#### Provider Version Prompt +```plaintext +Enter the Terraform provider version to migrate to (e.g., ~>1.19.0): >=2.0.0 +``` + +#### Logs During Execution +```plaintext +2024-12-01 15:45:22 [INFO] Creating migration folder: ./alert_migration +2024-12-01 15:45:22 [INFO] Running generate_imports.go with -type... +2024-12-01 15:45:22 [INFO] Successfully generated imports.tf at ./alert_migration. +2024-12-01 15:45:22 [INFO] Generating provider configuration in ./alert_migration/provider.tf... +2024-12-01 15:45:22 [INFO] Provider configuration generated in ./alert_migration/provider.tf. +2024-12-01 15:45:22 [INFO] Initializing Terraform in ./alert_migration... +2024-12-01 15:45:22 [INFO] Running terraform plan in ./alert_migration... +... +2024-12-01 15:45:22 [INFO] Terraform apply completed. +2024-12-01 15:45:22 [INFO] Cleanup completed. +2024-12-01 15:45:22 [INFO] Script completed successfully. +``` + +--- + +### 6. Notes +- **Customization**: + - Update the resource types in the script if new ones are added. + - Adjust the default provider version if needed. +- **Error Handling**: + - The script will exit if any step fails (`set -e`). + - Logs are color-coded for better visibility (`INFO`, `ERROR`, `WARNING`, etc.). + +--- \ No newline at end of file diff --git a/docs/guides/api-keys.md b/docs/guides/api-keys.md new file mode 100644 index 00000000..2c53effb --- /dev/null +++ b/docs/guides/api-keys.md @@ -0,0 +1,270 @@ +--- +page_title: "Migration Guide for API Keys (from pre 1.16)" +--- + +# Upgrading API Keys (from < 1.16) + +With version 1.16, the API Keys resource has been upgraded to the latest available version of the GRPC API which replaces "roles" with "presets" and "permissions". Read more [https://coralogix.com/docs/api-keys/](). This document is the guide on how you can update your existing Terraform files. + +## Legacy And New API Keys + +The change in the underlying permission model created two types of API keys with the old one being described as "legacy keys". Internally all keys have been transitioned to the new model, however there are two key differences: + +1. Legacy keys are "Custom" keys that have a custom set of permissions, instead of a preset +2. Legacy key permissions cannot be updated + +Therefore legacy keys can remain in use as long as no changes to the associated permissions are required. + +### Mapping Roles to Permissions + +Internally, existing roles are mapped to the following set of custom permissions: + + +| Role | Permissions | +|------------------------|------------------------------------------------------------------------------------------------------------| +| RUM Ingress | - rum-ingress:SendData | +| Send Data | - cloud-metadata-ingress:SendData
- logs.data-ingress:SendData
- metrics.data-ingress:SendData
- spans.data-ingress:SendData | +| Coralogix CLI | - data-usage:Read
- org-quota:Manage
- org-quota:Read
- org-teams:Manage
- org-teams:ReadConfig
- team-members:Manage
- team-members:ReadConfig
- team-scim:Manage
- team-scim:ReadConfig
- team-sso:Manage
- team-sso:ReadConfig
- team-quota:Manage
- team-quota:Read | +| SCIM | - team-groups:Manage
- team-groups:ReadConfig
- team-members:Manage
- team-members:ReadConfig
- team-roles:ReadConfig | +| Role Management | - team-roles:Manage
- team-roles:ReadConfig | +| Trigger Webhook | - contextual-data:SendData | +| Legacy Api Key | - alerts:ReadConfig
- alerts:UpdateConfig
- cloud-metadata-enrichment:ReadConfig
- cloud-metadata-enrichment:UpdateConfig
- data-usage:Read
- geo-enrichment:ReadConfig
- geo-enrichment:UpdateConfig
- grafana:Read
- grafana:Update
- logs.data-setup#low:ReadConfig
- logs.data-setup#low:UpdateConfig
- logs.events2metrics:ReadConfig
- logs.events2metrics:UpdateConfig
- logs.tco:ReadPolicies
- logs.tco:UpdatePolicies
- metrics.data-analytics#high:Read
- metrics.data-analytics#low:Read
- metrics.data-setup#high:ReadConfig
- metrics.data-setup#high:UpdateConfig
- metrics.data-setup#low:ReadConfig
- metrics.data-setup#low:UpdateConfig
- metrics.recording-rules:ReadConfig
- metrics.recording-rules:UpdateConfig
- metrics.tco:ReadPolicies
- metrics.tco:UpdatePolicies
- outbound-webhooks:ReadConfig
- outbound-webhooks:UpdateConfig
- parsing-rules:ReadConfig
- parsing-rules:UpdateConfig
- security-enrichment:ReadConfig
- security-enrichment:UpdateConfig
- serverless:Read
- service-catalog:ReadDimensionsConfig
- service-catalog:ReadSLIConfig
- service-catalog:UpdateDimensionsConfig
- service-catalog:UpdateSLIConfig
- service-map:Read
- source-mapping:UploadMapping
- spans.data-api#high:ReadData
- spans.data-api#low:ReadData
- spans.data-setup#low:ReadConfig
- spans.data-setup#low:UpdateConfig
- spans.events2metrics:ReadConfig
- spans.events2metrics:UpdateConfig
- spans.tco:ReadPolicies
- spans.tco:UpdatePolicies
- team-actions:ReadConfig
- team-actions:UpdateConfig
- team-api-keys-security-settings:Manage
- team-api-keys-security-settings:ReadConfig
- team-api-keys:Manage
- team-api-keys:ReadConfig
- team-custom-enrichment:ReadConfig
- team-custom-enrichment:ReadData
- team-custom-enrichment:UpdateConfig
- team-custom-enrichment:UpdateData
- team-dashboards:Read
- team-dashboards:Update
- user-actions:ReadConfig
- user-actions:UpdateConfig
- user-dashboards:Read
- user-dashboards:Update
- version-benchmark-tags:Read
- logs.alerts:ReadConfig
- logs.alerts:UpdateConfig
- spans.alerts:ReadConfig
- spans.alerts:UpdateConfig
- metrics.alerts:ReadConfig
- metrics.alerts:UpdateConfig
- livetail:Read
- service-catalog:Read
- version-benchmark-tags:Update
- service-catalog:ReadApdexConfig
- service-catalog:UpdateApdexConfig
- service-catalog:Update
- team-quota:Manage
- team-quota:Read | +| Query Data Legacy | - logs.data-api#high:ReadData
- logs.data-api#low:ReadData
- metrics.data-api#high:ReadData
- metrics.data-api#low:ReadData
- opensearch-dashboards:Read
- opensearch-dashboards:Update
- snowbit.cspm:Read
- snowbit.sspm:Read
- spans.data-api#high:ReadData
- spans.data-api#low:ReadData
- livetail:Read | + +If an API key had multiple roles, the permissions are merged. + +## Upgrade Procedure + +The new provider version upgrades the state automatically, however the `.tf` files need to reflect those updates as well - anything else would be considered a change by terraform. Here is a step by step upgrade guide: + +0. Upgrade the provider +1. Run `terraform refresh` +2. Locate the `coralogix_api_key` resources and create a property `permissions` corresponding to the roles in `roles`. Use the table above or examples below. +3. Add a property `presets = []` and remove the `roles` property +4. Run `terraform plan`, there should be no changes to the API keys requested + +## Examples + +**1.15.x:** + +```hcl +resource "coralogix_api_key" "example" { + name = "My SCIM KEY" + owner = { + team_id : "5633574" + } + active = true + roles = ["SCIM", "Legacy Api Key", "Role Management", "Send Data"] +} +``` + +**>1.16:** + +```hcl +resource "coralogix_api_key" "example" { + name = "My SCIM KEY" + owner = { + team_id : "5633574" + } + active = true + permissions = [ + "alerts:ReadConfig", + "alerts:UpdateConfig", + "cloud-metadata-enrichment:ReadConfig", + "cloud-metadata-enrichment:UpdateConfig", + "cloud-metadata-ingress:SendData", + "data-usage:Read", + "geo-enrichment:ReadConfig", + "geo-enrichment:UpdateConfig", + "grafana:Read", + "grafana:Update", + "incidents:Acknowledge", + "incidents:Assign", + "incidents:Close", + "incidents:Read", + "incidents:Snooze", + "livetail:Read", + "logs.alerts:ReadConfig", + "logs.alerts:UpdateConfig", + "logs.data-ingress:SendData", + "logs.data-setup#low:ReadConfig", + "logs.data-setup#low:UpdateConfig", + "logs.events2metrics:ReadConfig", + "logs.events2metrics:UpdateConfig", + "logs.tco:ReadPolicies", + "logs.tco:UpdatePolicies", + "metrics.alerts:ReadConfig", + "metrics.alerts:UpdateConfig", + "metrics.data-analytics#high:Read", + "metrics.data-analytics#low:Read", + "metrics.data-ingress:SendData", + "metrics.data-setup#high:ReadConfig", + "metrics.data-setup#high:UpdateConfig", + "metrics.data-setup#low:ReadConfig", + "metrics.data-setup#low:UpdateConfig", + "metrics.recording-rules:ReadConfig", + "metrics.recording-rules:UpdateConfig", + "metrics.tco:ReadPolicies", + "metrics.tco:UpdatePolicies", + "outbound-webhooks:ReadConfig", + "outbound-webhooks:UpdateConfig", + "parsing-rules:ReadConfig", + "parsing-rules:UpdateConfig", + "security-enrichment:ReadConfig", + "security-enrichment:UpdateConfig", + "serverless:Read", + "service-catalog:Read", + "service-catalog:ReadApdexConfig", + "service-catalog:ReadDimensionsConfig", + "service-catalog:ReadSLIConfig", + "service-catalog:Update", + "service-catalog:UpdateApdexConfig", + "service-catalog:UpdateDimensionsConfig", + "service-catalog:UpdateSLIConfig", + "service-map:Read", + "source-mapping:UploadMapping", + "spans.alerts:ReadConfig", + "spans.alerts:UpdateConfig", + "spans.data-api#high:ReadData", + "spans.data-api#low:ReadData", + "spans.data-ingress:SendData", + "spans.data-setup#low:ReadConfig", + "spans.data-setup#low:UpdateConfig", + "spans.events2metrics:ReadConfig", + "spans.events2metrics:UpdateConfig", + "spans.tco:ReadPolicies", + "spans.tco:UpdatePolicies", + "suppression-rules:ReadConfig", + "suppression-rules:UpdateConfig", + "team-actions:ReadConfig", + "team-actions:UpdateConfig", + "team-api-keys-security-settings:Manage", + "team-api-keys-security-settings:ReadConfig", + "team-api-keys:Manage", + "team-api-keys:ReadConfig", + "team-custom-enrichment:ReadConfig", + "team-custom-enrichment:ReadData", + "team-custom-enrichment:UpdateConfig", + "team-custom-enrichment:UpdateData", + "team-dashboards:Read", + "team-dashboards:Update", + "team-groups:Manage", + "team-groups:ReadConfig", + "team-members:Manage", + "team-members:ReadConfig", + "team-quota:Manage", + "team-quota:Read", + "team-roles:Manage", + "team-roles:ReadConfig", + "user-actions:ReadConfig", + "user-actions:UpdateConfig", + "user-dashboards:Read", + "user-dashboards:Update", + "version-benchmark-tags:Read", + "version-benchmark-tags:Update" + ] + presets = [] +} +``` + +--- + +**1.15.x:** + +```hcl +resource "coralogix_api_key" "example" { + name = "My RUM KEY" + owner = { + team_id : "5633574" + } + active = true + roles = ["RUM Ingress"] +} +``` + +**>1.16:** + +```hcl +resource "coralogix_api_key" "example" { + name = "My RUM KEY" + owner = { + team_id : "5633574" + } + active = true + permissions = [ + "rum-ingress:SendData" + ] + presets = [] +} +``` +--- + +**1.15.x:** + +```hcl +resource "coralogix_api_key" "example" { + name = "My WH KEY" + owner = { + team_id : "5633574" + } + active = true + roles = ["Trigger Webhook"] +} +``` + +**>1.16:** + +```hcl +resource "coralogix_api_key" "example" { + name = "My WH KEY" + owner = { + team_id : "5633574" + } + active = true + permissions = [ + "contextual-data:SendData" + ] + presets = [] +} +``` + +--- + +**1.15.x:** + +```hcl +resource "coralogix_api_key" "example" { + name = "My RBAC KEY" + owner = { + team_id : "5633574" + } + active = true + roles = ["SCIM", "Role Management"] +} +``` + +**>1.16:** + +```hcl +resource "coralogix_api_key" "example" { + name = "My RBAC KEY" + owner = { + team_id : "5633574" + } + active = true + permissions = [ + "team-roles:Manage", + "team-roles:ReadConfig", + "team-groups:Manage", + "team-groups:ReadConfig", + "team-members:Manage", + "team-members:ReadConfig" + ] + presets = [] +} +``` + +## Limitations + +- Encrypted (hashed) keys are unsupported in this provider, therefore all keys are created in plain text + diff --git a/docs/index.md b/docs/index.md index 5f259940..c1447b21 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,16 +1,14 @@ --- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "coralogix Provider" -subcategory: "" +page_title: "Provider: Coralogix" description: |- - + The Coralogix provider for configuring Coralogix. --- -# coralogix Provider +# Coralogix Provider +Coralogix is a cloud-based, SaaS analytics and monitoring platform that combines logs, metrics, and traces to gain full observability into your system using one tool. The platform ingests data from any digital source and transforms it using our core features, allowing you to fully understand your system, analyze that data efficiently, and respond to incidents before they become problems. - -## Example Usage +Manage your Coralogix account from Terraform, including alerts, dashboards, and more. First, sign up for an account at [Coralogix.com](https://coralogix.com/) and create an API key. With that key and your region you can then configure the provider as follows: ```terraform terraform { @@ -26,13 +24,20 @@ provider "coralogix" { #api_key = "" #env = "" } -``` - - +``` ## Schema ### Optional - `api_key` (String, Sensitive) A key for using coralogix APIs (Auto Generated), appropriate for the defined environment. environment variable 'CORALOGIX_API_KEY' can be defined instead. - `domain` (String) The Coralogix domain. Conflict With 'env'. environment variable 'CORALOGIX_DOMAIN' can be defined instead. -- `env` (String) The Coralogix API environment. can be one of ["US2" "AP2" "APAC3" "AP3" "EUROPE1" "APAC1" "AP1" "US1" "APAC2" "EUROPE2" "EU2" "EU1" "USA1" "USA2"]. environment variable 'CORALOGIX_ENV' can be defined instead. +- `env` (String) The Coralogix API environment. can be one of ["USA1" "APAC1" "US2" "AP1" "APAC2" "AP3" "EUROPE1" "EU1" "EU2" "US1" "AP2" "APAC3" "EUROPE2" "USA2"]. environment variable 'CORALOGIX_ENV' can be defined instead.# Getting Started + +Check out our examples for how to configure the various resources offered by the provider. If you already have Coralogix set up and want to import any existing resources, check out our migration script: [https://github.com/coralogix/coralogix-management-sdk/tree/master/tools/terraform-importer](). + +# Additional Notes + +## Upgrading from V1.x.x to V2.x.x + +In this version upgrade we changed the schema of our alerts, which are now incompatible to previous versions. You can ease the transition process by using the importer tool mentioned above so your state is safely upgraded. Note that for existing Coralogix users an additional process is required for upgrading your account. Please reach out to customer support to receive more guidance. + diff --git a/docs/resources/alert.md b/docs/resources/alert.md index e8bad33d..33291026 100644 --- a/docs/resources/alert.md +++ b/docs/resources/alert.md @@ -510,7 +510,7 @@ resource "coralogix_alert" "test" { - `description` (String) Alert description. - `enabled` (Boolean) Alert enabled status. True by default. -- `group_by` (Set of String) Group by fields. +- `group_by` (List of String) Group by fields. - `incidents_settings` (Attributes) (see [below for nested schema](#nestedatt--incidents_settings)) - `labels` (Map of String) - `notification_group` (Attributes) (see [below for nested schema](#nestedatt--notification_group)) @@ -1604,7 +1604,7 @@ Required: Optional: -- `group_by_keys` (Set of String) +- `group_by_keys` (List of String) - `webhooks_settings` (Attributes Set) (see [below for nested schema](#nestedatt--notification_group--webhooks_settings)) diff --git a/docs/resources/webhook.md b/docs/resources/webhook.md index 7b400cac..9c101163 100644 --- a/docs/resources/webhook.md +++ b/docs/resources/webhook.md @@ -30,13 +30,12 @@ provider "coralogix" { resource "coralogix_webhook" "slack_webhook" { name = "slack-webhook" slack = { - notify_on = ["flow_anomalies"] + notify_on = ["flow_anomalies"] url = "https://join.slack.com/example" - attachments = [ - { - type = "metric_snapshot" - active = true - }] + attachments = [{ + type = "metric_snapshot" + active = true + }] } } @@ -113,23 +112,24 @@ resource "coralogix_webhook" "event_bridge_webhook" { } //example of how to use webhooks that was created via terraform -resource "coralogix_alert" "standard_alert" { - name = "Standard alert example" - description = "Example of standard alert from terraform" - severity = "Critical" +resource "coralogix_alert" "alert_with_webhook" { + name = "alert example with webhook" + description = "Example of logs_immediate alert from terraform" + priority = "P2" - notifications_group { - notification { + notification_group { + webhooks_settings { integration_id = coralogix_webhook.slack_webhook.external_id - retriggering_period_minutes = 60 - notify_on = "Triggered_only" } } - standard { - search_query = "remote_addr_enriched:/.*/" - condition { - immediately = true + type_definition = { + logs_immediate = { + logs_filter = { + simple_filter = { + lucene_query = "message:\"error\"" + } + } } } } diff --git a/templates/index.md.tmpl b/templates/index.md.tmpl new file mode 100644 index 00000000..7b037123 --- /dev/null +++ b/templates/index.md.tmpl @@ -0,0 +1,26 @@ +--- +page_title: "Provider: Coralogix" +description: |- + The Coralogix provider for configuring Coralogix. +--- + +# Coralogix Provider + +Coralogix is a cloud-based, SaaS analytics and monitoring platform that combines logs, metrics, and traces to gain full observability into your system using one tool. The platform ingests data from any digital source and transforms it using our core features, allowing you to fully understand your system, analyze that data efficiently, and respond to incidents before they become problems. + +Manage your Coralogix account from Terraform, including alerts, dashboards, and more. First, sign up for an account at [Coralogix.com](https://coralogix.com/) and create an API key. With that key and your region you can then configure the provider as follows: + +{{ tffile "examples/provider/provider.tf" }} + +{{- .SchemaMarkdown | trimspace -}} + +# Getting Started + +Check out our examples for how to configure the various resources offered by the provider. If you already have Coralogix set up and want to import any existing resources, check out our migration script: [https://github.com/coralogix/coralogix-management-sdk/tree/master/tools/terraform-importer](). + +# Additional Notes + +## Upgrading from V1.x.x to V2.x.x + +In this version upgrade we changed the schema of our alerts, which are now incompatible to previous versions. You can ease the transition process by using the importer tool mentioned above so your state is safely upgraded. Note that for existing Coralogix users an additional process is required for upgrading your account. Please reach out to customer support to receive more guidance. +