Skip to content

Instantly share code, notes, and snippets.

@sqlwatch
sqlwatch / aggregation periods.m
Last active January 22, 2020 17:36
Power BI Aggregation Periods
>= 8760 then [day] //if window >= 1 year, aggregate over 1 day
>= 168 then [1_hour] //if window >= 1 week, aggregate over 1 hour
> 24 then [15_minutes] //if window > 24 hours, aggregate over 15 minutes
> 1 then [5_minutes] //if window > 1 hour, aggregate over 5 minutes
> 0 then [time] //if window > 0 hours, no aggregation
@sqlwatch
sqlwatch / check free space percentage.sql
Created January 24, 2020 21:42
SQLWATCH check free space percentage
select @output=min(free_space_percentage)
from dbo.vw_sqlwatch_report_dim_os_volume
where sql_instance = @@SERVERNAME
and free_space_percentage is not null
@sqlwatch
sqlwatch / action sp_send_dbmail.sql
Created January 24, 2020 23:27
SQLWATCH Action Send Email
exec msdb.dbo.sp_send_dbmail
@recipients = 'dba@yourcompany.com',
@subject = '{SUBJECT}',
@body = '{BODY}',
@profile_name='SQLWATCH',
@body_format = 'HTML'
@sqlwatch
sqlwatch / action Send-MailMessage.ps1
Created January 24, 2020 23:28
SQLWATCH Action Send Email PS
Send-MailMessage `
-From 'DBA <dba@yourcompany.com>' `
-To 'dba@yourcompany.com' `
-Subject "{SUBJECT}" `
-Body "{BODY}" `
-SmtpServer "smtp.yourcompany.com"
@sqlwatch
sqlwatch / action http pushover call.ps1
Last active January 24, 2020 23:30
SQLWATCH Action HTTP Call
$uri = "https://api.pushover.net/1/messages.json"
$parameters = @{
token = "YOUR_TOKEN"
user = "USER_TOKEN"
message = "{SUBJECT} {BODY}"
}
$parameters | Invoke-RestMethod -Uri $uri -Method Post
@sqlwatch
sqlwatch / action save file.ps1
Last active January 25, 2020 00:23
SQLWATCH Action Save File
"{BODY}" | Out-File -FilePath \\yourshare\Folder\trigger.dat
@sqlwatch
sqlwatch / action send to azure.ps1
Created January 24, 2020 23:32
SQLWATCH Send to Azure Log Monitor
Invoke-Sqlcmd `
-ServerInstance localhost `
-Database SQLWATCH `
-Query "{BODY}" `
| C:SQLWATCHPSUpload-AzMonitorLog.ps1 `
-WorkspaceId YOURWORKSPACEID `
-WorkspaceKey YOURWORKSPACEKEY `
-LogTypeName "{SUBJECT}" `
-AddComputerName
@sqlwatch
sqlwatch / install with dbatools.ps1
Created January 25, 2020 16:32
SQLWATCH Install with dbatools
Install-DbaSqlWatch -SqlInstance SQLSERVER1,SQLSERVER2,SQLSERVER3 -Database SQLWATCH