Logging

Source code & Installation

The source code of this kit module can be found hereopen in new window

Run the following command to install the kit module:

collie kit import azure/logging
1

Getting started with log analytics workspace

If you have not done so already, move an existing subscription into the management group hierarchy and check the policy assignment status in Azure Portal. We expect to see that the scope is compliant with the policy.

Here is how you interact with logs in your new workspace.

Open log analytics workspace in Azure portal. Choose the newly created workspace. Choose Workbooks → Activity Logs Insights. You will see stats about the Activity Logs streamed from the connected subscriptions to the log analytics workspace.

This assumes that in some Activity Log items has been generated in any of the

Alternatively, you can query logs. To do so, choose Logs in your workspace.

Here is a query that displays the last 50 Activity log events:

// Display top 50 Activity log events.
AzureActivity
| project TimeGenerated, SubscriptionId, ResourceGroup,ResourceProviderValue,OperationNameValue,CategoryValue,CorrelationId,ActivityStatusValue, ActivitySubstatusValue, Properties_d, Caller
| top 50 by TimeGenerated
1
2
3
4

Requirements

NameVersion
terraform>= 1.0
azapi~> 1.12.1
azuread~> 2.41.0
azurerm~> 3.71.0

Modules

NameSourceVersion
policy_lawgithub.com/meshcloud/collie-hub//kit/azure/util/azure-policiesef06c8d43611dd3bf6eebdd7f472b95472f86b0b

Resources

NameType
azapi_resource.diag_setting_management_groupopen in new windowresource
azuread_group.security_adminsopen in new windowresource
azuread_group.security_auditorsopen in new windowresource
azurerm_log_analytics_workspace.lawopen in new windowresource
azurerm_management_group_subscription_association.loggingopen in new windowresource
azurerm_resource_group.law_rgopen in new windowresource
azurerm_role_assignment.cloudfoundation_tfdeployopen in new windowresource
azurerm_role_assignment.loggingopen in new windowresource
azurerm_role_assignment.security_adminsopen in new windowresource
azurerm_role_assignment.security_admins_lawopen in new windowresource
azurerm_role_assignment.security_auditorsopen in new windowresource
azurerm_role_assignment.security_auditors_lawopen in new windowresource
azurerm_role_definition.cloudfoundation_tfdeployopen in new windowresource
terraform_data.subscription_nameopen in new windowresource
azurerm_subscription.currentopen in new windowdata source

Inputs

NameDescriptionTypeDefaultRequired
cloudfoundationthis is the name of your cloud foundationstringn/ayes
cloudfoundation_deploy_principal_idPrincipal ID authorized for deploying Cloud Foundation resourcesstringn/ayes
locationlocation of the resources created for loggingstringn/ayes
log_retention_in_daysamount of time of log retentionnumber30no
logging_subscription_nameName of your logging subscriptionstring"logging"no
parent_management_group_idid of the parent management group that the logging subscription will be placed understringn/ayes
scopeid of the management group that you want to collect activity logs fromstringn/ayes
security_admin_groupthe name of the cloud foundation security admin groupstring"cloudfoundation-security-admins"no
security_auditor_groupthe name of the cloud foundation security auditor groupstring"cloudfoundation-security-auditors"no

Outputs

NameDescription
documentation_mdn/a
law_workspace_idn/a
law_workspace_id_shortn/a
law_workspace_resource_idn/a
logging_subscriptionn/a
security_admins_azuread_group_idn/a
security_auditors_azuread_group_idn/a