Author | Chrissy LeMaire (@cl) , SmartTarget by Gianluca Sartori (@spaghettidba) |
Availability | Windows, Linux, macOS |
Want to see the source code for this command? Check out Start-DbaXESmartTarget on GitHub.
Want to see the Bill Of Health for this command? Check out Start-DbaXESmartTarget.
XESmartTarget runs as a client application for an Extended Events session running on a SQL Server instance.
XESmartTarget offers the ability to set up complex actions in response to Extended Events captured in sessions, without writing a single line of code.
See more at https://github.com/spaghettidba/XESmartTarget/wiki
Start-DbaXESmartTarget
[-SqlInstance] <DbaInstanceParameter[]>
[[-SqlCredential] <PSCredential>]
[[-Database] <String>]
[-Session] <String>
[-FailOnProcessingError]
[[-Responder] <Object[]>]
[[-Template] <String[]>]
[-NotAsJob]
[-EnableException]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
PS C:\> $response = New-DbaXESmartQueryExec -SqlInstance sql2017 -Database dbadb -Query "update table set whatever = 1"
PS C:\> Start-DbaXESmartTarget -SqlInstance sql2017 -Session deadlock_tracker -Responder $response
Executes a T-SQL command against dbadb on sql2017 whenever a deadlock event is recorded.
PS C:\> $response = New-DbaXESmartQueryExec -SqlInstance sql2017 -Database dbadb -Query "update table set whatever = 1"
PS C:\> $params = @{
>> SmtpServer = "smtp.ad.local"
>> To = "[email protected]"
>> Sender = "[email protected]"
>> Subject = "Query executed"
>> Body = "Query executed at {collection_time}"
>> Attachment = "batch_text"
>> AttachmentFileName = "query.sql"
>> }
PS C:\> $emailresponse = New-DbaXESmartEmail @params
PS C:\> Start-DbaXESmartTarget -SqlInstance sql2017 -Session querytracker -Responder $response, $emailresponse
Executes a T-SQL command against dbadb on sql2017 and sends an email whenever a querytracker event is recorded.
PS C:\> $columns = "cpu_time", "duration", "physical_reads", "logical_reads", "writes", "row_count", "batch_text"
PS C:\> $response = New-DbaXESmartTableWriter -SqlInstance sql2017 -Database dbadb -Table deadlocktracker -OutputColumns $columns -Filter "duration > 10000"
PS C:\> Start-DbaXESmartTarget -SqlInstance sql2017 -Session deadlock_tracker -Responder $response
Writes Extended Events to the deadlocktracker table in dbadb on sql2017.
The target SQL Server instance or instances. You must have sysadmin access and server version must be SQL Server version 2008 or higher.
Alias | |
Required | True |
Pipeline | true (ByValue) |
Default Value |
Name of the Extended Events session to attach to.
You can monitor a single session with an instance of XESmartTarget. In case you need to perform action on multiple sessions, run an additional instance of XESmartTarget, with its own configuration
file.
Alias | |
Required | True |
Pipeline | false |
Default Value |
Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).
Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory - Integrated are all supported.
For MFA support, please use Connect-DbaInstance.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Specifies the name of the database that contains the target table.
Alias | |
Required | False |
Pipeline | false |
Default Value |
If this switch is enabled, the a processing error will trigger a failure.
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
The list of responses can include zero or more Response objects, each to be configured by specifying values for their public members.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Path to the dbatools built-in templates
Alias | |
Required | False |
Pipeline | false |
Default Value |
If this switch is enabled, output will be sent to screen indefinitely. BY default, a job will be run in the background.
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting.
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
If this switch is enabled, no actions are performed but informational messages will be displayed that explain what would happen if the command were to run.
Alias | wi |
Required | False |
Pipeline | false |
Default Value |
If this switch is enabled, you will be prompted for confirmation before executing any operations that change state.
Alias | cf |
Required | False |
Pipeline | false |
Default Value |