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

cloudprovider: update regions behavior for cloudwatch jobs #1846

Open
wants to merge 4 commits into
base: tf-cloud-provider-aws-app
Choose a base branch
from

Conversation

tristanburgess
Copy link

This PR implements the Terraform changes needed to accommodate the breaking out of request and response models for CloudWatch scrape jobs. It supports the regionsSubsetOverride field on request, and the return of roleARN, regions, and regionsSubsetOverrideUsed on response.

regionsSubsetOverride not used (default account regions used)

scrape_job = {
  "aws_account_resource_id" = "2"
  "custom_namespace" = tolist([
    {
      "metric" = tolist([
        {
          "name" = "CoolMetric"
          "statistics" = toset([
            "Maximum",
            "Sum",
          ])
        },
      ])
      "name" = "CoolApp"
      "scrape_interval_seconds" = 300
    },
  ])
  "disabled_reason" = ""
  "enabled" = true
  "export_tags" = true
  "id" = "1:my-cloudwatch-scrape-job"
  "name" = "my-cloudwatch-scrape-job"
  "regions_subset_override" = toset([])
  "service" = tolist([
    {
      "metric" = tolist([
        {
          "name" = "CPUUtilization"
          "statistics" = toset([
            "Average",
          ])
        },
        {
          "name" = "StatusCheckFailed"
          "statistics" = toset([
            "Maximum",
          ])
        },
      ])
      "name" = "AWS/EC2"
      "resource_discovery_tag_filter" = tolist([
        {
          "key" = "k8s.io/cluster-autoscaler/enabled"
          "value" = "true"
        },
      ])
      "scrape_interval_seconds" = 300
      "tags_to_add_to_metrics" = toset([
        "eks:cluster-name",
      ])
    },
  ])
  "stack_id" = "1"
}
scrape_job_data = {
  "aws_account_resource_id" = "2"
  "custom_namespace" = tolist([
    {
      "metric" = tolist([
        {
          "name" = "CoolMetric"
          "statistics" = toset([
            "Maximum",
            "Sum",
          ])
        },
      ])
      "name" = "CoolApp"
      "scrape_interval_seconds" = 300
    },
  ])
  "disabled_reason" = ""
  "enabled" = true
  "export_tags" = true
  "id" = "1:my-cloudwatch-scrape-job"
  "name" = "my-cloudwatch-scrape-job"
  "regions" = toset([
    "ap-southeast-1",
    "eu-west-3",
    "us-east-2",
  ])
  "regions_subset_override_used" = false
  "role_arn" = "arn:aws:iam<removed for PR text>"
  "service" = tolist([
    {
      "metric" = tolist([
        {
          "name" = "CPUUtilization"
          "statistics" = toset([
            "Average",
          ])
        },
        {
          "name" = "StatusCheckFailed"
          "statistics" = toset([
            "Maximum",
          ])
        },
      ])
      "name" = "AWS/EC2"
      "resource_discovery_tag_filter" = tolist([
        {
          "key" = "k8s.io/cluster-autoscaler/enabled"
          "value" = "true"
        },
      ])
      "scrape_interval_seconds" = 300
      "tags_to_add_to_metrics" = toset([
        "eks:cluster-name",
      ])
    },
  ])
  "stack_id" = "1"
}

regionsSubsetOverride used

scrape_job = {
  "aws_account_resource_id" = "2"
  "custom_namespace" = tolist([
    {
      "metric" = tolist([
        {
          "name" = "CoolMetric"
          "statistics" = toset([
            "Maximum",
            "Sum",
          ])
        },
      ])
      "name" = "CoolApp"
      "scrape_interval_seconds" = 300
    },
  ])
  "disabled_reason" = "disabled_by_user"
  "enabled" = false
  "export_tags" = true
  "id" = "1:my-cloudwatch-scrape-job"
  "name" = "my-cloudwatch-scrape-job"
  "regions_subset_override" = toset([
    "eu-west-3",
    "us-east-2",
  ])
  "service" = tolist([
    {
      "metric" = tolist([
        {
          "name" = "CPUUtilization"
          "statistics" = toset([
            "Average",
          ])
        },
        {
          "name" = "StatusCheckFailed"
          "statistics" = toset([
            "Maximum",
          ])
        },
      ])
      "name" = "AWS/EC2"
      "resource_discovery_tag_filter" = tolist([
        {
          "key" = "k8s.io/cluster-autoscaler/enabled"
          "value" = "true"
        },
      ])
      "scrape_interval_seconds" = 300
      "tags_to_add_to_metrics" = toset([
        "eks:cluster-name",
      ])
    },
  ])
  "stack_id" = "1"
}
scrape_job_data = {
  "aws_account_resource_id" = "2"
  "custom_namespace" = tolist([
    {
      "metric" = tolist([
        {
          "name" = "CoolMetric"
          "statistics" = toset([
            "Maximum",
            "Sum",
          ])
        },
      ])
      "name" = "CoolApp"
      "scrape_interval_seconds" = 300
    },
  ])
  "disabled_reason" = "disabled_by_user"
  "enabled" = false
  "export_tags" = true
  "id" = "1:my-cloudwatch-scrape-job"
  "name" = "my-cloudwatch-scrape-job"
  "regions" = toset([
    "eu-west-3",
    "us-east-2",
  ])
  "regions_subset_override_used" = true
  "role_arn" = "arn:aws:iam<removed for PR text>"
  "service" = tolist([
    {
      "metric" = tolist([
        {
          "name" = "CPUUtilization"
          "statistics" = toset([
            "Average",
          ])
        },
        {
          "name" = "StatusCheckFailed"
          "statistics" = toset([
            "Maximum",
          ])
        },
      ])
      "name" = "AWS/EC2"
      "resource_discovery_tag_filter" = tolist([
        {
          "key" = "k8s.io/cluster-autoscaler/enabled"
          "value" = "true"
        },
      ])
      "scrape_interval_seconds" = 300
      "tags_to_add_to_metrics" = toset([
        "eks:cluster-name",
      ])
    },
  ])
  "stack_id" = "1"
}

@tristanburgess tristanburgess requested review from a team as code owners October 15, 2024 12:28
Copy link

In order to lower resource usage and have a faster runtime, PRs will not run Cloud tests automatically.
To do so, a Grafana Labs employee must trigger the cloud acceptance tests workflow manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant