GithubHelp home page GithubHelp logo

cloudyspells / psrazdo-workbooks Goto Github PK

View Code? Open in Web Editor NEW
6.0 1.0 1.0 51 KB

Azure Monitor workbooks for Analyzing PSRule.Rules.AzureDevOps results

License: MIT License

Bicep 100.00%
azure azure-devops azure-monitor best-practices bicep psrule

psrazdo-workbooks's Introduction

PSRule.Rules.AzureDevOps Azure Monitor Workbooks

Overview

This repository contains an Azure Monitor Workbooks deployment written in Bicep for analyzing PSRule.Rules.AzureDevOps results captured to an Azure Log Analytics workspace. Azure Pipelines and GitHub Actions yaml templates are included to setup a daily analysis of Azure DevOps Organizations with PSRule. The analysis will loop through all projects in the organization and capture the results.

Demo video on YouTube

Getting Started

The following steps will guide you through deploying the log analytics workspace and workbooks to your Azure subscription.

Prerequisites

  • Azure CLI version 2.20.0 or later.
  • Local copy of this repository. Use git clone to download and maintain a local copy of this repo.

Deployment

The following steps will guide you through deploying the log analytics workspace, workbooks and a keyvault to your Azure subscription. In your local copy of this repository, run the following command to create a new resource group:

# Set the location to deploy to
$location = 'westeurope'
# Set the resource group name
$resourceGroupName = 'rg-psrule-azuredevops-weu'
# Create the resource group in the specified location
az group create --name $resourceGroupName --location $location

Next, run the following command to deploy the log analytics workspace and workbooks:

az deployment group create `
    --resource-group $resourceGroupName `
    --template-file .\src\bicep\main.bicep `
    --query properties.outputs `
    -p azDoOrganization='contoso' `
    -p azDoPAT='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

The deployment will take approximately 5 minutes to complete. After the deployment has completed, there will be a log analytics workspace with workbooks and a key vault available in the resource group. The key vault will contain the necessary secrets to run the analysis with PSRule from an Azure Pipeline.

Azure Pipelines

The following steps will guide you through setting up a daily analysis of Azure DevOps projects with PSRule using Azure Pipelines.

Create a repository in Azure DevOps

Create a new repository in Azure DevOps to store the pipeline definition. To create a new repository, follow the steps in Create a repo. After creating the repository, clone it to your local machine and add the following files to the root of the repository:

  • azure-pipelines/psrule-azdo-loganalytics.yaml

Add the Key Vault as a Variable Group in Azure DevOps

Add the key vault as a variable group in Azure DevOps to allow the pipeline to access the secrets. The key vault can be found in the resource group specified in the deployment. To add the key vault as a variable group, follow the steps in Create a variable group. When prompted to select a source, select Azure Key Vault and select the key vault created in the previous step. Name the variable group azdo-psrule-run and select Allow access to all pipelines.

Create the pipeline

Create a new pipeline in Azure DevOps to run the PSRule analysis. To create a new pipeline, follow the steps in Create your first pipeline. When prompted to select a template, select Existing Azure Pipelines YAML file and select the azure-pipelines/psrule-azdo-loganalytics.yaml file from the repository.

Run the pipeline

Run the pipeline to verify the setup. The pipeline will run for approximately 2 to 5 minutes depending on the size of the Azure DevOps project. Do not run the pipeline more than once a day as the workbook is designed to analyze a single day of data.

Note: When running the pipeline for the first time, it will take up to 15 minutes for data to appear in the workbook.

Check the workbook

After the pipeline has completed, check the workbook in the log analytics workspace. The main workbook is named Azure DevOps Main and is available in the Workbooks section of the log analytics workspace. The workbook will show the results of the last run in 24 hour intervals.

References and acknowledgements

psrazdo-workbooks's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

lromano72

psrazdo-workbooks's Issues

Bug: Bicep Deployment Fails because it finds a duplicate vault in western europe with name 'kv-psrule-azdo-prd-weu'

๐Ÿž Bug Report

Describe the bug

Probably this happens because the Vault name defined in the Bicep template is static and the location is hard coded to western europe, where this vault already exists. Maybe add a random suffix in the vault's name?

image


Is this a regression?


To Reproduce


Expected behaviour


Media prove


Your environment

  • OS:
  • PowerShell version:
  • PSRule version:
  • PSRule.Rules.AzureDevOps version:

Additional context

Bug: Query Error when multi-selecting Resources from the "Azure DevOps Rules Hits by Resource" Workbook

๐Ÿž Bug Report

Describe the bug

From the Resource Name drop-down multi-select field, if I select more than one resource to be displayed, then I get a query error. Error's Line and Position # differs based on the drop-down resource selection. The "All" and "single-select" checkbox options work.

image

image

image


Is this a regression?

This is the first time I am experiencing this since the initial deployment and initial run of the YAML Pipeline


To Reproduce


Media prove


Your environment

  • OS:
  • PowerShell version:
  • PSRule version:
  • PSRule.Rules.AzureDevOps version:

Additional context

Bug: West Europe location for deploying bicep Azure resource in the RG is hard coded

๐Ÿž Bug Report

Describe the bug

The Azure location 'West Europe' is hard-coded in the resource deployment of the bicep template. For example I have created my RG in 'eastus' and I need all my resources to be created in 'eastus'. However, the resources are created by default in 'west europe'. May have the $location as input variable in the 'az deployment group create' script for the main.bicep?


Is this a regression?


To Reproduce


Expected behaviour


Media prove


Your environment

  • OS:
  • PowerShell version:
  • PSRule version:
  • PSRule.Rules.AzureDevOps version:

Additional context

Feature: Workbook "Azure DevOps Resources by Rule" - ruleName field should be a drop-down multi-select field (like in Azure DevOps Rule Hits by Resource Workbook)

๐Ÿš€ Feature Request

Is your feature request related to a problem? Please describe.

The problem is more on user's usability, where the user has to know (and copy-paste) the whole rule string in the "ruleName" text box in order to list the resources affected by that rule.

image

This should be a prepopulated drop-down multi-select field like the "Resource Name" in the "Azure DevOps Rule Hits by Resource" Workbook.

Also, the Resource FQN Column which lists the selected resource's rule Outcome(s), should be a hyperlink taking the user to the Resource Rule details screen (like in the Azure DevOps Resource State Workbook)

image

There are two usability problems here:

  1. The user need to know the rule name, the specific rule FQN, copy it from somewhere and then paste it in the "ruleName" field
  2. The table gets populated with that rule's Resource FQN and Outcome, but then the user does not know what the next action should be. I guess the logical action should be for the Resource FQN which either pass or fails, to be a hyperlink that sends the user to that Resource's Rule details screen. This is just a suggestion for analysis and review based on my perspective

Describe the solution you'd like


Describe alternatives you've considered


Additional context

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.