# drop-observability-azure-research

# Drop — Observability Stack on Azure (Research)

**Client:** Drop (Digital Banking)
**Type:** Research — Azure equivalent of AWS observability plan
**Reference:** ~/system/specs/drop-observability-plan.md (AWS version)
**Created:** 2026-02-20

---

## AWS → Azure Mapping

| Komponenta | AWS (Drop danas) | Azure ekvivalent |
|-----------|-------------------|-------------------|
| Log aggregation | CloudWatch Logs | **Azure Monitor Logs** (Log Analytics Workspace) |
| Alarmi | CloudWatch Alarms | **Azure Monitor Alerts** (Metric Alerts + Log Alerts) |
| Notifikacije | SNS Topics | **Action Groups** (email, SMS, Slack webhook, Teams) |
| DB monitoring | RDS Performance Insights | **Query Performance Insight** (Azure Database for PostgreSQL) |
| App observability | App Runner Observability | **Application Insights** (auto-instrument, zero-code za .NET/Node/Python) |
| Container logs | App Runner → CloudWatch | **Container Apps Logs** → Log Analytics (automatic) |
| Uptime monitoring | BetterStack (external) | **BetterStack** (isto — cloud-agnostic) ILI Azure Availability Tests |
| Error tracking | Sentry (external) | **Sentry** (isto — cloud-agnostic) ILI Application Insights Exceptions |
| Metrics/Dashboards | Grafana Cloud (external) | **Grafana Cloud** (isto) ILI Azure Dashboards + Workbooks |

---

## Azure-Specific Prednosti

1. **Application Insights** — Ubija 3 alata odjednom (APM + error tracking + metrics). Auto-instrument za Node.js. Zamjenjuje Sentry + Prometheus + dio Grafane.
2. **Log Analytics Workspace** — KQL query language (moćniji od CloudWatch Insights). Centralni log store.
3. **Action Groups** — Jedna konfiguracija za SVE alerte (email + SMS + Slack webhook + Teams + Azure Function).
4. **Azure Workbooks** — Besplatni interaktivni dashboardi (zamjena za Grafana ako ne treba multi-cloud).

---

## Terraform (AzureRM)

```hcl
# 1. Log Analytics Workspace
resource "azurerm_log_analytics_workspace" "main" {
  name                = "drop-logs"
  resource_group_name = azurerm_resource_group.main.name
  location            = azurerm_resource_group.main.location
  sku                 = "PerGB2018"    # Pay-as-you-go, 5GB/mo free
  retention_in_days   = 30
}

# 2. Application Insights
resource "azurerm_application_insights" "main" {
  name                = "drop-appinsights"
  resource_group_name = azurerm_resource_group.main.name
  location            = azurerm_resource_group.main.location
  workspace_id        = azurerm_log_analytics_workspace.main.id
  application_type    = "Node.JS"
}

# 3. Action Group (notifikacije)
resource "azurerm_monitor_action_group" "ops" {
  name                = "drop-ops-alerts"
  resource_group_name = azurerm_resource_group.main.name
  short_name          = "dropops"

  email_receiver {
    name          = "ceo"
    email_address = "alem@alai.no"
  }
  # Slack: webhook_receiver { ... service_uri = "https://hooks.slack.com/..." }
}

# 4. Alert Rules (primjeri)
resource "azurerm_monitor_metric_alert" "high_error_rate" {
  name                = "drop-high-error-rate"
  resource_group_name = azurerm_resource_group.main.name
  scopes              = [azurerm_application_insights.main.id]
  severity            = 1
  frequency           = "PT1M"
  window_size         = "PT5M"

  criteria {
    metric_namespace = "microsoft.insights/components"
    metric_name      = "requests/failed"
    aggregation      = "Count"
    operator         = "GreaterThan"
    threshold        = 5
  }
  action { action_group_id = azurerm_monitor_action_group.ops.id }
}

# 5. Availability Test (uptime monitoring)
resource "azurerm_application_insights_standard_web_test" "health" {
  name                    = "drop-health-check"
  resource_group_name     = azurerm_resource_group.main.name
  location                = azurerm_resource_group.main.location
  application_insights_id = azurerm_application_insights.main.id
  frequency               = 300  # 5 min
  enabled                 = true

  request { url = "https://drop.example.com/api/health" }
}
```

---

## Koraci za implementaciju

1. [ ] Kreiraj Azure Resource Group za monitoring resurse
2. [ ] Deploy Log Analytics Workspace (Terraform)
3. [ ] Deploy Application Insights connected to Workspace (Terraform)
4. [ ] Dodaj `APPLICATIONINSIGHTS_CONNECTION_STRING` u app environment
5. [ ] `npm install applicationinsights` u app + `appinsights.setup().start()` na boot
6. [ ] Kreiraj Action Group sa email + Slack webhook (Terraform)
7. [ ] Dodaj Metric Alerts: error rate, response time p99, availability (Terraform)
8. [ ] Dodaj Availability Test za health endpoint (Terraform)
9. [ ] Opciono: BetterStack kao external monitor (isti setup kao AWS varijanta)
10. [ ] Verifikuj: App Insights prima telemetriju, alarmi rade, logi vidljivi u Log Analytics

---

## Cost (Azure)

| Stavka | Cijena |
|--------|--------|
| Application Insights | 5GB/mo free, zatim ~$2.30/GB |
| Log Analytics | 5GB/mo free ingestion, 31 dana free retention |
| Alert Rules | 1st metric alert free, zatim ~$0.10/rule/mo |
| Availability Tests | 1st 10 free |
| **Total (mali promet)** | **~$0-5/mo** |

---

## Reference

- AWS plan: ~/system/specs/drop-observability-plan.md
- Azure Monitor docs: https://learn.microsoft.com/en-us/azure/azure-monitor/
- Application Insights Node.js: https://learn.microsoft.com/en-us/azure/azure-monitor/app/nodejs
- Terraform AzureRM Monitor: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_metric_alert