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

opentelekomcloud_ces_alarmrule not allowed to create alert rules where the metric_name starts with "/" for Linux mount points. #2078

Open
thople opened this issue Feb 7, 2023 · 6 comments
Labels

Comments

@thople
Copy link

thople commented Feb 7, 2023

Terraform provider version

Terraform v1.3.7

Affected Resource(s)

"opentelekomcloud_ces_alarmrule"

Terraform Configuration Files

resource "opentelekomcloud_ces_alarmrule" "disk_usage" {
alarm_name = "alert-name"
alarm_action_enabled = true
metric {
namespace = "SYS.ECS"
metric_name = "/_disk_usedPercent"
dimensions {
name = "instance_id"
value = data.opentelekomcloud_compute_instance_v2.instance.id
}
}
condition {
period = 1
filter = "sum"
comparison_operator = ">="
value = 90
unit = "%"
count = 3
}
}

Debug Output/Panic Output

│ Error: invalid value for metric.0.metric_name (Must start with a letter.)

│ with module.cloudeye-alert.opentelekomcloud_ces_alarmrule.disk_usage,
│ on ../../../modules/main.tf line 87, in resource "opentelekomcloud_ces_alarmrule" "disk_usage":
│ 87: metric_name = "/_disk_usedPercent"

Steps to Reproduce

  1. 'create an alart rule with metric_name that starts with "/" like for example:
    metric_name = "/_disk_usedPercent" or metric_name = "/opt_disk_usedPercent"
  2. terraform apply

Expected Behavior

Should allow creating alartrule Terraform that starts with "/" for Linux mount points.
Like this in the interface. (added manual in interface)
screenshot alart policy

Actual Behavior

It forces creating alert rules that start with a letter. It will create the alert if you add a letter, but this won't work for Linux. Furthermore, it's written in the web interface behind the "?" at Mount point option to add it with "/":
· For a Windows OS, enter a drive letter, such as C, D, or E.
· For a Linux OS, enter a mount point, such as /dev or /opt.

@anton-sidelnikov anton-sidelnikov self-assigned this Feb 10, 2023
otc-zuul bot pushed a commit that referenced this issue Feb 10, 2023
…es_alarmrule` (#2084)

[CES] support slashes for metric name in `resource/opentelekomcloud_ces_alarmrule`

Summary of the Pull Request
PR Checklist

 Refers to: #2078
 Tests added/passed.
 Documentation updated.
 Schema updated.
 Release notes added.

Acceptance Steps Performed
=== RUN   TestCESAlarmRule_basic
=== PAUSE TestCESAlarmRule_basic
=== CONT  TestCESAlarmRule_basic
--- PASS: TestCESAlarmRule_basic (150.95s)
=== RUN   TestAccCheckCESV1AlarmValidation
--- PASS: TestAccCheckCESV1AlarmValidation (22.09s)
=== RUN   TestCESAlarmRule_slashes
=== PAUSE TestCESAlarmRule_slashes
=== CONT  TestCESAlarmRule_slashes
--- PASS: TestCESAlarmRule_slashes (103.15s)
PASS

Process finished with the exit code 0

Reviewed-by: Artem Lifshits
Reviewed-by: Aloento
@anton-sidelnikov
Copy link
Member

@thople hi, please check on latest

@thople
Copy link
Author

thople commented Feb 24, 2023

@anton-sidelnikov hi, thank you for the quick fix.

I tested but there is still a bug in it.

What happens is that it creates the alarm rule just as it should be, but it won't work.
The only way to make it work is to manually go into the interface, modify it, and then save it again. For some reason, it then creates a second alert rule that is exactly the same in the interface, but this one works while the one created with Terraform doesn't.

@anton-sidelnikov
Copy link
Member

@thople hm, seems another bug, will ask QA team

@anton-sidelnikov
Copy link
Member

@thople could you show some pictures what exact not working in rule?

I created that in latest provider:

resource "opentelekomcloud_compute_instance_v2" "vm_1" {
  name        = "instance_1"
  image_name  = "Standard_Debian_11_latest"
  flavor_name = "s3.large.2"

  network {
    uuid = data.opentelekomcloud_vpc_subnet_v1.shared_subnet.network_id
  }
}

resource "opentelekomcloud_ces_alarmrule" "alarmrule_s" {
  alarm_name = "alarm_rule_s"

  metric {
    namespace   = "SYS.ECS"
    metric_name = "/mnt/share_disk_usedPercent"
    dimensions {
      name  = "instance_id"
      value = opentelekomcloud_compute_instance_v2.vm_1.id
    }
  }
  condition {
    period              = 1
    filter              = "sum"
    comparison_operator = ">="
    value               = 90
    unit                = "%%"
    count               = 3
  }
  alarm_action_enabled = false
}

image

@thople
Copy link
Author

thople commented Feb 24, 2023

@anton-sidelnikov

What I did to test the alarm rule was creating an alarm rule for the EC2 instance, just as you can see in the Terraform code I shared. After that, I created a file that fills the disk on the "/" mount point (/_disk_usedPercent) above the 90% threshold. If you look in the Alarm Records, it should trigger an alarm like this, but this is not the case for Terraform created alarm rules.
OTC ec2 alarm record

@anton-sidelnikov
Copy link
Member

@thople Thank you, yes seems api works differently from UI, created internal issue for backend team:
https://jira.tsi-dev.otc-service.com/browse/BM-1550

@anton-sidelnikov anton-sidelnikov added the otc-issue Blocked by OTC issues label Feb 24, 2023
@anton-sidelnikov anton-sidelnikov removed their assignment May 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants