Log PSRule analysis results to Azure Monitor.
Перейти к файлу
Bernie White 0fedcb7120
Release v0.1.0 (#22)
2020-07-01 22:19:46 +10:00
.azure-pipelines Added sonarcloud to CI pipeline (#9) 2019-12-14 00:37:09 +10:00
.github Remove push PSRule workflow trigger (#21) 2020-07-01 22:03:17 +10:00
.ps-rule Added OSS rules for checking repository files (#18) 2020-07-01 19:35:32 +10:00
.vscode Added OSS rules for checking repository files (#18) 2020-07-01 19:35:32 +10:00
docs Added install instructions (#11) 2019-12-16 15:35:29 +10:00
src/PSRule.Monitor Release v0.1.0 (#22) 2020-07-01 22:19:46 +10:00
tests/PSRule.Monitor.Tests Added OSS rules for checking repository files (#18) 2020-07-01 19:35:32 +10:00
.gitignore Added OSS rules for checking repository files (#18) 2020-07-01 19:35:32 +10:00
CHANGELOG.md Release v0.1.0 (#22) 2020-07-01 22:19:46 +10:00
CODE_OF_CONDUCT.md Initial CODE_OF_CONDUCT.md commit 2019-11-28 03:49:34 -08:00
CONTRIBUTING.md Add project files (#1) 2019-11-28 22:27:54 +10:00
LICENSE Map resource Id from input data #6 #7 (#8) 2019-12-14 00:19:34 +10:00
PSRule.Monitor.sln Add project files (#1) 2019-11-28 22:27:54 +10:00
README.md Release v0.1.0 (#22) 2020-07-01 22:19:46 +10:00
SECURITY.md Add project files (#1) 2019-11-28 22:27:54 +10:00
ThirdPartyNotices.txt Add third party notice and quality updates (#5) 2019-11-30 01:07:44 +10:00
pipeline.build.ps1 Remove PSRule module dependency #13 (#20) 2020-07-01 21:45:22 +10:00
ps-project.yaml Added OSS rules for checking repository files (#18) 2020-07-01 19:35:32 +10:00
ps-rule.yaml Added OSS rules for checking repository files (#18) 2020-07-01 19:35:32 +10:00

README.md

PSRule to Azure Monitor

Log PSRule analysis results to Azure Monitor.

ci-badge

Disclaimer

This project is open source and not a supported product.

If you are experiencing problems, have a feature request, or a question, please check for an issue on GitHub. If you do not see your problem captured, please file a new issue, and follow the provided template.

If you have any problems with the PSRule engine, please check the project GitHub issues page instead.

Getting the modules

This project requires the PSRule PowerShell module. For details on each see install.

You can download and install these modules from the PowerShell Gallery.

Module Description Downloads / instructions
PSRule.Monitor Log PSRule analysis results to Azure Monitor. latest / instructions

Getting started

Upload results

To upload results from PSRule to Azure Monitor, use the Send-PSRuleMonitorRecord cmdlet. Results can by piped directly from Invoke-PSRule or stored and piped from a variable.

The Send-PSRuleMonitorRecord cmdlet requires a Log Analytics workspace to send data to. A workspace can be specified by using the -WorkspaceId and -SharedKey parameters.

For example:

$data | Invoke-PSRule | Send-PSRuleMonitorRecord -WorkspaceId <workspaceId> -SharedKey <primaryKey>;

The following example shows using analysis results from a pre-built module:

$results = Invoke-PSRule -InputPath .\*.json -Module 'PSRule.Rules.Azure';
$results | Send-PSRuleMonitorRecord -WorkspaceId <workspaceId> -SharedKey <primaryKey>;

Querying logs from Azure Monitor

By default, PSRule results are stored in the PSRule_CL table. The following query returns all rule records from the last hour that failed:

PSRule_CL
| where Outcome_s == "Fail" and TimeGenerated > ago(1h)

To query these results from PowerShell use:

Invoke-AzOperationalInsightsQuery -WorkspaceId <workspaceId> -Query 'PSRule_CL | where Outcome_s == "Fail" and TimeGenerated > ago(1h)'

Language reference

Commands

The following commands exist in the PSRule.Monitor module:

Changes and versioning

Modules in this repository will use the semantic versioning model to declare breaking changes from v1.0.0. Prior to v1.0.0, breaking changes may be introduced in minor (0.x.0) version increments. For a list of module changes please see the change log.

Pre-release module versions are created on major commits and can be installed from the PowerShell Gallery. Pre-release versions should be considered experimental. Modules and change log details for pre-releases will be removed as standard releases are made available.

Contributing

This project welcomes contributions and suggestions. If you are ready to contribute, please visit the contribution guide.

Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Maintainers

License

This project is licensed under the MIT License.