Azure CLI를 사용하여 Microsoft Azure(Web App)에서 Blackbox Exporter 설정

목표 :
  • Azure CLI를 사용하여 Microsoft Azure에서 Blackbox Exporter WebApp 생성

  • 전제 조건:


  • 리소스 생성:
  • App Service 플랜
  • 스토리지 계정
  • 앱 서비스

  • 스크립트

    $ResourceGroupName      = "suryarg"
    $LocationName           = "eastus2"
    $ACRName                = "suryacr"
    $ACRUrl                 = "$ACRName.azurecr.io"
    
    $AppServicePlan         = "suryaasp"
    $AppServicePlanSku      = "S1"
    $StorageAccountName     = "suryastorageaccountsa"
    $StorageAccountSku      = "Standard_ZRS"
    $StorageAccountShare    = "suryasblackboxexporter"
    $WebAppName             = "suryawablackboxexporter"
    



    #Create App Service Plan
    az appservice plan create --resource-group $ResourceGroupName --name $AppServicePlan --is-linux --sku $AppServicePlanSku    
    
    #Create a Storage Account
    az storage account create --resource-group $ResourceGroupName --name $StorageAccountName --kind StorageV2 --sku $StorageAccountSku
    
    #Create an Storage Account File Share
    az storage share-rm create --resource-group $ResourceGroupName --storage-account $StorageAccountName --name $StorageAccountShare --access-tier "TransactionOptimized" --quota 64
    
    #Create an Webapp for blackboxexporter
    az webapp create --resource-group $ResourceGroupName --name $WebAppName --plan $AppServicePlan -i "$ACRUrl/blackbox-exporter:SuryaLatest"
    



    #Create Storage Mount for blackboxexporter WebApp
    $storageaccountkey  =   $(az storage account keys list --resource-group $ResourceGroupName --account-name $StorageAccountName --query [0].value -o tsv)
    
    az webapp config storage-account add --resource-group $ResourceGroupName --name $WebAppName --custom-id "config" --storage-type "AzureFiles" --share-name $StorageAccountShare --account-name $StorageAccountName --access-key $storageaccountkey  --mount-path "/config/"
    



    #Set an Environment Variable for blackboxexporter WebApp
    az webapp config appsettings set --resource-group $ResourceGroupName --name $WebAppName --settings WEBSITES_PORT=9115
    
    #Set an Startup Commmand for blackboxexporter WebApp
    az webapp config set --name $WebAppName --resource-group $ResourceGroupName --startup-file `
    "--config.file=/config/blackbox.yml"
    


  • blackbox.yml (suryasblackboxexporter 스토리지 계정 공유에 이 파일 업로드)

  • modules:
      http_2xx:
        prober: http
      http_post_2xx:
        prober: http
        http:
          method: POST
      tcp_connect:
        prober: tcp
      pop3s_banner:
        prober: tcp
        tcp:
          query_response:
          - expect: "^+OK"
          tls: true
          tls_config:
            insecure_skip_verify: false
      grpc:
        prober: grpc
        grpc:
          tls: true
          preferred_ip_protocol: "ip4"
      grpc_plain:
        prober: grpc
        grpc:
          tls: false
          service: "service1"
      ssh_banner:
        prober: tcp
        tcp:
          query_response:
          - expect: "^SSH-2.0-"
          - send: "SSH-2.0-blackbox-ssh-check"
      irc_banner:
        prober: tcp
        tcp:
          query_response:
          - send: "NICK prober"
          - send: "USER prober prober prober :prober"
          - expect: "PING :([^ ]+)"
            send: "PONG ${1}"
          - expect: "^:[^ ]+ 001"
      icmp:
        prober: icmp
      icmp_ttl5:
        prober: icmp
        timeout: 5s
        icmp:
          ttl: 5
    






    출력 :





    좋은 웹페이지 즐겨찾기