{"id":49346317,"url":"https://github.com/microsoft/psrule.monitor","last_synced_at":"2026-04-27T08:01:15.187Z","repository":{"id":36495314,"uuid":"224642027","full_name":"microsoft/PSRule.Monitor","owner":"microsoft","description":"Log PSRule analysis results to Azure Monitor.","archived":false,"fork":false,"pushed_at":"2026-04-23T11:05:44.000Z","size":245,"stargazers_count":16,"open_issues_count":9,"forks_count":8,"subscribers_count":4,"default_branch":"main","last_synced_at":"2026-04-27T06:33:51.453Z","etag":null,"topics":["azure","azure-monitor","cmdlet","powershell","powershell-module","psrule"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/microsoft.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":"SUPPORT.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2019-11-28T11:49:29.000Z","updated_at":"2026-03-24T23:40:04.000Z","dependencies_parsed_at":"2026-04-27T08:00:57.111Z","dependency_job_id":null,"html_url":"https://github.com/microsoft/PSRule.Monitor","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/microsoft/PSRule.Monitor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2FPSRule.Monitor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2FPSRule.Monitor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2FPSRule.Monitor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2FPSRule.Monitor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/microsoft","download_url":"https://codeload.github.com/microsoft/PSRule.Monitor/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2FPSRule.Monitor/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32327701,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T23:26:28.701Z","status":"online","status_checked_at":"2026-04-27T02:00:06.769Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["azure","azure-monitor","cmdlet","powershell","powershell-module","psrule"],"created_at":"2026-04-27T08:00:34.653Z","updated_at":"2026-04-27T08:01:15.143Z","avatar_url":"https://github.com/microsoft.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PSRule for Azure Monitor\r\n\r\nLog PSRule analysis results to Azure Monitor.\r\n\r\n\u003e [!NOTE]\r\n\u003e This module is being migrated into \u003chttps://github.com/microsoft/PSRule\u003e\r\n\u003e and this repository will be archived in the future.\r\n\u003e The functionality of this module will be included PSRule in a future release.\r\n\u003e This repository currently reflects functionality as a standalone module.\r\n\u003e\r\n\u003e You may still continue to download and use this module from source or the PowerShell Gallery,\r\n\u003e but it will not receive any further updates or support.\r\n\u003e\r\n\u003e Please log any new issues at \u003chttps://github.com/microsoft/PSRule/issues\u003e\r\n---\r\n\r\n## Getting the module\r\n\r\nThis project requires the `PSRule` PowerShell module.\r\nFor detail on installation and dependencies see [install].\r\n\r\nYou can download and install these modules from the PowerShell Gallery.\r\n\r\nModule             | Description | Downloads / instructions\r\n------             | ----------- | ------------------------\r\nPSRule.Monitor     | Log PSRule analysis results to Azure Monitor. | [latest][module] / [instructions][install]\r\n\r\n## Getting started\r\n\r\n### Upload results with PSRule convention\r\n\r\nA convention can be used to upload the results of a PSRule analysis to Azure Monitor.\r\nTo use the convention:\r\n\r\n- Install the `PSRule.Monitor` module from the PowerShell Gallery.\r\n- Include the `PSRule.Monitor` module.\r\n  This can be set in PSRule options or specified at runtime as a parameter.\r\n- Reference `Monitor.LogAnalytics.Import` convention.\r\n  This can be set in PSRule options or specified at runtime as a parameter.\r\n\r\nFor example:\r\n\r\n```yaml\r\ninclude:\r\n  module:\r\n  - 'PSRule.Monitor'\r\n\r\nconvention:\r\n  include:\r\n  - 'Monitor.LogAnalytics.Import\r\n```\r\n\r\nWhen using the convention a Log Analytics workspace must be specified.\r\nThis can be done by setting the following environment variables:\r\n\r\n- `PSRULE_CONFIGURATION_MONITOR_WORKSPACE_ID` - Containing the Log Analytics workspace ID.\r\n- `PSRULE_CONFIGURATION_MONITOR_WORKSPACE_KEY` - Containing either the primary or secondary key to the workspace.\r\n  This value is sensitive and should be stored securely.\r\n  To protect this value, avoid storing it in source control.\r\n\r\nFor example:\r\n\r\n```powershell\r\n# PowerShell: Setting environment variable\r\n$Env:PSRULE_CONFIGURATION_MONITOR_WORKSPACE_ID = '00000000-0000-0000-0000-000000000000'\r\n$Env:PSRULE_CONFIGURATION_MONITOR_WORKSPACE_KEY = Get-Secret -Name 'WORKSPACE_KEY' -AsPlainText\r\n```\r\n\r\n```yaml\r\n# GitHub Actions: Setting environment variable with microsoft/ps-rule action\r\n- name: Run PSRule analysis\r\n  uses: microsoft/ps-rule@main\r\n  env:\r\n    PSRULE_CONFIGURATION_MONITOR_WORKSPACE_ID: 00000000-0000-0000-0000-000000000000\r\n    PSRULE_CONFIGURATION_MONITOR_WORKSPACE_KEY: ${{ secrets.WORKSPACE_KEY }}\r\n```\r\n\r\n```yaml\r\n# Azure Pipelines: Setting environment variable with ps-rule-assert task\r\n- task: ps-rule-assert@0\r\n  displayName: Run PSRule analysis\r\n  inputs:\r\n    inputType: repository\r\n  env:\r\n    PSRULE_CONFIGURATION_MONITOR_WORKSPACE_ID: 00000000-0000-0000-0000-000000000000\r\n    PSRULE_CONFIGURATION_MONITOR_WORKSPACE_KEY: $(WORKSPACE_KEY)\r\n```\r\n\r\n### Upload results with PowerShell\r\n\r\nTo upload results from PSRule to Azure Monitor, use the `Send-PSRuleMonitorRecord` cmdlet.\r\nResults can by piped directly from `Invoke-PSRule` or stored and piped from a variable.\r\n\r\nThe `Send-PSRuleMonitorRecord` cmdlet requires a Log Analytics workspace to send data to.\r\nA workspace can be specified by using the `-WorkspaceId` and `-SharedKey` parameters.\r\n\r\nFor example:\r\n\r\n```powershell\r\n$data | Invoke-PSRule | Send-PSRuleMonitorRecord -WorkspaceId \u003cworkspaceId\u003e -SharedKey \u003cprimaryKey\u003e;\r\n```\r\n\r\nThe following example shows using analysis results from a pre-built module:\r\n\r\n```powershell\r\n$results = Invoke-PSRule -InputPath .\\*.json -Module 'PSRule.Rules.Azure';\r\n$results | Send-PSRuleMonitorRecord -WorkspaceId \u003cworkspaceId\u003e -SharedKey \u003cprimaryKey\u003e;\r\n```\r\n\r\n### Querying logs from Azure Monitor\r\n\r\nBy default, PSRule results are stored in the `PSRule_CL` table.\r\nThe results can be queries from the Log Analytics workspace using Kusto.\r\n\r\nThe following query returns all rule records from the last hour that failed:\r\n\r\n```kusto\r\nPSRule_CL\r\n| where Outcome_s == \"Fail\" and TimeGenerated \u003e ago(1h)\r\n```\r\n\r\nTo query these results from PowerShell use:\r\n\r\n```powershell\r\nInvoke-AzOperationalInsightsQuery -WorkspaceId \u003cworkspaceId\u003e -Query 'PSRule_CL | where Outcome_s == \"Fail\" and TimeGenerated \u003e ago(1h)'\r\n```\r\n\r\n## Language reference\r\n\r\n### Commands\r\n\r\nThe following commands exist in the `PSRule.Monitor` module:\r\n\r\n- [Send-PSRuleMonitorRecord](docs/commands/PSRule.Monitor/en-US/Send-PSRuleMonitorRecord.md) - Send analysis results from PSRule to Azure Monitor.\r\n\r\n## Contributing\r\n\r\nThis project welcomes contributions and suggestions.\r\nIf you are ready to contribute, please visit the [contribution guide](CONTRIBUTING.md).\r\n\r\n## Code of Conduct\r\n\r\nThis project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).\r\nFor more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)\r\nor contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.\r\n\r\n## Maintainers\r\n\r\n- [Bernie White](https://github.com/BernieWhite)\r\n\r\n## License\r\n\r\nThis project is [licensed under the MIT License](LICENSE).\r\n\r\n[install]: docs/scenarios/install-instructions.md\r\n[module]: https://www.powershellgallery.com/packages/PSRule.Monitor\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrosoft%2Fpsrule.monitor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicrosoft%2Fpsrule.monitor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrosoft%2Fpsrule.monitor/lists"}