From a0a1cd6ca7118bd7e0efbc68499d7cf5309f0e1f Mon Sep 17 00:00:00 2001 From: Yufei Li Date: Fri, 21 Apr 2023 11:37:36 +0800 Subject: [PATCH] feat: Add rspec generator for documentation in Hashicorp Registry (#1) --- docs/data-sources/functions.md | 51 ---- docs/resources/alertpolicy.md | 158 +++++++++- docs/resources/dashboard.md | 23 +- docs/resources/membergroup.md | 58 +++- docs/resources/monitor.md | 23 +- docs/resources/mute.md | 293 ++++++++++++++++++- docs/resources/notification.md | 50 +++- docs/resources/pipeline.md | 106 +++++++ examples/alertpolicy/README.md | 2 +- examples/alertpolicy/main.tf | 2 +- examples/dashboard/README.md | 2 +- examples/membergroup/README.md | 1 - examples/membergroup/main.tf | 1 - examples/monitor/README.md | 2 +- examples/mute/README.md | 111 ++++--- examples/mute/main.tf | 111 ++++--- guance/data_sources.go | 2 - internal/consts/types.go | 1 - internal/datasources/functions/README.md | 1 - internal/datasources/functions/datasource.go | 111 ------- internal/datasources/functions/model.go | 45 --- internal/datasources/functions/schema.go | 79 ----- internal/resources/alertpolicy/README.md | 84 +++++- internal/resources/alertpolicy/model.go | 2 +- internal/resources/alertpolicy/schema.go | 2 +- internal/resources/dashboard/README.md | 14 +- internal/resources/membergroup/README.md | 34 ++- internal/resources/monitor/README.md | 14 +- internal/resources/mute/README.md | 151 +++++++++- internal/resources/mute/model.go | 7 + internal/resources/mute/schema.go | 24 +- internal/resources/notification/README.md | 30 +- internal/resources/pipeline/README.md | 58 +++- tests/resources/alertpolicy/resource_test.go | 2 +- tests/resources/membergroup/resource_test.go | 1 - tests/resources/mute/resource_test.go | 111 ++++--- 36 files changed, 1328 insertions(+), 439 deletions(-) delete mode 100644 docs/data-sources/functions.md delete mode 100644 internal/datasources/functions/README.md delete mode 100644 internal/datasources/functions/datasource.go delete mode 100644 internal/datasources/functions/model.go delete mode 100644 internal/datasources/functions/schema.go diff --git a/docs/data-sources/functions.md b/docs/data-sources/functions.md deleted file mode 100644 index e8298e9..0000000 --- a/docs/data-sources/functions.md +++ /dev/null @@ -1,51 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "guance_functions Data Source - guance" -subcategory: "" -description: |- - Guance Cloud Function is a function development, management and execution platform. It is simple and easy to use, without the need to build Web services from scratch, without managing servers and other infrastructure, just write code and publish, and simply configure to generate HTTP API interfaces for functions. ---- - -# guance_functions (Data Source) - -Guance Cloud Function is a function development, management and execution platform. It is simple and easy to use, without the need to build Web services from scratch, without managing servers and other infrastructure, just write code and publish, and simply configure to generate HTTP API interfaces for functions. - - - - -## Schema - -### Optional - -- `filter` (Attributes List) The list of the resource (see [below for nested schema](#nestedatt--filter)) -- `max_results` (Number) The max results count of the resource will be returned. - -### Read-Only - -- `id` (String) Identifier of the resource. -- `items` (Attributes List) The list of the resource (see [below for nested schema](#nestedatt--items)) - - -### Nested Schema for `filter` - -Required: - -- `name` (String) The filter path, represent as json path. -- `values` (List of String) The filter values - - - -### Nested Schema for `items` - -Optional: - -- `description` (String) Description -- `func_id` (String) Function ID -- `title` (String) Title - -Read-Only: - -- `created_at` (String) Timestamp of the last Terraform update of the order. -- `id` (String) Numeric identifier of the order. - - diff --git a/docs/resources/alertpolicy.md b/docs/resources/alertpolicy.md index b57058f..e796792 100644 --- a/docs/resources/alertpolicy.md +++ b/docs/resources/alertpolicy.md @@ -3,22 +3,93 @@ page_title: "guance_alertpolicy Resource - guance" subcategory: "" description: |- - Alert policy is a set of rules that define when to trigger an alert. You can create alert policies for your data sources, and set up alert targets to receive alerts. - Guance Cloud supports alert policy management for the results of monitor checks, by sending alert notification emails or group message notifications, so that you can know about the abnormal data situation of the monitoring in time, find problems, and solve problems. + Alert Policy + Alert policy is a set of rules that define when to trigger an alert. You can create alert policies for your data + sources, and set up alert targets to receive alerts. + Guance Cloud supports alert policy management for the results of monitor checks, by sending alert notification emails or + group message notifications, so that you can know about the abnormal data situation of the monitoring in time, find + problems, and solve problems. Relationships: ```mermaid graph LR A[Monitor] --> B[Alert Policy] --> C[Notification] ``` Notes: - When a monitor is created, an alert policy must be selected, and the default is selected by default;When a certain alert policy is deleted, the monitor under the deleted alert policy will automatically be classified into the default. + When a monitor is created, an alert policy must be selected, and the default is selected by default;When a certain alert policy is deleted, the monitor under the deleted alert policy will automatically be classified + into the default. + Create + The first let me create a resource. We will send the create operation to the resource management service + ```terraform + variable "dingtalkwebhook" { + type = string + } + variable "dingtalksecret" { + type = string + } + variable "email" { + type = string + } + data "guance_members" "demo" { + filter = [ + { + name = "email" + values = [var.email] + } + ] + } + resource "guancemembergroup" "demo" { + name = "oac-demo" + memberids = data.guance_members.demo.items[*].id + } + resource "guancenotification" "demo" { + name = "oac-demo" + type = "dingtalkrobot" + dingtalkrobot = { + webhook = var.dingtalkwebhook + secret = var.dingtalk_secret + } + } + resource "guancealertpolicy" "demo" { + name = "oac-demo" + silenttimeout = "1h" + statuses = [ + "critical", + "error", + "warning", + "info", + "ok", + "nodata", + "nodataok", + "nodataas_ok", + ] + alerttargets = [ + { + type = "membergroup" + membergroup = { + id = guancemembergroup.demo.id + } + }, + { + type = "notification" + notification = { + id = guance_notification.demo.id + } + } + ] + } + ``` --- # guance_alertpolicy (Resource) -Alert policy is a set of rules that define when to trigger an alert. You can create alert policies for your data sources, and set up alert targets to receive alerts. +# Alert Policy + +Alert policy is a set of rules that define when to trigger an alert. You can create alert policies for your data +sources, and set up alert targets to receive alerts. -Guance Cloud supports alert policy management for the results of monitor checks, by sending alert notification emails or group message notifications, so that you can know about the abnormal data situation of the monitoring in time, find problems, and solve problems. +Guance Cloud supports alert policy management for the results of monitor checks, by sending alert notification emails or +group message notifications, so that you can know about the abnormal data situation of the monitoring in time, find +problems, and solve problems. Relationships: @@ -31,7 +102,80 @@ A[Monitor] --> B[Alert Policy] --> C[Notification] Notes: 1. When a monitor is created, an alert policy must be selected, and the default is selected by default; -2. When a certain alert policy is deleted, the monitor under the deleted alert policy will automatically be classified into the default. +2. When a certain alert policy is deleted, the monitor under the deleted alert policy will automatically be classified + into the default. + +## Create + +The first let me create a resource. We will send the create operation to the resource management service + +```terraform +variable "ding_talk_webhook" { + type = string +} + +variable "ding_talk_secret" { + type = string +} + +variable "email" { + type = string +} + +data "guance_members" "demo" { + filter = [ + { + name = "email" + values = [var.email] + } + ] +} + +resource "guance_membergroup" "demo" { + name = "oac-demo" + member_ids = data.guance_members.demo.items[*].id +} + +resource "guance_notification" "demo" { + name = "oac-demo" + type = "ding_talk_robot" + ding_talk_robot = { + webhook = var.ding_talk_webhook + secret = var.ding_talk_secret + } +} + +resource "guance_alertpolicy" "demo" { + name = "oac-demo" + silent_timeout = "1h" + + statuses = [ + "critical", + "error", + "warning", + "info", + "ok", + "nodata", + "nodata_ok", + "nodata_as_ok", + ] + + alert_targets = [ + { + type = "member_group" + member_group = { + id = guance_membergroup.demo.id + } + }, + { + type = "notification" + notification = { + id = guance_notification.demo.id + } + } + ] +} +``` @@ -46,7 +190,7 @@ Notes: ### Optional - `alert_targets` (Attributes List) Alert Action (see [below for nested schema](#nestedatt--alert_targets)) -- `silent_timeout` (Number) Silent timeout timestamp +- `silent_timeout` (String) Silent timeout timestamp ### Read-Only diff --git a/docs/resources/dashboard.md b/docs/resources/dashboard.md index a997dc3..a8e5c80 100644 --- a/docs/resources/dashboard.md +++ b/docs/resources/dashboard.md @@ -3,15 +3,24 @@ page_title: "guance_dashboard Resource - guance" subcategory: "" description: |- - WORKING IN PROGRESS! + Dashboard + WORKING IN PROGRESS A dashboard is a collection of visualizations that you can use to monitor the health of your systems and applications. Dashboards are made up of one or more panels, which are the visualizations themselves. Each panel displays a single metric or a single aggregation of metrics. Dashboards are a great way to visualize your data and monitor your systems. You can use them to track metrics over time, and to quickly see how your systems are performing. You can also use them to compare metrics from different systems and applications. Guance Cloud's dashboard is used to clearly show the range in which the metric data values are located. It is suitable for slicing messy data into points. + Create + The first let me create a resource. We will send the create operation to the resource management service + terraform + resource "guance_dashboard" "demo" { + name = "oac-demo" + } --- # guance_dashboard (Resource) -**WORKING IN PROGRESS!** +# Dashboard + +**WORKING IN PROGRESS** A dashboard is a collection of visualizations that you can use to monitor the health of your systems and applications. Dashboards are made up of one or more panels, which are the visualizations themselves. Each panel displays a single metric or a single aggregation of metrics. @@ -19,6 +28,16 @@ Dashboards are a great way to visualize your data and monitor your systems. You Guance Cloud's dashboard is used to clearly show the range in which the metric data values are located. It is suitable for slicing messy data into points. +## Create + +The first let me create a resource. We will send the create operation to the resource management service + +```terraform +resource "guance_dashboard" "demo" { + name = "oac-demo" +} +``` + diff --git a/docs/resources/membergroup.md b/docs/resources/membergroup.md index e9b7ff3..2528b43 100644 --- a/docs/resources/membergroup.md +++ b/docs/resources/membergroup.md @@ -3,21 +3,47 @@ page_title: "guance_membergroup Resource - guance" subcategory: "" description: |- - Member group is a collection of members in a workspace, and member groups can be authorized to access the resources in the workspace. - Member group is an abstract concept, it can be a team, or a department, it can help us build a reasonable organizational structure, optimize the management efficiency and user experience of the observability platform. + Member Group + Member group is a collection of members in a workspace, and member groups can be authorized to access the resources in + the workspace. + Member group is an abstract concept, it can be a team, or a department, it can help us build a reasonable organizational + structure, optimize the management efficiency and user experience of the observability platform. Relationships: ```mermaid graph LR A[Workspace] --> B[Member] A --> C[MemberGroup] ``` + Create + The first let me create a resource. We will send the create operation to the resource management service + ```terraform + variable "email" { + type = string + } + data "guance_members" "demo" { + filter = [ + { + name = "email" + values = [var.email] + } + ] + } + resource "guancemembergroup" "demo" { + name = "oac-demo" + memberids = data.guance_members.demo.items[*].id + } + ``` --- # guance_membergroup (Resource) -Member group is a collection of members in a workspace, and member groups can be authorized to access the resources in the workspace. +# Member Group + +Member group is a collection of members in a workspace, and member groups can be authorized to access the resources in +the workspace. -Member group is an abstract concept, it can be a team, or a department, it can help us build a reasonable organizational structure, optimize the management efficiency and user experience of the observability platform. +Member group is an abstract concept, it can be a team, or a department, it can help us build a reasonable organizational +structure, optimize the management efficiency and user experience of the observability platform. Relationships: @@ -28,6 +54,30 @@ A[Workspace] --> B[Member] A --> C[MemberGroup] ``` +## Create + +The first let me create a resource. We will send the create operation to the resource management service + +```terraform +variable "email" { + type = string +} + +data "guance_members" "demo" { + filter = [ + { + name = "email" + values = [var.email] + } + ] +} + +resource "guance_membergroup" "demo" { + name = "oac-demo" + member_ids = data.guance_members.demo.items[*].id +} +``` + diff --git a/docs/resources/monitor.md b/docs/resources/monitor.md index be16a39..55362e6 100644 --- a/docs/resources/monitor.md +++ b/docs/resources/monitor.md @@ -3,7 +3,8 @@ page_title: "guance_monitor Resource - guance" subcategory: "" description: |- - WORKING IN PROGRESS! + Monitor + WORKING IN PROGRESS A monitor is a set of checks that you can run against your data. A monitor watches your data over time and alerts you when certain conditions are met. For example, you can create a monitor that watches the average response time of your website and alerts you when the response time is greater than 1 second. Monitors are made up of one or more checks. A check is a single test that you can run against your data. For example, you can create a check that watches the average response time of your website. You can also create a check that watches the percentage of 5xx errors in your logs. Guance Cloud supports defining monitors, users can customize the configuration of detection rules and trigger conditions, and open the monitors to receive related alarm events triggered by the detection rules. @@ -12,11 +13,19 @@ description: |- graph LR A[Monitor] --> B[Alert Policy] --> C[Notification] ``` + Create + The first let me create a resource. We will send the create operation to the resource management service + terraform + resource "guance_monitor" "demo" { + name = "oac-demo" + } --- # guance_monitor (Resource) -**WORKING IN PROGRESS!** +# Monitor + +**WORKING IN PROGRESS** A monitor is a set of checks that you can run against your data. A monitor watches your data over time and alerts you when certain conditions are met. For example, you can create a monitor that watches the average response time of your website and alerts you when the response time is greater than 1 second. @@ -32,6 +41,16 @@ graph LR A[Monitor] --> B[Alert Policy] --> C[Notification] ``` +## Create + +The first let me create a resource. We will send the create operation to the resource management service + +```terraform +resource "guance_monitor" "demo" { + name = "oac-demo" +} +``` + diff --git a/docs/resources/mute.md b/docs/resources/mute.md index 9de2586..805a426 100644 --- a/docs/resources/mute.md +++ b/docs/resources/mute.md @@ -3,19 +3,153 @@ page_title: "guance_mute Resource - guance" subcategory: "" description: |- - Mute rule is a feature that allows you to temporarily stop receiving notifications for a specific alert. You can use mute rules to temporarily silence alerts that are not relevant to you, or to silence alerts that you are already aware of. - Guance Cloud supports the management of all mute rules in the current workspace. It supports muting different monitors, smart inspections, self-built inspections, SLOs, and alert policies, so that the muted objects do not send any alert notifications to any alert notification objects during the mute time. + Mute Rule + Mute rule is a feature that allows you to temporarily stop receiving notifications for a specific alert. You can use + mute rules to temporarily silence alerts that are not relevant to you, or to silence alerts that you are already aware + of. + Guance Cloud supports the management of all mute rules in the current workspace. It supports muting different monitors, + smart inspections, self-built inspections, SLOs, and alert policies, so that the muted objects do not send any alert + notifications to any alert notification objects during the mute time. Relationships: mermaid graph LR A[Mute Rule] --> B[Alert Policy] + + Create + The first let me create a resource. We will send the create operation to the resource management service + ```terraform + variable "dingtalkwebhook" { + type = string + } + variable "dingtalksecret" { + type = string + } + variable "email" { + type = string + } + data "guance_members" "demo" { + filter = [ + { + name = "email" + values = [var.email] + } + ] + } + resource "guancemembergroup" "demo" { + name = "oac-demo" + memberids = data.guance_members.demo.items[*].id + } + resource "guancenotification" "demo" { + name = "oac-demo" + type = "dingtalkrobot" + dingtalkrobot = { + webhook = var.dingtalkwebhook + secret = var.dingtalk_secret + } + } + resource "guancealertpolicy" "demo" { + name = "oac-demo" + silenttimeout = "1h" + statuses = [ + "critical", + "error", + "warning", + "info", + "ok", + "nodata", + "nodataok", + "nodataas_ok", + ] + alerttargets = [ + { + type = "membergroup" + membergroup = { + id = guancemembergroup.demo.id + } + }, + { + type = "notification" + notification = { + id = guance_notification.demo.id + } + } + ] + } + resource "guancemute" "demo" { + // mute ranges + muteranges = [ + { + type = "alert_policy" + alert_policy = { + id = guance_alertpolicy.demo.id + } + } + + ] + // notify options + notify = { + message = < B[Alert Policy] ``` +## Create + +The first let me create a resource. We will send the create operation to the resource management service + +```terraform +variable "ding_talk_webhook" { + type = string +} + +variable "ding_talk_secret" { + type = string +} + +variable "email" { + type = string +} + +data "guance_members" "demo" { + filter = [ + { + name = "email" + values = [var.email] + } + ] +} + +resource "guance_membergroup" "demo" { + name = "oac-demo" + member_ids = data.guance_members.demo.items[*].id +} + +resource "guance_notification" "demo" { + name = "oac-demo" + type = "ding_talk_robot" + ding_talk_robot = { + webhook = var.ding_talk_webhook + secret = var.ding_talk_secret + } +} + +resource "guance_alertpolicy" "demo" { + name = "oac-demo" + silent_timeout = "1h" + + statuses = [ + "critical", + "error", + "warning", + "info", + "ok", + "nodata", + "nodata_ok", + "nodata_as_ok", + ] + + alert_targets = [ + { + type = "member_group" + member_group = { + id = guance_membergroup.demo.id + } + }, + { + type = "notification" + notification = { + id = guance_notification.demo.id + } + } + ] +} + +resource "guance_mute" "demo" { + // mute ranges + mute_ranges = [ + { + type = "alert_policy" + + alert_policy = { + id = guance_alertpolicy.demo.id + } + } + ] + + // notify options + notify = { + message = < @@ -32,6 +305,7 @@ graph LR ### Optional - `mute_ranges` (Attributes List) Mute Ranges (see [below for nested schema](#nestedatt--mute_ranges)) +- `mute_tags` (Attributes List) Tags (see [below for nested schema](#nestedatt--mute_tags)) - `notify` (Attributes) Notify Options (see [below for nested schema](#nestedatt--notify)) - `notify_targets` (Attributes List) Notify targets (see [below for nested schema](#nestedatt--notify_targets)) - `onetime` (Attributes) Onetime (see [below for nested schema](#nestedatt--onetime)) @@ -71,6 +345,15 @@ Required: + +### Nested Schema for `mute_tags` + +Required: + +- `key` (String) Tag +- `value` (String) Tag Value + + ### Nested Schema for `notify` @@ -123,7 +406,7 @@ Optional: Optional: -- `crontab` (Attributes) Repeat Crontab Set (see [below for nested schema](#nestedatt--repeat--crontab)) +- `crontab` (Attributes) Crontab configuration (see [below for nested schema](#nestedatt--repeat--crontab)) - `crontab_duration` (String) Crontab Duration - `end` (String) End - `expire` (String) Repeat Expire diff --git a/docs/resources/notification.md b/docs/resources/notification.md index ecf0c0f..02fd780 100644 --- a/docs/resources/notification.md +++ b/docs/resources/notification.md @@ -3,21 +3,44 @@ page_title: "guance_notification Resource - guance" subcategory: "" description: |- + Notification Notification is a feature that allows you to receive alerts when an event occurs. - Guance Cloud supports setting the notification object for the alert event. When the alert event occurs, the alert information will be sent to the notification object. + Guance Cloud supports setting the notification object for the alert event. When the alert event occurs, the alert + information will be sent to the notification object. Guance Cloud supports multiple different notification methods. You can refer to the documentation to learn more. Relationships: ```mermaid graph LR A[Monitor] --> B[Alert Policy] --> C[Notification] ``` + Create + The first let me create a resource. We will send the create operation to the resource management service + ```terraform + variable "dingtalkwebhook" { + type = string + } + variable "dingtalksecret" { + type = string + } + resource "guancenotification" "demo" { + name = "oac-demo" + type = "dingtalkrobot" + dingtalkrobot = { + webhook = var.dingtalkwebhook + secret = var.dingtalk_secret + } + } + ``` --- # guance_notification (Resource) +# Notification + Notification is a feature that allows you to receive alerts when an event occurs. -Guance Cloud supports setting the notification object for the alert event. When the alert event occurs, the alert information will be sent to the notification object. +Guance Cloud supports setting the notification object for the alert event. When the alert event occurs, the alert +information will be sent to the notification object. Guance Cloud supports multiple different notification methods. You can refer to the documentation to learn more. @@ -29,6 +52,29 @@ graph LR A[Monitor] --> B[Alert Policy] --> C[Notification] ``` +## Create + +The first let me create a resource. We will send the create operation to the resource management service + +```terraform +variable "ding_talk_webhook" { + type = string +} + +variable "ding_talk_secret" { + type = string +} + +resource "guance_notification" "demo" { + name = "oac-demo" + type = "ding_talk_robot" + ding_talk_robot = { + webhook = var.ding_talk_webhook + secret = var.ding_talk_secret + } +} +``` + diff --git a/docs/resources/pipeline.md b/docs/resources/pipeline.md index dea4908..a7fd281 100644 --- a/docs/resources/pipeline.md +++ b/docs/resources/pipeline.md @@ -3,19 +3,125 @@ page_title: "guance_pipeline Resource - guance" subcategory: "" description: |- + Pipeline Pipeline is a data processing language that Observability Cloud provides. Pipeline supports text parsing of different formats of log data. By writing a pipeline script, you can customize the structure of the log and use the cut fields as attributes. By cutting out the attribute fields, we can quickly filter the relevant logs and perform data association analysis to help us quickly locate and solve problems. + Create + The first let me create a resource. We will send the create operation to the resource management service + ```terraform + resource "guancepipeline" "demo" { + name = "oac-demo" + category = "logging" + source = [ + "nginx" + ] + isdefault = false + is_force = false + content = < diff --git a/examples/alertpolicy/README.md b/examples/alertpolicy/README.md index 1816763..fb821c4 100644 --- a/examples/alertpolicy/README.md +++ b/examples/alertpolicy/README.md @@ -63,7 +63,7 @@ resource "guance_notification" "demo" { resource "guance_alertpolicy" "demo" { name = "oac-demo" - silent_timeout = 3600 + silent_timeout = "1h" statuses = [ "critical", diff --git a/examples/alertpolicy/main.tf b/examples/alertpolicy/main.tf index a8b4b3b..d3f5a37 100644 --- a/examples/alertpolicy/main.tf +++ b/examples/alertpolicy/main.tf @@ -35,7 +35,7 @@ resource "guance_notification" "demo" { resource "guance_alertpolicy" "demo" { name = "oac-demo" - silent_timeout = 3600 + silent_timeout = "1h" statuses = [ "critical", diff --git a/examples/dashboard/README.md b/examples/dashboard/README.md index 179cfc1..381a229 100644 --- a/examples/dashboard/README.md +++ b/examples/dashboard/README.md @@ -1,6 +1,6 @@ # Dashboard -**WORKING IN PROGRESS!** +**WORKING IN PROGRESS** A dashboard is a collection of visualizations that you can use to monitor the health of your systems and applications. Dashboards are made up of one or more panels, which are the visualizations themselves. Each panel displays a single metric or a single aggregation of metrics. diff --git a/examples/membergroup/README.md b/examples/membergroup/README.md index 45e3102..6b9adb3 100644 --- a/examples/membergroup/README.md +++ b/examples/membergroup/README.md @@ -37,5 +37,4 @@ resource "guance_membergroup" "demo" { name = "oac-demo" member_ids = data.guance_members.demo.items[*].id } - ``` diff --git a/examples/membergroup/main.tf b/examples/membergroup/main.tf index 8b17c53..e5d43e9 100644 --- a/examples/membergroup/main.tf +++ b/examples/membergroup/main.tf @@ -15,4 +15,3 @@ resource "guance_membergroup" "demo" { name = "oac-demo" member_ids = data.guance_members.demo.items[*].id } - diff --git a/examples/monitor/README.md b/examples/monitor/README.md index 5edc91a..f8135f2 100644 --- a/examples/monitor/README.md +++ b/examples/monitor/README.md @@ -1,6 +1,6 @@ # Monitor -**WORKING IN PROGRESS!** +**WORKING IN PROGRESS** A monitor is a set of checks that you can run against your data. A monitor watches your data over time and alerts you when certain conditions are met. For example, you can create a monitor that watches the average response time of your website and alerts you when the response time is greater than 1 second. diff --git a/examples/mute/README.md b/examples/mute/README.md index 9cfee44..da36df4 100644 --- a/examples/mute/README.md +++ b/examples/mute/README.md @@ -33,8 +33,11 @@ variable "email" { } data "guance_members" "demo" { - emails = [ - "liyufei906@guance.com" + filter = [ + { + name = "email" + values = [var.email] + } ] } @@ -43,28 +46,60 @@ resource "guance_membergroup" "demo" { member_ids = data.guance_members.demo.items[*].id } -resource "guance_mute" "demo" { - name = "oac-demo" +resource "guance_notification" "demo" { + name = "oac-demo" + type = "ding_talk_robot" + ding_talk_robot = { + webhook = var.ding_talk_webhook + secret = var.ding_talk_secret + } +} - // mute ranges - mute_ranges { - type = "monitor" +resource "guance_alertpolicy" "demo" { + name = "oac-demo" + silent_timeout = "1h" + + statuses = [ + "critical", + "error", + "warning", + "info", + "ok", + "nodata", + "nodata_ok", + "nodata_as_ok", + ] - monitor { - id = "" + alert_targets = [ + { + type = "member_group" + member_group = { + id = guance_membergroup.demo.id + } + }, + { + type = "notification" + notification = { + id = guance_notification.demo.id + } } - } + ] +} - mute_ranges { - type = "alert_policy" +resource "guance_mute" "demo" { + // mute ranges + mute_ranges = [ + { + type = "alert_policy" - alert_policy { - id = "" + alert_policy = { + id = guance_alertpolicy.demo.id + } } - } + ] // notify options - notify { + notify = { message = < B[Alert Policy] --> C[Notification] Notes: 1. When a monitor is created, an alert policy must be selected, and the default is selected by default; -2. When a certain alert policy is deleted, the monitor under the deleted alert policy will automatically be classified into the default. \ No newline at end of file +2. When a certain alert policy is deleted, the monitor under the deleted alert policy will automatically be classified + into the default. + +## Create + +The first let me create a resource. We will send the create operation to the resource management service + +```terraform +variable "ding_talk_webhook" { + type = string +} + +variable "ding_talk_secret" { + type = string +} + +variable "email" { + type = string +} + +data "guance_members" "demo" { + filter = [ + { + name = "email" + values = [var.email] + } + ] +} + +resource "guance_membergroup" "demo" { + name = "oac-demo" + member_ids = data.guance_members.demo.items[*].id +} + +resource "guance_notification" "demo" { + name = "oac-demo" + type = "ding_talk_robot" + ding_talk_robot = { + webhook = var.ding_talk_webhook + secret = var.ding_talk_secret + } +} + +resource "guance_alertpolicy" "demo" { + name = "oac-demo" + silent_timeout = "1h" + + statuses = [ + "critical", + "error", + "warning", + "info", + "ok", + "nodata", + "nodata_ok", + "nodata_as_ok", + ] + + alert_targets = [ + { + type = "member_group" + member_group = { + id = guance_membergroup.demo.id + } + }, + { + type = "notification" + notification = { + id = guance_notification.demo.id + } + } + ] +} +``` diff --git a/internal/resources/alertpolicy/model.go b/internal/resources/alertpolicy/model.go index c449043..143ada3 100644 --- a/internal/resources/alertpolicy/model.go +++ b/internal/resources/alertpolicy/model.go @@ -13,7 +13,7 @@ type alertPolicyResourceModel struct { ID types.String `tfsdk:"id"` CreatedAt types.String `tfsdk:"created_at"` Name types.String `tfsdk:"name"` - SilentTimeout types.Int64 `tfsdk:"silent_timeout"` + SilentTimeout types.String `tfsdk:"silent_timeout"` Statuses []types.String `tfsdk:"statuses"` AlertTargets []*AlertTarget `tfsdk:"alert_targets"` } diff --git a/internal/resources/alertpolicy/schema.go b/internal/resources/alertpolicy/schema.go index e465cec..4a4f954 100644 --- a/internal/resources/alertpolicy/schema.go +++ b/internal/resources/alertpolicy/schema.go @@ -31,7 +31,7 @@ var resourceSchema = schema.Schema{ Required: true, }, - "silent_timeout": schema.Int64Attribute{ + "silent_timeout": schema.StringAttribute{ Description: "Silent timeout timestamp", Optional: true, diff --git a/internal/resources/dashboard/README.md b/internal/resources/dashboard/README.md index 47c014b..381a229 100644 --- a/internal/resources/dashboard/README.md +++ b/internal/resources/dashboard/README.md @@ -1,7 +1,19 @@ -**WORKING IN PROGRESS!** +# Dashboard + +**WORKING IN PROGRESS** A dashboard is a collection of visualizations that you can use to monitor the health of your systems and applications. Dashboards are made up of one or more panels, which are the visualizations themselves. Each panel displays a single metric or a single aggregation of metrics. Dashboards are a great way to visualize your data and monitor your systems. You can use them to track metrics over time, and to quickly see how your systems are performing. You can also use them to compare metrics from different systems and applications. Guance Cloud's dashboard is used to clearly show the range in which the metric data values are located. It is suitable for slicing messy data into points. + +## Create + +The first let me create a resource. We will send the create operation to the resource management service + +```terraform +resource "guance_dashboard" "demo" { + name = "oac-demo" +} +``` diff --git a/internal/resources/membergroup/README.md b/internal/resources/membergroup/README.md index 1238f25..6b9adb3 100644 --- a/internal/resources/membergroup/README.md +++ b/internal/resources/membergroup/README.md @@ -1,6 +1,10 @@ -Member group is a collection of members in a workspace, and member groups can be authorized to access the resources in the workspace. +# Member Group -Member group is an abstract concept, it can be a team, or a department, it can help us build a reasonable organizational structure, optimize the management efficiency and user experience of the observability platform. +Member group is a collection of members in a workspace, and member groups can be authorized to access the resources in +the workspace. + +Member group is an abstract concept, it can be a team, or a department, it can help us build a reasonable organizational +structure, optimize the management efficiency and user experience of the observability platform. Relationships: @@ -9,4 +13,28 @@ graph LR A[Workspace] --> B[Member] A --> C[MemberGroup] -``` \ No newline at end of file +``` + +## Create + +The first let me create a resource. We will send the create operation to the resource management service + +```terraform +variable "email" { + type = string +} + +data "guance_members" "demo" { + filter = [ + { + name = "email" + values = [var.email] + } + ] +} + +resource "guance_membergroup" "demo" { + name = "oac-demo" + member_ids = data.guance_members.demo.items[*].id +} +``` diff --git a/internal/resources/monitor/README.md b/internal/resources/monitor/README.md index fff3f33..f8135f2 100644 --- a/internal/resources/monitor/README.md +++ b/internal/resources/monitor/README.md @@ -1,4 +1,6 @@ -**WORKING IN PROGRESS!** +# Monitor + +**WORKING IN PROGRESS** A monitor is a set of checks that you can run against your data. A monitor watches your data over time and alerts you when certain conditions are met. For example, you can create a monitor that watches the average response time of your website and alerts you when the response time is greater than 1 second. @@ -13,3 +15,13 @@ graph LR A[Monitor] --> B[Alert Policy] --> C[Notification] ``` + +## Create + +The first let me create a resource. We will send the create operation to the resource management service + +```terraform +resource "guance_monitor" "demo" { + name = "oac-demo" +} +``` diff --git a/internal/resources/mute/README.md b/internal/resources/mute/README.md index d8e8848..da36df4 100644 --- a/internal/resources/mute/README.md +++ b/internal/resources/mute/README.md @@ -1,10 +1,155 @@ -Mute rule is a feature that allows you to temporarily stop receiving notifications for a specific alert. You can use mute rules to temporarily silence alerts that are not relevant to you, or to silence alerts that you are already aware of. +# Mute Rule -Guance Cloud supports the management of all mute rules in the current workspace. It supports muting different monitors, smart inspections, self-built inspections, SLOs, and alert policies, so that the muted objects do not send any alert notifications to any alert notification objects during the mute time. +Mute rule is a feature that allows you to temporarily stop receiving notifications for a specific alert. You can use +mute rules to temporarily silence alerts that are not relevant to you, or to silence alerts that you are already aware +of. + +Guance Cloud supports the management of all mute rules in the current workspace. It supports muting different monitors, +smart inspections, self-built inspections, SLOs, and alert policies, so that the muted objects do not send any alert +notifications to any alert notification objects during the mute time. Relationships: ```mermaid graph LR A[Mute Rule] --> B[Alert Policy] -``` \ No newline at end of file +``` + +## Create + +The first let me create a resource. We will send the create operation to the resource management service + +```terraform +variable "ding_talk_webhook" { + type = string +} + +variable "ding_talk_secret" { + type = string +} + +variable "email" { + type = string +} + +data "guance_members" "demo" { + filter = [ + { + name = "email" + values = [var.email] + } + ] +} + +resource "guance_membergroup" "demo" { + name = "oac-demo" + member_ids = data.guance_members.demo.items[*].id +} + +resource "guance_notification" "demo" { + name = "oac-demo" + type = "ding_talk_robot" + ding_talk_robot = { + webhook = var.ding_talk_webhook + secret = var.ding_talk_secret + } +} + +resource "guance_alertpolicy" "demo" { + name = "oac-demo" + silent_timeout = "1h" + + statuses = [ + "critical", + "error", + "warning", + "info", + "ok", + "nodata", + "nodata_ok", + "nodata_as_ok", + ] + + alert_targets = [ + { + type = "member_group" + member_group = { + id = guance_membergroup.demo.id + } + }, + { + type = "notification" + notification = { + id = guance_notification.demo.id + } + } + ] +} + +resource "guance_mute" "demo" { + // mute ranges + mute_ranges = [ + { + type = "alert_policy" + + alert_policy = { + id = guance_alertpolicy.demo.id + } + } + ] + + // notify options + notify = { + message = < B[Alert Policy] --> C[Notification] -``` \ No newline at end of file +``` + +## Create + +The first let me create a resource. We will send the create operation to the resource management service + +```terraform +variable "ding_talk_webhook" { + type = string +} + +variable "ding_talk_secret" { + type = string +} + +resource "guance_notification" "demo" { + name = "oac-demo" + type = "ding_talk_robot" + ding_talk_robot = { + webhook = var.ding_talk_webhook + secret = var.ding_talk_secret + } +} +``` diff --git a/internal/resources/pipeline/README.md b/internal/resources/pipeline/README.md index a15ed06..c358dd4 100644 --- a/internal/resources/pipeline/README.md +++ b/internal/resources/pipeline/README.md @@ -1,5 +1,61 @@ +# Pipeline + Pipeline is a data processing language that Observability Cloud provides. Pipeline supports text parsing of different formats of log data. By writing a pipeline script, you can customize the structure of the log and use the cut fields as attributes. -By cutting out the attribute fields, we can quickly filter the relevant logs and perform data association analysis to help us quickly locate and solve problems. \ No newline at end of file +By cutting out the attribute fields, we can quickly filter the relevant logs and perform data association analysis to help us quickly locate and solve problems. + +## Create + +The first let me create a resource. We will send the create operation to the resource management service + +```terraform +resource "guance_pipeline" "demo" { + name = "oac-demo" + category = "logging" + source = [ + "nginx" + ] + is_default = false + is_force = false + + content = <