Issue:
I got multiple databricks work space and received many complaints from end user on availability. Also as a admin, i was not aware or notified any availability issue in advance.
Solution:
To overcome this communication gap, i have written a powershell script to check databricks work space for every 5 minutes and notify me when service is not reachable or accessible.
Powershell Script:
clear
Try
{
#Install-Module -Name
DatabricksPS
$Out
= 0
$accessToken
= "Admin
Access Token "
$apiUrl
= "https://XYZ.azuredatabricks.net"
Set-DatabricksEnvironment
-AccessToken $accessToken
-ApiRootUrl $apiUrl
-ErrorAction Stop
Get-DatabricksJobRun
-JobID 17410 | Get-DatabricksJobRunOutput
-ErrorAction Stop
}
catch
{
Write-Output
"Something threw an exception"
$emailSmtpServer
= "mailrelay.xyz.com"
$emailFrom
= “databricks@xyz.com"
$recipients
= "user@xyz.com"
$emailSubject
= "Alert!
List of DataBricks Environment Unavailable"
$message
= " Kindly
check this environment availability - $apiUrl - Here is the
message $_.Exception.Message"
[string[]]$emailTo = $recipients.Split(',')
Send-MailMessage
-To $emailTo
-From $emailFrom
-Subject $emailSubject
-Body $message
-SmtpServer $emailSmtpServer
}