如何使用Terraform通过日志工作区实现Azure监控警报VM心跳

编程入门 行业动态 更新时间:2024-10-17 13:34:16
本文介绍了如何使用Terraform通过日志工作区实现Azure监控警报VM心跳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

需要使用KQL/Kusto查询在Azure监视中实现一系列警报。这是非常基本的,例如心跳、可用磁盘空间(基于代理输出到日志工作区)。

查看Terraform文档时,我不确定要使用哪些资源。我预计我需要首先在资源中构建查询,然后构建警报资源。但是,查看文档后,似乎应该将查询添加到此资源。

registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_activity_log_alert

无论如何,如果有人能分享一个为虚拟机实现Azure监视器警报的示例(win/linux),那就太棒了。

推荐答案

谢谢UserP。将您的建议作为答复发布以帮助其他社区成员。

azurerm_monitor_scheduled_query_rules_alert

  • 管理Azure监视器中的AlertingAction计划查询规则资源。
resource "azurerm_resource_group" "example" { name = "monitoring-resources" location = "West Europe" } resource "azurerm_application_insights" "example" { name = "appinsights" location = var.location resource_group_name = azurerm_resource_group.example.name application_type = "web" } resource "azurerm_application_insights" "example2" { name = "appinsights2" location = var.location resource_group_name = azurerm_resource_group.example.name application_type = "web" } # Example: Alerting Action with metric trigger resource "azurerm_monitor_scheduled_query_rules_alert" "example" { name = format("%s-queryrule", var.prefix) location = azurerm_resource_group.example.location resource_group_name = azurerm_resource_group.example.name action { action_group = [] email_subject = "Email Header" custom_webhook_payload = "{}" } data_source_id = azurerm_application_insights.example.id description = "Query results grouped into AggregatedValue; alert when results cross threshold" enabled = true # Count all requests with server error result code grouped into 5-minute bins by HTTP operation query = <<-QUERY requests | where tolong(resultCode) >= 500 | summarize AggregatedValue = count() by operation_Name, bin(timestamp, 5m) QUERY severity = 1 frequency = 5 time_window = 30 trigger { operator = "GreaterThan" threshold = 3 metric_trigger { operator = "GreaterThan" threshold = 1 metric_trigger_type = "Total" metric_column = "operation_Name" } } }

您可以参考azurerm_monitor_scheduled_query_rules_alert和Support alerts based on Log analytics queries

更多推荐

如何使用Terraform通过日志工作区实现Azure监控警报VM心跳

本文发布于:2023-11-24 04:44:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1624017.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:警报   如何使用   工作   日志   VM

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!