View the DSC logs

After you set up integration with Log Analytics for your Automation DSC data, a Log search button will appear on
the DSC Nodes blade of your automation account. Click the Log Search button to view the logs for DSC node data.

The Log Search blade opens, and you see a DscNodeStatusData operation for each DSC node,
and a DscResourceStatusData operation for each DSC resource
called in the Node configuration applied to that node.

The DscResourceStatusData operation contains error information for any DSC resources that failed.

Click each operation in the list to see the data for that operation.

You can also view the logs by [searching in Log Analytics.
See Find data using log searches.
Type the following query to find your DSC logs:
Type=AzureDiagnostics ResourceProvider="MICROSOFT.AUTOMATION" Category = "DscNodeStatus"

You can also narrow the query by the operation name. For example:
`Type=AzureDiagnostics ResourceProvider="MICROSOFT.AUTOMATION" Category = "DscNodeStatus" OperationName = "DscNodeStatusData"

Send an email when a DSC compliance check fails

One of our top customer requests is for the ability to send an email or a text when something goes wrong with a DSC configuration.

To create an alert rule, you start by creating a log search for the DSC report records that should invoke the alert. Click the Alert button to create and configure the alert rule.

From the Log Analytics Overview page, click Log Search.

Create a log search query for your alert by typing the following search into the query field: Type=AzureDiagnostics Category=DscNodeStatus NodeName_s=DSCTEST1 OperationName=DscNodeStatusData ResultType=Failed

If you have set up logs from more than one Automation account or subscription to your workspace, you can group your alerts by subscription and Automation account.Automation account name can be derived from the Resource field in the search of DscNodeStatusData.

To open the Add Alert Rule screen, click Alert at the top of the page. For more information on the options to configure the alert, see Alerts in Log Analytics.

Find failed DSC resources across all nodes

One advantage of using Log Analytics is that you can search for failed checks across nodes.
To find all instances of DSC resources that failed.

From the Log Analytics Overview page, click Log Search.

Create a log search query for your alert by typing the following search into the query field: Type=AzureDiagnostics Category=DscNodeStatus OperationName=DscResourceStatusData ResultType=Failed

View historical DSC node status

Finally, you may want to visualize your DSC node status history over time.You can use this query to search for the status of your DSC node status over time.

Log Analytics records

Diagnostics from Azure Automation creates two categories of records in Log Analytics.

DscNodeStatusData

Property

Description

TimeGenerated

Date and time when the compliance check ran.

OperationName

DscNodeStatusData

ResultType

Whether the node is compliant.

NodeName_s

The name of the managed node.

NodeComplianceStatus_s

Whether the node is compliant.

DscReportStatus

Whether the compliance check ran successfully.

ConfigurationMode

How the configuration is applied to the node. Possible values are "ApplyOnly","ApplyandMonitior", and "ApplyandAutoCorrect".

ApplyOnly: DSC applies the configuration and does nothing further unless a new configuration is pushed to the target node or when a new configuration is pulled from a server. After initial application of a new configuration, DSC does not check for drift from a previously configured state. DSC attempts to apply the configuration until it is successful before ApplyOnly takes effect.

ApplyAndMonitor: This is the default value. The LCM applies any new configurations. After initial application of a new configuration, if the target node drifts from the desired state, DSC reports the discrepancy in logs. DSC attempts to apply the configuration until it is successful before ApplyAndMonitor takes effect.

ApplyAndAutoCorrect: DSC applies any new configurations. After initial application of a new configuration, if the target node drifts from the desired state, DSC reports the discrepancy in logs, and then reapplies the current configuration.

HostName_s

The name of the managed node.

IPAddress

The IPv4 address of the managed node.

Category

DscNodeStatus

Resource

The name of the Azure Automation account.

Tenant_g

GUID that identifies the tenant for the Caller.

NodeId_g

GUID that identifies the managed node.

DscReportId_g

GUID that identifies the report.

LastSeenTime_t

Date and time when the report was last viewed.

ReportStartTime_t

Date and time when the report was started.

ReportEndTime_t

Date and time when the report completed.

NumberOfResources_d

The number of DSC resources called in the configuration applied to the node.