Azure CLI를 사용하여 Microsoft Azure(WebApp)에서 Grafana 설정
6941 단어 tutorialgrafanamonitoringazure
mysql
Azure Database for MySQL single server
입니다.전제 조건:
리소스 생성:
스크립트
$ResourceGroupName = "suryarg"
$LocationName = "eastus2"
$ACRName = "suryacr"
$ACRUrl = "$ACRName.azurecr.io"
$AppServicePlan = "suryaasp"
$AppServicePlanSku = "S1"
$StorageAccountName = "suryastorageaccountsa"
$StorageAccountSku = "Standard_ZRS"
$StorageAccountShare = "suryasgrafana"
$WebAppName = "suryawagrafana"
$MYSQLServer = "suryamysql"
$MYSQLDB = "grafana"
#(Basic, Gen 5 hardware, 1 vCores).
$MYSQLServerSku = "B_Gen5_1"
$MYSQLUsername = "suryauser"
$MYSQLPassword = "surya@pass@2022"
$IP = (Invoke-WebRequest -uri "https://api.ipify.org/").Content
#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 Grafana
az webapp create --resource-group $ResourceGroupName --name $WebAppName --plan $AppServicePlan -i "$ACRUrl/grafana:SuryaLatest"
#Create MYSQL Server for Grafana Database
az mysql server create --resource-group $ResourceGroupName --name $MYSQLServer --location $LocationName --admin-user $MYSQLUsername --admin-password $MYSQLPassword --sku-name $MYSQLServerSku --storage-size 5120
#Create MYSQL Database
az mysql db create --resource-group $ResourceGroupName --server-name $MYSQLServer --name $MYSQLDB
#Create Storage Mount for Grafana 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 "grafana" --storage-type "AzureFiles" --share-name $StorageAccountShare --account-name $StorageAccountName --access-key $storageaccountkey --mount-path "/var/lib/grafana"
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 "/etc/grafana"
az webapp config storage-account add --resource-group $ResourceGroupName --name $WebAppName --custom-id "log" --storage-type "AzureFiles" --share-name $StorageAccountShare --account-name $StorageAccountName --access-key $storageaccountkey --mount-path "/var/log/grafana"
#Set an Environment Variable for Grafana WebApp
$envg0 = "mysql"
az webapp config appsettings set --resource-group $ResourceGroupName --name $WebAppName --settings GF_DATABASE_TYPE=$envg0
$envg1 = "mysql://$($MYSQLUsername)@$($MYSQLServer):$($MYSQLPassword)@$($MYSQLServer).mysql.database.azure.com:3306/$($MYSQLDB)"
az webapp config appsettings set --resource-group $ResourceGroupName --name $WebAppName --settings GF_DATABASE_URL=$envg1
$envg2="/etc/grafana/custom.ini"
az webapp config appsettings set --resource-group $ResourceGroupName --name $WebAppName --settings GF_PATHS_CONFIG=$envg2
$envg3="console file"
az webapp config appsettings set --resource-group $ResourceGroupName --name $WebAppName --settings GF_LOG_MODE=$envg3
$envg4="/var/log/grafana"
az webapp config appsettings set --resource-group $ResourceGroupName --name $WebAppName --settings GF_PATHS_LOGS=$envg4
az webapp config appsettings set --resource-group $ResourceGroupName --name $WebAppName --settings WEBSITES_PORT=3000
#Allow WebApp IP Address in MySQL Server
$WebAppAllIP = (az webapp show --resource-group $ResourceGroupName --name $WebAppName --query possibleOutboundIpAddresses --output tsv).split(",")
foreach($singleIP in $WebAppAllIP)
{
az mysql server firewall-rule create --resource-group $ResourceGroupName --server $MYSQLServer --name $WebAppAllIP.IndexOf($singleIP) --start-ip-address $singleIP --end-ip-address $singleIP
}
#Allow Current IP Address in MySQL Server
az mysql server firewall-rule create --resource-group $ResourceGroupName --server $MYSQLServer --name AllowMyIP --start-ip-address $IP --end-ip-address $IP
출력 :
_____________________________________엑스______________________________________
Reference
이 문제에 관하여(Azure CLI를 사용하여 Microsoft Azure(WebApp)에서 Grafana 설정), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/suryabhansv/setup-grafana-in-microsoft-azure-webapp-using-azure-cli-493p텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)