1

I was reading this article about how to draw a trendline in the time chart related to the Azure SQL Database consumption.

The query is like this:

AzureMetrics
| where TimeGenerated >= ago(90d)
| where Resource == 'MyDB'
| where MetricName == 'full_backup_size_bytes' // in ('full_backup_size_bytes','diff_backup_size_bytes','log_backup_size_bytes')
| make-series SizeBackupDiffTB=max(Maximum/1024/1024/1024/1024) on TimeGenerated in range(ago(90d),now(), 1d)
| extend (RSquare,Slope,Variance,RVariance,Interception,TrendLine)=series_fit_line(SizeBackupDiffTB)
| render timechart

But the Azure Portal returns this error:

Please provide below info when asking for support: timestamp = 2022-12-19T09:09:42.5539654Z, correlationId = 9cfa2a61-7cbe-412d-8e21-20b245a0e7da. (Code:BadRequest)

Details:
Query is invalid. Please refer to the documentation for the Azure Resource Graph service and fix the error before retrying. (Code:InvalidQuery)
ParserFailure (Code:ParserFailure)
ParserFailure (Code:ParserFailure)
ParserFailure (Code:ParserFailure)
ParserFailure (Code:ParserFailure)
ParserFailure (Code:ParserFailure)
ParserFailure (Code:ParserFailure)

I think the problem might recide in the second line >=.

But what does that means?

EDIT: I think there is more than one problem because it doesn't take make-series and render timechart:

enter image description here

But the error is now reduced:

Please provide below info when asking for support: timestamp = 2022-12-19T09:37:04.2221903Z, correlationId = 12157f78-2c92-4820-94d6-f088acf1a5a0. (Code:BadRequest)

Details:
Query is invalid. Please refer to the documentation for the Azure Resource Graph service and fix the error before retrying. (Code:InvalidQuery)
ParserFailure (Code:ParserFailure)
ParserFailure (Code:ParserFailure)
ParserFailure (Code:ParserFailure)
More information on the error can be found here.
Francesco Mantovani
  • 10,216
  • 13
  • 73
  • 113
  • I think >= stands for >= – Jul_DW Dec 19 '22 at 09:32
  • Thank you, that might have fixed the problem. Now on line fife it doesn't recognize `make-series`. I think there are several errors with the query overall – Francesco Mantovani Dec 19 '22 at 09:35
  • Hum, it works in my lab. And it actually is something part of KQL - https://learn.microsoft.com/en-us/azure/data-explorer/kusto/query/make-seriesoperator. Where are you running this query ? From Log Analytics ? – Jul_DW Dec 19 '22 at 09:38
  • I'm running it form Azure Resource Graph Explorer – Francesco Mantovani Dec 19 '22 at 09:58
  • 1
    This query has to be ran from Log Analytics. Resource Graph is meant to explorer resources, not metrics/logs, see respectively https://learn.microsoft.com/en-us/azure/azure-monitor/logs/queries and https://learn.microsoft.com/en-us/azure/governance/resource-graph/overview. – Jul_DW Dec 19 '22 at 13:23

1 Answers1

1

This is probably the Unicode for greater-than that is not reflected properly. You should try with the following in Log Analytics:

AzureMetrics
| where TimeGenerated >= ago(90d)
| where Resource == 'MyDB'
| where MetricName == 'full_backup_size_bytes' // in ('full_backup_size_bytes','diff_backup_size_bytes','log_backup_size_bytes')
| make-series SizeBackupDiffTB=max(Maximum/1024/1024/1024/1024) on TimeGenerated in range(ago(90d),now(), 1d)
| extend (RSquare,Slope,Variance,RVariance,Interception,TrendLine)=series_fit_line(SizeBackupDiffTB)
| render timechart
Jul_DW
  • 1,036
  • 6
  • 20
  • Hi and thank you for your help. I have added a few more info. Is it working on your end? Are you targeting the name of an Azure SQL Database? – Francesco Mantovani Dec 19 '22 at 09:40
  • Resource Graph only supports a subset of KQL, see https://learn.microsoft.com/en-us/azure/governance/resource-graph/concepts/query-language#supported-kql-language-elements. You need to run this query in Log Analytics to get the full breadth of the query language, including make-series and rendering. – Jul_DW Dec 19 '22 at 13:24