Skip to content

Commit 88c9e9b

Browse files
ConvertTo-DbaTimeline - Add support for Find-DbaDbGrowthEvent input
Adds detection and mapping for Find-DbaDbGrowthEvent output so that database auto-growth and auto-shrink events can be visualized as a timeline chart. Event classes are mapped to human-readable labels (Data Grow, Log Grow, Data Shrink, Log Shrink) with green for growth events and orange for shrink events. Closes #8055 (do ConvertTo-DbaTimeline) Co-authored-by: Andreas Jordan <andreasjordan@users.noreply.github.com>
1 parent 97d03be commit 88c9e9b

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

public/ConvertTo-DbaTimeline.ps1

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
function ConvertTo-DbaTimeline {
22
<#
33
.SYNOPSIS
4-
Generates interactive HTML timeline visualizations from SQL Server job history and backup history data
4+
Generates interactive HTML timeline visualizations from SQL Server job history, backup history, and database growth event data
55
66
.DESCRIPTION
7-
Transforms SQL Server job execution and backup operation data into visual timeline reports for analysis and troubleshooting. Takes piped output from Get-DbaAgentJobHistory and Get-DbaDbBackupHistory and generates a complete HTML file with an interactive Google Charts timeline.
7+
Transforms SQL Server job execution, backup operation, and database growth event data into visual timeline reports for analysis and troubleshooting. Takes piped output from Get-DbaAgentJobHistory, Get-DbaDbBackupHistory, or Find-DbaDbGrowthEvent and generates a complete HTML file with an interactive Google Charts timeline.
88
9-
Perfect for analyzing job schedules, identifying backup windows, troubleshooting overlapping operations, or creating visual reports for management. The timeline shows execution duration, status, and timing relationships across multiple instances, with hover tooltips displaying detailed information including start/end times and duration calculations.
9+
Perfect for analyzing job schedules, identifying backup windows, visualizing auto-growth events, troubleshooting overlapping operations, or creating visual reports for management. The timeline shows execution duration, status, and timing relationships across multiple instances, with hover tooltips displaying detailed information including start/end times and duration calculations.
1010
1111
Output is a self-contained HTML file that can be viewed in any browser, emailed to stakeholders, or archived for historical analysis. Supports both single and multi-instance scenarios with automatic labeling and color-coded status indicators.
1212
1313
.PARAMETER InputObject
14-
Specifies the SQL Server data to convert into timeline visualization. Accepts piped output from Get-DbaAgentJobHistory or Get-DbaDbBackupHistory.
15-
Use this to transform job execution history or backup operation data into an interactive HTML timeline chart.
14+
Specifies the SQL Server data to convert into timeline visualization. Accepts piped output from Get-DbaAgentJobHistory, Get-DbaDbBackupHistory, or Find-DbaDbGrowthEvent.
15+
Use this to transform job execution history, backup operation data, or database auto-growth/shrink events into an interactive HTML timeline chart.
1616
The function automatically detects the input type and formats the timeline appropriately with status colors and duration calculations.
1717
1818
.PARAMETER ExcludeRowLabel
@@ -61,6 +61,11 @@ function ConvertTo-DbaTimeline {
6161
6262
Creates an output file containing a pretty timeline for the agent job history since 2018-08-13 for all of the registered servers on sqlcm
6363
64+
.EXAMPLE
65+
PS C:\> Find-DbaDbGrowthEvent -SqlInstance sql-1 | ConvertTo-DbaTimeline | Out-File C:\temp\DbaDbGrowthEvent.html -Encoding ASCII
66+
67+
Creates an output file containing a timeline of all database auto-growth and auto-shrink events for sql-1.
68+
6469
.EXAMPLE
6570
PS C:\> $messageParameters = @{
6671
>> Subject = "Backup history for sql2017 and sql2016"
@@ -164,6 +169,9 @@ function ConvertTo-DbaTimeline {
164169
} elseif ($InputObject[0] -is [Dataplat.Dbatools.Database.BackupHistory]) {
165170
$CallerName = " Get-DbaDbBackupHistory"
166171
$data = $InputObject | Select-Object @{ Name = "SqlInstance"; Expression = { $_.SqlInstance } }, @{ Name = "InstanceName"; Expression = { $_.InstanceName } }, @{ Name = "vLabel"; Expression = { "[" + $($_.SqlInstance -replace "\\", "\\\") + "] " + $_.Database } }, @{ Name = "hLabel"; Expression = { $_.Type } }, @{ Name = "StartDate"; Expression = { $(ConvertTo-JsDate($_.Start)) } }, @{ Name = "EndDate"; Expression = { $(ConvertTo-JsDate($_.End)) } }
172+
} elseif ($null -ne $InputObject[0].PSObject.Properties['EventClass'] -and $null -ne $InputObject[0].PSObject.Properties['ChangeInSize']) {
173+
$CallerName = "Find-DbaDbGrowthEvent"
174+
$data = $InputObject | Select-Object @{ Name = "SqlInstance"; Expression = { $_.SqlInstance } }, @{ Name = "InstanceName"; Expression = { $_.InstanceName } }, @{ Name = "vLabel"; Expression = { "[" + $($_.SqlInstance -replace "\\", "\\\") + "] " + $_.DatabaseName } }, @{ Name = "hLabel"; Expression = { switch ([int]$_.EventClass) { 92 { "Data Grow" } 93 { "Log Grow" } 94 { "Data Shrink" } 95 { "Log Shrink" } default { "Unknown" } } } }, @{ Name = "Style"; Expression = { if ([int]$_.EventClass -in 92, 93) { "#36B300" } else { "#FF8C00" } } }, @{ Name = "StartDate"; Expression = { $(ConvertTo-JsDate($_.StartTime)) } }, @{ Name = "EndDate"; Expression = { $(ConvertTo-JsDate($_.EndTime)) } }
167175
} else {
168176
# sorry to be so formal, can't help it ;)
169177
Stop-Function -Message "Unsupported input data. To request support for additional commands, please file an issue at dbatools.io/issues and we'll take a look"

0 commit comments

Comments
 (0)