Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove unsupported and add log analytics workspace #1425

Merged
merged 1 commit into from
Mar 12, 2025

Conversation

tjololo
Copy link
Member

@tjololo tjololo commented Mar 12, 2025

Description

Azuremonitor setup isn't really supported it seems. Add LAW and diagnosticsettings to ease the clickops journey

Related Issue(s)

  • #{issue number}

Verification

  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)
  • All tests run green

Documentation

  • User documentation is updated with a separate linked PR in altinn-studio-docs. (if applicable)

Summary by CodeRabbit

  • New Features
    • Enhanced diagnostic logging and monitoring for API Management delivers improved log collection and performance insights.
    • Integrated a dedicated log analytics platform for refined data tracking and retention.
  • Chores
    • Retired the outdated diagnostic configuration to streamline the monitoring process.

@tjololo tjololo requested a review from a team as a code owner March 12, 2025 09:28
Copy link
Contributor

coderabbitai bot commented Mar 12, 2025

📝 Walkthrough

Walkthrough

The pull request updates the diagnostic configuration for an Azure API Management instance. It removes the existing azurerm_api_management_diagnostic resource and introduces two new resources in the same Terraform file: one to set up diagnostic settings via azurerm_monitor_diagnostic_setting and another to provision a Log Analytics workspace via azurerm_log_analytics_workspace. The new configuration forwards "GatewayLogs" and "AllMetrics" to the Log Analytics workspace.

Changes

File Change Summary
infrastructure/.../analytics.tf - Added: azurerm_monitor_diagnostic_setting resource for API Management diagnostics
- Added: azurerm_log_analytics_workspace resource for log analytics
- Removed: azurerm_api_management_diagnostic resource

Sequence Diagram(s)

sequenceDiagram
  participant APIM as API Management
  participant MSD as Monitor Diagnostic Setting
  participant LA as Log Analytics Workspace

  APIM->>MSD: Generate logs and metrics
  MSD->>LA: Forward logs and metrics
Loading

Possibly related PRs

Suggested reviewers

  • sduranc

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

github-actions bot commented Mar 12, 2025

Terraform environment test

Format and Style 🖌success

Initialization ⚙️success

Validation 🤖success

Validation Output

Success! The configuration is valid.


Plan 📖success

Show Plan

[Lines containing Refreshing state removed]
[Truncated to 120000 bytes! See logoutput for complete plan]
Acquiring state lock. This may take a few moments...
data.azurerm_container_registry.altinncr: Reading...
data.azurerm_container_registry.altinncr: Read complete after 1s [id=/subscriptions/a6e9ee7d-2b65-41e1-adfb-0c8c23515cf9/resourceGroups/acr/providers/Microsoft.ContainerRegistry/registries/altinncr]

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # azurerm_log_analytics_workspace.apimlogs will be created
  + resource "azurerm_log_analytics_workspace" "apimlogs" {
      + allow_resource_only_permissions = true
      + daily_quota_gb                  = -1
      + id                              = (known after apply)
      + internet_ingestion_enabled      = true
      + internet_query_enabled          = true
      + local_authentication_disabled   = false
      + location                        = "norwayeast"
      + name                            = "altinn-apim-test-apimlogs"
      + primary_shared_key              = (sensitive value)
      + resource_group_name             = "altinn-apim-test-rg"
      + retention_in_days               = 7
      + secondary_shared_key            = (sensitive value)
      + sku                             = "PerGB2018"
      + workspace_id                    = (known after apply)
    }

  # azurerm_monitor_diagnostic_setting.apimdiagnostics_settings will be created
  + resource "azurerm_monitor_diagnostic_setting" "apimdiagnostics_settings" {
      + id                             = (known after apply)
      + log_analytics_destination_type = (known after apply)
      + log_analytics_workspace_id     = (known after apply)
      + name                           = "altinn-apim-test-apimdiagnostics-settings"
      + target_resource_id             = "/subscriptions/1ce8e9af-c2d6-44e7-9c5e-099a308056fe/resourceGroups/altinn-apim-test-rg/providers/Microsoft.ApiManagement/service/altinn-apim-test-apim"

      + enabled_log {
          + category       = "GatewayLogs"
            # (1 unchanged attribute hidden)
        }

      + metric {
          + category = "AllMetrics"
          + enabled  = true
        }
    }

Plan: 2 to add, 0 to change, 0 to destroy.

─────────────────────────────────────────────────────────────────────────────

Saved the plan to: tfplan.out

To perform exactly these actions, run the following command to apply:
    terraform apply "tfplan.out"
Releasing state lock. This may take a few moments...

Context Values
Pusher @tjololo
Action push
Working Directory ./infrastructure/adminservices-test/altinn-apim-test-rg
State File github.com/altinn/altinn-platform/environments/test/altinn-apim-test-rg.tfstate
Plan File github.com_altinn_altinn-platform_environments_test_altinn-apim-test-rg.tfstate.tfplan

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
infrastructure/adminservices-test/altinn-apim-test-rg/analytics.tf (1)

79-86: New Log Analytics Workspace Configuration
The new azurerm_log_analytics_workspace resource is set up with the SKU "PerGB2018" and a retention period of 7 days. Confirm that these settings align with your monitoring and compliance requirements. Optionally, consider parameterizing retention_in_days to allow easier adjustments for different environments or future changes.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e553437 and addb5fd.

📒 Files selected for processing (1)
  • infrastructure/adminservices-test/altinn-apim-test-rg/analytics.tf (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (go)
🔇 Additional comments (1)
infrastructure/adminservices-test/altinn-apim-test-rg/analytics.tf (1)

18-28: New Diagnostic Settings Resource
The new azurerm_monitor_diagnostic_setting resource is configured to forward "GatewayLogs" (logs) and "AllMetrics" (metrics) from the API Management instance to the Log Analytics workspace. Please verify that these categories are supported for your specific API Management instance and that no additional options (such as retention policies) are required in your operational context.

@tjololo tjololo merged commit 752a475 into main Mar 12, 2025
8 checks passed
@tjololo tjololo deleted the feat/remove-azuremonitor-add-law branch March 12, 2025 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants