diff --git a/docs/data-sources/alert.md b/docs/data-sources/alert.md index 6795e00..cd70d7a 100644 --- a/docs/data-sources/alert.md +++ b/docs/data-sources/alert.md @@ -36,6 +36,7 @@ output "alert" { ``` + ## Schema ### Required diff --git a/docs/index.md b/docs/index.md index 090dca6..4b8159f 100644 --- a/docs/index.md +++ b/docs/index.md @@ -8,8 +8,6 @@ description: |- # signoz Provider - - ## Example Usage ```terraform @@ -19,16 +17,12 @@ provider "signoz" { ``` + ## Schema ### Optional -- `access_token` (String, Sensitive) Access token of the SigNoz API. You can retrieve it from SigNoz UI -with Admin Role ([documentation](https://signoz.io/newsroom/launch-week-1-day-5/#using-access-token)). -Also, you can set it using environment variable SIGNOZ_ACCESS_TOKEN. -- `endpoint` (String) Endpoint of the SigNoz. It is the root URL of the SigNoz UI. -Also, you can set it using environment variable SIGNOZ_ENDPOINT. If not set, it defaults to http://localhost:3301. -- `http_max_retry` (Number) Specifies the max retry limit for the HTTP requests made to SigNoz. -Also, you can set it using environment variable SIGNOZ_HTTP_MAX_RETRY. If not set, it defaults to 10. -- `http_timeout` (Number) Specifies the timeout limit in seconds for the HTTP requests made to SigNoz. -Also, you can set it using environment variable SIGNOZ_HTTP_TIMEOUT. If not set, it defaults to 35. +- `access_token` (String, Sensitive) Access token of the SigNoz API. You can retrieve it from SigNoz UI with Admin Role ([documentation](https://signoz.io/newsroom/launch-week-1-day-5/#using-access-token)). Also, you can set it using environment variable SIGNOZ_ACCESS_TOKEN. +- `endpoint` (String) Endpoint of the SigNoz. It is the root URL of the SigNoz UI. Also, you can set it using environment variable SIGNOZ_ENDPOINT. If not set, it defaults to http://localhost:3301. +- `http_max_retry` (Number) Specifies the max retry limit for the HTTP requests made to SigNoz. Also, you can set it using environment variable SIGNOZ_HTTP_MAX_RETRY. If not set, it defaults to 10. +- `http_timeout` (Number) Specifies the timeout limit in seconds for the HTTP requests made to SigNoz. Also, you can set it using environment variable SIGNOZ_HTTP_TIMEOUT. If not set, it defaults to 35. diff --git a/docs/resources/alert.md b/docs/resources/alert.md index 8a21eb0..a59b24d 100644 --- a/docs/resources/alert.md +++ b/docs/resources/alert.md @@ -115,6 +115,7 @@ output "alert_new" { ``` + ## Schema ### Required diff --git a/examples/data-sources/alert/example_1.tf b/examples/data-sources/alert/example_1.tf new file mode 100644 index 0000000..df5cd66 --- /dev/null +++ b/examples/data-sources/alert/example_1.tf @@ -0,0 +1,20 @@ +terraform { + required_providers { + signoz = { + source = "registry.terraform.io/signoz/signoz" + } + } +} + +provider "signoz" { + endpoint = "http://localhost:3301" + # access_token = "ACCESS_TOKEN" +} + +data "signoz_alert" "get_alert" { + id = "5" +} + +output "alert" { + value = data.signoz_alert.get_alert +} diff --git a/examples/example_1.tf b/examples/example_1.tf new file mode 100644 index 0000000..872ed5a --- /dev/null +++ b/examples/example_1.tf @@ -0,0 +1,3 @@ +provider "signoz" { + # example configuration here +} diff --git a/examples/resources/alert/example_1.tf b/examples/resources/alert/example_1.tf new file mode 100644 index 0000000..3047e0c --- /dev/null +++ b/examples/resources/alert/example_1.tf @@ -0,0 +1,99 @@ +terraform { + required_providers { + signoz = { + source = "registry.terraform.io/signoz/signoz" + } + } +} + +provider "signoz" { + endpoint = "http://localhost:3301" + # access_token = "ACCESS_TOKEN" +} + +resource "signoz_alert" "new_alert" { + alert = "TF Test Alert" + alert_type = "METRIC_BASED_ALERT" + broadcast_to_all = false + condition = jsonencode( + { + absentFor = 10 + alertOnAbsent = true + compositeQuery = { + builderQueries = { + A = { + ShiftBy = 0 + aggregateAttribute = { + dataType = "float64" + isColumn = true + isJSON = false + key = "k8s_node_memory_rss" + type = "Gauge" + } + aggregateOperator = "avg" + dataSource = "metrics" + disabled = false + expression = "A" + filters = { + items = [] + op = "AND" + } + groupBy = [ + { + dataType = "string" + isColumn = false + isJSON = false + key = "k8s_node_name" + type = "tag" + }, + ] + limit = 0 + offset = 0 + pageSize = 0 + queryName = "A" + reduceTo = "avg" + spaceAggregation = "avg" + stepInterval = 60 + timeAggregation = "avg" + } + } + chQueries = { + A = { + disabled = false + query = "" + } + } + panelType = "graph" + promQueries = { + A = { + disabled = false + query = "" + } + } + queryType = "builder" + unit = "bytes" + } + matchType = "1" + op = "1" + selectedQueryName = "A" + target = 10 + targetUnit = "gbytes" + } + ) + description = "Alert is fired when the defined metric (current value: {{$value}}) crosses the threshold ({{$threshold}})" + eval_window = "5m0s" + frequency = "1m0s" + labels = { + "observer" = "local-test" + } + preferred_channels = [ + "alert-test-terraform" + ] + rule_type = "threshold_rule" + severity = "info" + version = "v4" +} + +output "alert_new" { + value = signoz_alert.new_alert +} diff --git a/templates/data-sources/alert.md.tmpl b/templates/data-sources/alert.md.tmpl new file mode 100644 index 0000000..1240d35 --- /dev/null +++ b/templates/data-sources/alert.md.tmpl @@ -0,0 +1,46 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "signoz_alert Data Source - signoz" +subcategory: "" +description: |- + Fetches an alert from Signoz using its ID. The ID can be found in the URL of the alert in the Signoz UI. +--- + +{{/* This template serves as a starting point for documentation generation, and can be customized with hardcoded values and/or doc gen templates. + +For example, the {{ .SchemaMarkdown }} template can be used to replace manual schema documentation if descriptions of schema attributes are added in the provider source code. */ -}} + +# signoz_alert (Data Source) + +Fetches an alert from Signoz using its ID. The ID can be found in the URL of the alert in the Signoz UI. + +## Example Usage + +{{tffile "examples/data-sources/alert/example_1.tf"}} + + + +## Schema + +### Required + +- `id` (String) ID of the alert. + +### Read-Only + +- `alert` (String) Name of the alert. +- `alert_type` (String) Type of the alert. Possible values are: METRIC_BASED_ALERT, LOGS_BASED_ALERT, TRACES_BASED_ALERT, and EXCEPTIONS_BASED_ALERT. +- `broadcast_to_all` (Boolean) Whether to broadcast the alert to all the alert channels. +- `condition` (String) Condition of the alert. +- `description` (String) Description of the alert. +- `disabled` (Boolean) Whether the alert is disabled. +- `eval_window` (String) Evaluation window of the alert. +- `frequency` (String) Frequency of the alert. +- `labels` (Map of String) Labels of the alert. Severity is a required label. +- `preferred_channels` (List of String) List of preferred channels of the alert. This is a noop if BroadcastToAll is true. +- `rule_type` (String) Type of the Alert Rule for threshold. Possible values are: threshold_rule and promql_rule. +- `severity` (String) Severity of the alert. +- `source` (String) Source URL of the alert. +- `state` (String) State of the alert. Possible values are: inactive, firing, pending, and disabled. +- `summary` (String) Summary of the alert. +- `version` (String) Version of the alert. diff --git a/templates/index.md.tmpl b/templates/index.md.tmpl new file mode 100644 index 0000000..0955fe0 --- /dev/null +++ b/templates/index.md.tmpl @@ -0,0 +1,28 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "signoz Provider" +subcategory: "" +description: |- + +--- + +{{/* This template serves as a starting point for documentation generation, and can be customized with hardcoded values and/or doc gen templates. + +For example, the {{ .SchemaMarkdown }} template can be used to replace manual schema documentation if descriptions of schema attributes are added in the provider source code. */ -}} + +# signoz Provider + +## Example Usage + +{{tffile "examples/example_1.tf"}} + + + +## Schema + +### Optional + +- `access_token` (String, Sensitive) Access token of the SigNoz API. You can retrieve it from SigNoz UI with Admin Role ([documentation](https://signoz.io/newsroom/launch-week-1-day-5/#using-access-token)). Also, you can set it using environment variable SIGNOZ_ACCESS_TOKEN. +- `endpoint` (String) Endpoint of the SigNoz. It is the root URL of the SigNoz UI. Also, you can set it using environment variable SIGNOZ_ENDPOINT. If not set, it defaults to http://localhost:3301. +- `http_max_retry` (Number) Specifies the max retry limit for the HTTP requests made to SigNoz. Also, you can set it using environment variable SIGNOZ_HTTP_MAX_RETRY. If not set, it defaults to 10. +- `http_timeout` (Number) Specifies the timeout limit in seconds for the HTTP requests made to SigNoz. Also, you can set it using environment variable SIGNOZ_HTTP_TIMEOUT. If not set, it defaults to 35. diff --git a/templates/resources/alert.md.tmpl b/templates/resources/alert.md.tmpl new file mode 100644 index 0000000..545f8f3 --- /dev/null +++ b/templates/resources/alert.md.tmpl @@ -0,0 +1,53 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "signoz_alert Resource - signoz" +subcategory: "" +description: |- + Creates and manages alert resources in SigNoz. +--- + +{{/* This template serves as a starting point for documentation generation, and can be customized with hardcoded values and/or doc gen templates. + +For example, the {{ .SchemaMarkdown }} template can be used to replace manual schema documentation if descriptions of schema attributes are added in the provider source code. */ -}} + +# signoz_alert (Resource) + +Creates and manages alert resources in SigNoz. + +## Example Usage + +{{tffile "examples/resources/alert/example_1.tf"}} + + + +## Schema + +### Required + +- `alert` (String) Name of the alert. +- `alert_type` (String) Type of the alert. Possible values are: METRIC_BASED_ALERT, LOGS_BASED_ALERT, TRACES_BASED_ALERT, and EXCEPTIONS_BASED_ALERT. +- `condition` (String) Condition of the alert. +- `severity` (String) Severity of the alert. Possible values are: info, warning, error, and critical. + +### Optional + +- `broadcast_to_all` (Boolean) Whether to broadcast the alert to all the alerting channels. By default, the alert is only sent to the preferred channels. +- `description` (String) Description of the alert. +- `disabled` (Boolean) Whether the alert is disabled. +- `eval_window` (String) The evaluation window of the alert. By default, it is 5m0s. +- `frequency` (String) The frequency of the alert. By default, it is 1m0s. +- `labels` (Map of String) Labels of the alert. Severity is a required label. +- `preferred_channels` (List of String) Preferred channels of the alert. By default, it is empty. +- `rule_type` (String) Type of the alert. Possible values are: threshold_rule and promql_rule. +- `source` (String) Source of the alert. By default, it is /alerts. +- `summary` (String) Summary of the alert. +- `version` (String) Version of the alert. By default, it is v4. + +### Read-Only + +- `create_at` (String) Creation time of the alert. +- `create_by` (String) Creator of the alert. +- `id` (String) Autogenerated unique ID for the alert. +- `state` (String) State of the alert. +- `update_at` (String) Last update time of the alert. +- `update_by` (String) Last updater of the alert.