terraform-provider-mackerel 2초(+)로 URL 외형 모니터링α)개시하다

10423 단어 TerraformMackereltech
이 항목은 Mackerel Ambassador의 기사인 8입니다.
오래간만😅 일람표여기.
며칠 전GitHub Pages에 작은 페이지[1]에 만들어졌기 때문에 URL의 외형 감시를 넣고 싶습니다.
하지만 그렇게 많지는 않지만, 다 손에 넣는 건 좀 싫다.
수동으로 폼 팩터 모니터링을 설정할 때 STEPS 따르기

모니터링 규칙 추가

모양새 모니터링 설정 1

모양새 모니터링 설정 2

모양새 모니터링 설정 2.2
나는 조금 상상해 보았다.숫자가 100이 되면 구하기 싫을 거야.
그래서 알파가 공개한v0.0.1-alpha20210507을 사용하기로 했습니다.
https://github.com/mackerelio-labs/terraform-provider-mackerel/releases/

준비: 공급업체의 로컬 설정 사용자 정의


의외로terraform-provider-mackerel은 현재(2021/5/9)에https://registry.terraform.io/browse/providers에 등록되지 않았기 때문에 로컬에서 사용해야 합니다.
이전의 terraform 0.1.229 gmail Filter를 활용한 경험[2]을 바탕으로 최신 terraform 0.153terraform init을 사용하려면 실패한다.
잘못된 정보로 공식 문서를 검색하거나 찾아보면 어떻게 설정해야 하는지 알겠지만-plugin-dir 옵션이 성공한 사례를 찾기 전에???상태.정말 고마워요, 선배.
https://www.terraform.io/docs/cli/config/config-file.html#provider-installation
https://sioncojp.hateblo.jp/entry/2020/10/13/195117
나는 검증된 것을 코드로 정리하고 준비 절차를 자신의 창고에 썼다.이용자의 참고가 됐으면 좋겠어요.
나는 포인트가 아래 두 점이라고 생각한다.
  • ${WorkingDirectory}/.terraform/plugins/registry.terraform.io/mackerel/mackerel/X.X.X/darwin_amd64/에 바이너리 배치
  • terraform init -plugin-dir=${PWD}/.terraform/plugins처럼 지정-plugin-dir
  • https://github.com/sogaoh/mackerel-practice/tree/master/terraform-provider/monitor/external#pre-requirements

    실행: 2초 만에 완성 (너무 빨라) 깜짝이야


    실행 중인 콘솔 출력입니다.
    terraform init , plan
    
    ❯ terraform init -plugin-dir=${PWD}/.terraform/plugins
    
    Initializing the backend...
    
    Initializing provider plugins...
    - Finding mackerel/mackerel versions matching "~> 0.0.1"...
    - Installing mackerel/mackerel v0.0.1...
    - Installed mackerel/mackerel v0.0.1 (unauthenticated)
    
    Terraform has created a lock file .terraform.lock.hcl to record the provider
    selections it made above. Include this file in your version control repository
    so that Terraform can guarantee to make the same selections by default when
    you run "terraform init" in the future.
    
    Terraform has been successfully initialized!
    
    You may now begin working with Terraform. Try running "terraform plan" to see
    any changes that are required for your infrastructure. All Terraform commands
    should now work.
    
    If you ever set or change modules or backend configuration for Terraform,
    rerun this command to reinitialize your working directory. If you forget, other
    commands will detect it and remind you to do so if necessary.
    
    
    ❯ terraform plan
    
    Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
      + create
    
    Terraform will perform the following actions:
    
      # mackerel_monitor.ant-in-giant_github_io will be created
      + resource "mackerel_monitor" "ant-in-giant_github_io" {
          + id                    = (known after apply)
          + is_mute               = false
          + name                  = "ant-in-giant.github.io"
          + notification_interval = 0
    
          + external {
              + certification_expiration_critical = 10
              + certification_expiration_warning  = 30
              + contains_string                   = "Slide (index)"
              + max_check_attempts                = 1
              + method                            = "GET"
              + response_time_critical            = 120000
              + response_time_duration            = 3
              + response_time_warning             = 30000
              + service                           = "dev"
              + url                               = "https://ant-in-giant.github.io/slide/"
            }
        }
    
    Plan: 1 to add, 0 to change, 0 to destroy.
    
    Note: You didn't use the -out option to save this plan, so Terraform can't guarantee to take exactly these actions if you run "terraform apply" now.
    
    
    terraform apply
    (색상을 표시하려면 이미지)

    terraform apply ... complete after 2s !
    너무 빨라서 솔직히 놀랐는데 관리 화면도 반영됐어요.
    https://mackerel.io/orgs/${myOrganization}/monitors#monitor=${monitor_id}



    이후 차례대로 외형 감시를 하는 것 같다.

    또한 문서의 유지보수가 아직 끝나지 않았기 때문에 프로젝트는 코드에 따라 추측하여 지정한 것이다.나는 아마도 의도와 일치한다고 생각한다.
    https://github.com/mackerelio-labs/terraform-provider-mackerel/blob/master/mackerel/resource_mackerel_monitor.go#L169-L241
    각주
    ↩︎
    https://zenn.dev/sogaoh/articles/20-09-13-b239669609bb4145b738 ↩︎

    좋은 웹페이지 즐겨찾기