Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New commands to output results to file and database and New Power Bi File #727

Merged
merged 85 commits into from
May 9, 2020

Conversation

SQLDBAWithABeard
Copy link
Collaborator

@SQLDBAWithABeard SQLDBAWithABeard commented Dec 27, 2019

OK This is a big change, so I would like some feedback on this before it gets merged.

There are some bug fixes to checks that I found along the way but the important stuff is

New Commands

I have added

  • Convert-DbcResult
    This will take the out put of Invoke-DbcCheck WITH THE -PassThru parameter :-) and convert the output to a PowerShell object that looks like this
Date           : 27/12/2019 13:40:20
Label          : Morning-Checks
Describe       : Future File Growth
Context        : Testing for files likely to grow soon
Name           : Database msdb file MSDBData has free space under threshold
Database       : msdb
ComputerName   : SQL2019N5
Instance       : SQL2019N5\DAVE
Result         : Failed
FailureMessage : Expected the actual value to be greater than or equal to 10, because free space within the file should be lower than threshold of 10 %, but got 5.932.

The label is a way of defining a group of checks (like the environmenttag for Update-DbcPowerBiDataSource)

You can try it with

Invoke-DbcCheck -SqlInstance INSTANCE -Check CHECK -PassThru | Convert-DbcResult -Label Some-Label
  • Set-DbcFile
    This command will take an object from Convert-DbcResult and either save to a file or add to a file of type CSV, JSON or XML

You can try it with

Invoke-DbcCheck -SqlInstance SQLINSTANCE -Check AutoClose -Show Fails -PassThru|Convert-DbcResult -Label 'Some-Label' | Set-DbcFile -FilePath C:\temp\dbachecks\ -FileName Auto-close.json -FileType Json 

or by setting the output of the checks to a variable and piping that

$Tests = Invoke-DbcCheck -Check AutoClose -Show Fails -PassThru
$Tests |Convert-DbcResult -Label 'Some-Label' | Set-DbcFile -FilePath C:\temp\dbachecks\ -FileName Auto-close.json -FileType Json 
$Tests |Convert-DbcResult -Label 'Some-Label' | Set-DbcFile -FilePath C:\temp\dbachecks\ -FileName Auto-close.csv -FileType CSV 
$Tests |Convert-DbcResult -Label 'Some-Label' | Set-DbcFile -FilePath C:\temp\dbachecks\ -FileName Auto-close.xml -FileType XML
$Tests |Convert-DbcResult -Label 'Some-Label' | Set-DbcFile -FilePath C:\temp\dbachecks\ -FileName Auto-close.json -FileType Json -Force
$Tests |Convert-DbcResult -Label 'Some-Label' | Set-DbcFile -FilePath C:\temp\dbachecks\ -FileName Auto-close.csv -FileType CSV -Force 
$Tests |Convert-DbcResult -Label 'Some-Label' | Set-DbcFile -FilePath C:\temp\dbachecks\ -FileName Auto-close.xml -FileType XML -Force
$Tests |Convert-DbcResult -Label 'Some-Label' | Set-DbcFile -FilePath C:\temp\dbachecks\ -FileName Auto-close.json -FileType Json -Append
$Tests |Convert-DbcResult -Label 'Some-Label' | Set-DbcFile -FilePath C:\temp\dbachecks\ -FileName Auto-close.csv -FileType CSV -Append
$Tests |Convert-DbcResult -Label 'Some-Label' | Set-DbcFile -FilePath C:\temp\dbachecks\ -FileName Auto-close.xml -FileType XML -Append
  • Write-DbcTable
    This command will take the output of Convert-DbcResult and write it to a database table - It will also take the output of Get-DbcCheck and place that in a table called dbachecksChecks (This is required for the new pbix

You can try it with

$Tests = Invoke-DbcCheck -Check AutoClose -Show Fails -PassThru |Convert-DbcResult -Label 'Some-Label' | Write-DbcTable -SqlInstance SQL2017N5 -Database tempdb -Table SomeLabelChecks 

I have also added a new PowerBi to the repo under \bin which I would really like some clever people to make more beautiful!

Here is what I have so far - The data comes from the database created by Write-DbcTable

https://app.powerbi.com/reportEmbed?reportId=48d7902f-f3d6-4d46-9308-bce4aeda14eb&autoAuth=true&ctid=b122247e-1ebf-4b52-b309-c2aa7436fc6b&config=eyJjbHVzdGVyVXJsIjoiaHR0cHM6Ly93YWJpLW5vcnRoLWV1cm9wZS1yZWRpcmVjdC5hbmFseXNpcy53aW5kb3dzLm5ldC8ifQ%3D%3D

The first page shows the information for the latest date in the data

image

The second page

image

shows the info by date

The third page by database

image

The fourth page is the drill through page showing the information for the checks enabling you to see the failure messages

image

image

image

image

This is similar to another report that I build so that DBAs could quickly get information about the checks and the reasons for failures and identify what to work on, DBA team leaders could identify risk areas and see how the team were doing and Management could see pretty pictures which changed when they clicked on them.

I am interested in making these reports as gorgeous as possible with the info that people expect to see, so please feel free to comment or to take the Power Bi file new-dbachecks.pbix in the bin folder and make it more beautiful

Some items are not finished yet, the Pester Tests wont succeed as there is no help for the new commands either but if you wish to try this out.

Tests now pass.
If you want to try this out

Clone the repo or update your own clone with

Git status
git fetch upstream
Git checkout development
git merge upstream/development
git checkout New-Json

Then navigate to the root of your repo and run

ipmo dbachecks.psd1

to load the new code

Copy link
Collaborator

@ClaudioESSilva ClaudioESSilva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @SQLDBAWithABeard as mentioned before I have done something like this (non-dbachecks native), and hence my comments/questions.
Let me know if I can help further

Note: Just to share, in my PoC implementation I save Summary and Details (checks results) two different tables where there is an FK with SummaryID (FK to Summary table). To be honest the main point is that some PowerBI dashboards will leverage on the already aggregated data (total tests, successed / failed, etc..).

cc/ @spaghettidba

functions/Write-DbcTable.ps1 Show resolved Hide resolved
functions/Write-DbcTable.ps1 Outdated Show resolved Hide resolved
functions/Write-DbcTable.ps1 Outdated Show resolved Hide resolved
functions/Write-DbcTable.ps1 Outdated Show resolved Hide resolved
else {
$Database = $null
}
$Date = Get-Date # -Format "yyyy-MM-dd"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be the datetime of the import or related with the run?
Should we have both?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think so, I only think that the time of the check is important

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree but the get-date will be the date of the object conversion and then becomes the import date.
Tbh i don't remember to see a date time of the run for each test as result of the pester test. Am I right?

@SQLDBAWithABeard
Copy link
Collaborator Author

GRRRRRRRR

image

So I was looking at handling the couldn't connects to be a little nicer and now I realise that the name of every single test where we cant connect is "Couldn't connect to"

which is correct

but now I need to work out how to filter those out of the results in the PowerBi

so I am walking away for a while

Copy link
Collaborator

@jpomfret jpomfret left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rob!
This looks amazing.

It's been a little while since I've played with dbachecks and the reporting looks fantastic! Put a couple of notes, nothing major.

Was able to pretty easily run some checks, get the data into a database and then get the PowerBI report looking at that database.

Some great changes here, I'm excited!

functions/Write-DbcTable.ps1 Outdated Show resolved Hide resolved
functions/Write-DbcTable.ps1 Outdated Show resolved Hide resolved
functions/Write-DbcTable.ps1 Show resolved Hide resolved
functions/Start-DbcPowerBi.ps1 Show resolved Hide resolved
@SQLDBAWithABeard SQLDBAWithABeard merged commit 2b03bf0 into development May 9, 2020
@SQLDBAWithABeard SQLDBAWithABeard deleted the new-json branch April 26, 2022 06:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants