SOLVED

Query for Azure Backup

Copper Contributor

Hello All,

 

I'm using the below script to get the backup information, but in this script I can't found were or how can I get the error message, error code and the recommendations message.

Can anyone help me on this? :)

 

 

let Events = AzureDiagnostics

| where Category == "AzureBackupReport" ;

Events

| where OperationName == "Job" and JobOperation_s == "Backup"

| project ProtectedServerUniqueId_s, JobStatus_s, Resource , TimeGenerated , JobStartDateTime_s , JobDurationInSecs_s

| join kind=inner

(

Events

| where OperationName == "ProtectedServer"

| where ProtectedServerFriendlyName_s != ""

| distinct ProtectedServerUniqueId_s, ProtectedServerFriendlyName_s

| project ProtectedServerUniqueId_s, ProtectedServerFriendlyName_s

)

on ProtectedServerUniqueId_s

| project ProtectedServerFriendlyName_s, JobStatus_s, Resource, TimeGenerated , JobStartDateTime_s , JobDurationInSecs_s

| extend Vault= Resource

| summarize count() by ProtectedServerFriendlyName_s, JobStatus_s, Vault, TimeGenerated , JobStartDateTime_s , JobDurationInSecs_s

 

9 Replies

@Lucas Chies 

 

If you remove the filters, like this, do you see the Columns of data you need?  I don't see names like Error message or error code but they may have other names?  If you find the right data you can add them to the Project and Distinct lines

let Events = AzureDiagnostics
| where Category == "AzureBackupReport" ;
Events
| where OperationName == "Job" and JobOperation_s == "Backup"
//| project ProtectedServerUniqueId_s, JobStatus_s, Resource , TimeGenerated , JobStartDateTime_s , JobDurationInSecs_s
| join kind=inner
(
Events
| where OperationName == "ProtectedServer"
| where ProtectedServerFriendlyName_s != ""
//| distinct ProtectedServerUniqueId_s, ProtectedServerFriendlyName_s
//| project ProtectedServerUniqueId_s, ProtectedServerFriendlyName_s
)
on ProtectedServerUniqueId_s
//| project ProtectedServerFriendlyName_s, JobStatus_s, Resource, TimeGenerated , JobStartDateTime_s , JobDurationInSecs_s
| extend Vault= Resource

 

Hello @CliveWatson 

 

Tks for your help.

So, all scripts doesn't show the recommendation. I'm trying to find this message on the below screen:

image.png

I'm trying use the "RecommendedAction_s", but doesn't show any information.

let Events = AzureDiagnostics 
| where Category == "AzureBackupReport"; Events 
| extend JobOperationSubType_s = columnifexists("JobOperationSubType_s", "") 
| where OperationName == "Job" and JobOperation_s == "Backup" and JobStatus_s == "Failed" and JobOperationSubType_s != "Log" and JobOperationSubType_s != "Recovery point_Log"
| distinct JobUniqueId_g, BackupItemUniqueId_s, JobStatus_s, Resource, JobFailureCode_s, JobStartDateTime_s, RecommendedAction_s
| project BackupItemUniqueId_s, JobStatus_s, Resource, JobFailureCode_s, JobStartDateTime_s, RecommendedAction_s

 

@Lucas Chies 

.

That is an "Alert" operation so you need to add that. ie. 

| where OperationName == "Alert"

Amended query:
let Events = AzureDiagnostics 
| where Category == "AzureBackupReport";
 Events 
| extend JobOperationSubType_s = columnifexists("JobOperationSubType_s", "") 
| where OperationName == "Alert" or  OperationName == "Job" 
        and JobOperation_s == "Backup" and JobStatus_s == "Failed"
        and JobOperationSubType_s !in ("Log","Recovery point_Log")
| distinct JobUniqueId_g, BackupItemUniqueId_s, JobStatus_s, Resource, JobFailureCode_s, JobStartDateTime_s, RecommendedAction_s
| project BackupItemUniqueId_s, JobStatus_s, Resource, JobFailureCode_s, JobStartDateTime_s, RecommendedAction_s

  

@CliveWatson 

 

Hi Clive,

I´m trying to achieve the same here. Tested the amended query, but no luck on getting the Error Message or the Recommended Action yet.

Quest continues...

best response confirmed by ThereseSolimeno (Microsoft)
Solution
AddonAzureBackupJobs
| where JobOperation=="Backup"
| summarize arg_max(TimeGenerated,*) by JobUniqueId
| where JobStatus=="Completed"
| join kind=inner
(
CoreAzureBackup
| where OperationName == "BackupItem"
| where BackupItemType=="VM" and BackupManagementType=="IaaSVM"
| distinct BackupItemUniqueId, BackupItemFriendlyName
)
on BackupItemUniqueId

I hope this code helps you out.

@Lewis-H 

Tried the same, but neither Error Message nor Recommended action are returned by this query. 

Hi Everyone,
just to make sure, this thread should be re-opened until a working solution is achieved, right?

@GBADARO 

 

That's correct, question is still open until you are happy or our collective knowledge is exhausted.  I see this data with the query I provided.  You can see it working in the demo data set here:

Go to Log Analytics and run query

 

As to why you don't have it, perhaps its the back up type or other issue.  I'm not familiar with backup, so perhaps others will comment? 

@Lewis-H 

Hi, I used your query and it works fine. Can you please add lines to display database backups (SQL in Azure VM)

 

 

 

 

1 best response

Accepted Solutions
best response confirmed by ThereseSolimeno (Microsoft)
Solution
AddonAzureBackupJobs
| where JobOperation=="Backup"
| summarize arg_max(TimeGenerated,*) by JobUniqueId
| where JobStatus=="Completed"
| join kind=inner
(
CoreAzureBackup
| where OperationName == "BackupItem"
| where BackupItemType=="VM" and BackupManagementType=="IaaSVM"
| distinct BackupItemUniqueId, BackupItemFriendlyName
)
on BackupItemUniqueId

I hope this code helps you out.

View solution in original post