azuremonitor: port azure log analytics query function to the backend (#23839)

* azuremonitor: add support for log analytics macros

Also adds tests for the kql macros

* azuremonitor: backend implementation for Log Analytics

* azuremonitor: remove gzip header from plugin route

The Go net/http library adds an accept encoding header
for gzip automatically.

https://golang.org/src/net/http/transport.go\#L2454

So no need to specify it manually

* azuremonitor: parses log analytics time series

* azuremonitor: support for table data for Log Analytics

* azuremonitor: for log analytics switch to calling the API...

...from the backend for time series and table queries.

* azuremonitor: fix missing err check

* azuremonitor: support Azure China, Azure Gov...

for log analytics on the backend.

* azuremonitor: review fixes

* azuremonitor: rename test files folder to testdata

To follow Go conventions for test data in tests

* azuremonitor: review fixes

* azuremonitor: better error message for http requests

* azuremonitor: fix for load workspaces on config page

* azuremonitor: strict null check fixes

Co-authored-by: bergquist <carl.bergquist@gmail.com>
This commit is contained in:
Daniel Lee
2020-04-27 17:43:02 +02:00
committed by GitHub
co-authored by bergquist
parent 458f6bdb87
commit c05049f395
32 changed files with 1460 additions and 258 deletions
@@ -0,0 +1,27 @@
{
"tables": [
{
"name": "PrimaryResult",
"columns": [
{
"name": "timestamp",
"type": "datetime"
},
{
"name": "value",
"type": "int"
}
],
"rows": [
[
"2019-09-13T01:02:03.456789Z",
1
],
[
"2019-09-13T02:02:03.456789Z",
2
]
]
}
]
}
@@ -0,0 +1,43 @@
{
"tables": [
{
"name": "PrimaryResult",
"columns": [
{
"name": "timestamp",
"type": "datetime"
},
{
"name": "value",
"type": "int"
},
{
"name": "segment",
"type": "string"
}
],
"rows": [
[
"2019-09-13T01:02:03.456789Z",
1,
"a"
],
[
"2019-09-13T01:02:03.456789Z",
2,
"b"
],
[
"2019-09-14T02:02:03.456789Z",
3,
"a"
],
[
"2019-09-14T02:02:03.456789Z",
4,
"b"
]
]
}
]
}
@@ -0,0 +1,9 @@
{
"value": {
"start": "2019-09-13T01:02:03.456789Z",
"end": "2019-09-13T02:02:03.456789Z",
"value": {
"avg": 1.2
}
}
}
@@ -0,0 +1,23 @@
{
"value": {
"start": "2019-09-13T01:02:03.456789Z",
"end": "2019-09-13T03:02:03.456789Z",
"interval": "PT1H",
"segments": [
{
"start": "2019-09-13T01:02:03.456789Z",
"end": "2019-09-13T02:02:03.456789Z",
"value": {
"avg": 1
}
},
{
"start": "2019-09-13T02:02:03.456789Z",
"end": "2019-09-13T03:02:03.456789Z",
"value": {
"avg": 2
}
}
]
}
}
@@ -0,0 +1,45 @@
{
"value": {
"start": "2019-09-13T01:02:03.456789Z",
"end": "2019-09-13T03:02:03.456789Z",
"interval": "PT1H",
"segments": [
{
"start": "2019-09-13T01:02:03.456789Z",
"end": "2019-09-13T02:02:03.456789Z",
"segments": [
{
"value": {
"avg": 1
},
"blob": "a"
},
{
"value": {
"avg": 3
},
"blob": "b"
}
]
},
{
"start": "2019-09-13T02:02:03.456789Z",
"end": "2019-09-13T03:02:03.456789Z",
"segments": [
{
"value": {
"avg": 2
},
"blob": "a"
},
{
"value": {
"avg": 4
},
"blob": "b"
}
]
}
]
}
}
@@ -0,0 +1,47 @@
{
"cost": 0,
"timespan": "2019-02-08T10:13:50Z\/2019-02-08T16:13:50Z",
"interval": "PT1M",
"value": [
{
"id": "\/subscriptions\/xxx\/resourceGroups\/grafanastaging\/providers\/Microsoft.Compute\/virtualMachines\/grafana\/providers\/Microsoft.Insights\/metrics\/Percentage CPU",
"type": "Microsoft.Insights\/metrics",
"name": {
"value": "Percentage CPU",
"localizedValue": "Percentage CPU"
},
"unit": "Percent",
"timeseries": [
{
"metadatavalues": [
],
"data": [
{
"timeStamp": "2019-02-08T10:13:00Z",
"average": 2.0875
},
{
"timeStamp": "2019-02-08T10:14:00Z",
"average": 2.1525
},
{
"timeStamp": "2019-02-08T10:15:00Z",
"average": 2.155
},
{
"timeStamp": "2019-02-08T10:16:00Z",
"average": 3.6925
},
{
"timeStamp": "2019-02-08T10:17:00Z",
"average": 2.44
}
]
}
]
}
],
"namespace": "Microsoft.Compute\/virtualMachines",
"resourceregion": "westeurope"
}
@@ -0,0 +1,47 @@
{
"cost": 0,
"timespan": "2019-02-09T13:29:41Z\/2019-02-09T19:29:41Z",
"interval": "PT1M",
"value": [
{
"id": "\/subscriptions\/xxx\/resourceGroups\/grafanastaging\/providers\/Microsoft.Compute\/virtualMachines\/grafana\/providers\/Microsoft.Insights\/metrics\/Percentage CPU",
"type": "Microsoft.Insights\/metrics",
"name": {
"value": "Percentage CPU",
"localizedValue": "Percentage CPU"
},
"unit": "Percent",
"timeseries": [
{
"metadatavalues": [
],
"data": [
{
"timeStamp": "2019-02-09T13:29:00Z",
"total": 8.26
},
{
"timeStamp": "2019-02-09T13:30:00Z",
"total": 8.7
},
{
"timeStamp": "2019-02-09T13:31:00Z",
"total": 14.82
},
{
"timeStamp": "2019-02-09T13:32:00Z",
"total": 10.07
},
{
"timeStamp": "2019-02-09T13:33:00Z",
"total": 8.52
}
]
}
]
}
],
"namespace": "Microsoft.Compute\/virtualMachines",
"resourceregion": "westeurope"
}
@@ -0,0 +1,47 @@
{
"cost": 0,
"timespan": "2019-02-09T14:26:12Z\/2019-02-09T20:26:12Z",
"interval": "PT1M",
"value": [
{
"id": "\/subscriptions\/xxx\/resourceGroups\/grafanastaging\/providers\/Microsoft.Compute\/virtualMachines\/grafana\/providers\/Microsoft.Insights\/metrics\/Percentage CPU",
"type": "Microsoft.Insights\/metrics",
"name": {
"value": "Percentage CPU",
"localizedValue": "Percentage CPU"
},
"unit": "Percent",
"timeseries": [
{
"metadatavalues": [
],
"data": [
{
"timeStamp": "2019-02-09T14:26:00Z",
"maximum": 3.07
},
{
"timeStamp": "2019-02-09T14:27:00Z",
"maximum": 2.92
},
{
"timeStamp": "2019-02-09T14:28:00Z",
"maximum": 2.87
},
{
"timeStamp": "2019-02-09T14:29:00Z",
"maximum": 2.27
},
{
"timeStamp": "2019-02-09T14:30:00Z",
"maximum": 2.52
}
]
}
]
}
],
"namespace": "Microsoft.Compute\/virtualMachines",
"resourceregion": "westeurope"
}
@@ -0,0 +1,47 @@
{
"cost": 0,
"timespan": "2019-02-09T14:43:21Z\/2019-02-09T20:43:21Z",
"interval": "PT1M",
"value": [
{
"id": "\/subscriptions\/xxx\/resourceGroups\/grafanastaging\/providers\/Microsoft.Compute\/virtualMachines\/grafana\/providers\/Microsoft.Insights\/metrics\/Percentage CPU",
"type": "Microsoft.Insights\/metrics",
"name": {
"value": "Percentage CPU",
"localizedValue": "Percentage CPU"
},
"unit": "Percent",
"timeseries": [
{
"metadatavalues": [
],
"data": [
{
"timeStamp": "2019-02-09T14:43:00Z",
"minimum": 1.51
},
{
"timeStamp": "2019-02-09T14:44:00Z",
"minimum": 2.38
},
{
"timeStamp": "2019-02-09T14:45:00Z",
"minimum": 1.69
},
{
"timeStamp": "2019-02-09T14:46:00Z",
"minimum": 2.27
},
{
"timeStamp": "2019-02-09T14:47:00Z",
"minimum": 1.96
}
]
}
]
}
],
"namespace": "Microsoft.Compute\/virtualMachines",
"resourceregion": "westeurope"
}
@@ -0,0 +1,47 @@
{
"cost": 0,
"timespan": "2019-02-09T14:44:52Z\/2019-02-09T20:44:52Z",
"interval": "PT1M",
"value": [
{
"id": "\/subscriptions\/xxx\/resourceGroups\/grafanastaging\/providers\/Microsoft.Compute\/virtualMachines\/grafana\/providers\/Microsoft.Insights\/metrics\/Percentage CPU",
"type": "Microsoft.Insights\/metrics",
"name": {
"value": "Percentage CPU",
"localizedValue": "Percentage CPU"
},
"unit": "Percent",
"timeseries": [
{
"metadatavalues": [
],
"data": [
{
"timeStamp": "2019-02-09T14:44:00Z",
"count": 4
},
{
"timeStamp": "2019-02-09T14:45:00Z",
"count": 4
},
{
"timeStamp": "2019-02-09T14:46:00Z",
"count": 4
},
{
"timeStamp": "2019-02-09T14:47:00Z",
"count": 4
},
{
"timeStamp": "2019-02-09T14:48:00Z",
"count": 4
}
]
}
]
}
],
"namespace": "Microsoft.Compute\/virtualMachines",
"resourceregion": "westeurope"
}
@@ -0,0 +1,128 @@
{
"cost": 0,
"timespan": "2019-02-09T15:21:39Z\/2019-02-09T21:21:39Z",
"interval": "PT1H",
"value": [
{
"id": "\/subscriptions\/xxx\/resourceGroups\/grafanastaging\/providers\/Microsoft.Storage\/storageAccounts\/grafanastaging\/blobServices\/default\/providers\/Microsoft.Insights\/metrics\/BlobCount",
"type": "Microsoft.Insights\/metrics",
"name": {
"value": "BlobCount",
"localizedValue": "Blob Count"
},
"unit": "Count",
"timeseries": [
{
"metadatavalues": [
{
"name": {
"value": "blobtype",
"localizedValue": "blobtype"
},
"value": "PageBlob"
}
],
"data": [
{
"timeStamp": "2019-02-09T15:21:00Z",
"average": 3
},
{
"timeStamp": "2019-02-09T16:21:00Z",
"average": 3
},
{
"timeStamp": "2019-02-09T17:21:00Z",
"average": 3
},
{
"timeStamp": "2019-02-09T18:21:00Z",
"average": 3
},
{
"timeStamp": "2019-02-09T19:21:00Z",
"average": 3
},
{
"timeStamp": "2019-02-09T20:21:00Z"
}
]
},
{
"metadatavalues": [
{
"name": {
"value": "blobtype",
"localizedValue": "blobtype"
},
"value": "BlockBlob"
}
],
"data": [
{
"timeStamp": "2019-02-09T15:21:00Z",
"average": 1
},
{
"timeStamp": "2019-02-09T16:21:00Z",
"average": 1
},
{
"timeStamp": "2019-02-09T17:21:00Z",
"average": 1
},
{
"timeStamp": "2019-02-09T18:21:00Z",
"average": 1
},
{
"timeStamp": "2019-02-09T19:21:00Z",
"average": 1
},
{
"timeStamp": "2019-02-09T20:21:00Z"
}
]
},
{
"metadatavalues": [
{
"name": {
"value": "blobtype",
"localizedValue": "blobtype"
},
"value": "Azure Data Lake Storage"
}
],
"data": [
{
"timeStamp": "2019-02-09T15:21:00Z",
"average": 0
},
{
"timeStamp": "2019-02-09T16:21:00Z",
"average": 0
},
{
"timeStamp": "2019-02-09T17:21:00Z",
"average": 0
},
{
"timeStamp": "2019-02-09T18:21:00Z",
"average": 0
},
{
"timeStamp": "2019-02-09T19:21:00Z",
"average": 0
},
{
"timeStamp": "2019-02-09T20:21:00Z"
}
]
}
]
}
],
"namespace": "Microsoft.Storage\/storageAccounts\/blobServices",
"resourceregion": "westeurope"
}
@@ -0,0 +1,38 @@
{
"tables": [
{
"name": "PrimaryResult",
"columns": [
{
"name": "TimeGenerated",
"type": "datetime"
},
{
"name": "Computer",
"type": "string"
},
{
"name": "avg_CounterValue",
"type": "real"
}
],
"rows": [
[
"2020-04-19T19:16:06.5Z",
"grafana-vm",
1.1
],
[
"2020-04-19T19:16:16.5Z",
"grafana-vm",
2.2
],
[
"2020-04-19T19:16:26.5Z",
"grafana-vm",
3.3
]
]
}
]
}
@@ -0,0 +1,68 @@
{
"tables": [
{
"name": "PrimaryResult",
"columns": [
{
"name": "TimeGenerated",
"type": "datetime"
},
{
"name": "ObjectName",
"type": "string"
},
{
"name": "avg_CounterValue",
"type": "real"
}
],
"rows": [
[
"2020-04-20T21:40:00Z",
"Processor",
0.75
],
[
"2020-04-20T21:40:00Z",
"Logical Disk",
16090.551851851851
],
[
"2020-04-20T21:40:00Z",
"Memory",
702.0666666666667
],
[
"2020-04-20T21:45:00Z",
"Memory",
700.5888888888888
],
[
"2020-04-20T21:45:00Z",
"Processor",
1.0055555555555555
],
[
"2020-04-20T21:45:00Z",
"Logical Disk",
16090.537037037036
],
[
"2020-04-20T21:50:00Z",
"Logical Disk",
16090.586419753086
],
[
"2020-04-20T21:50:00Z",
"Processor",
0.7407407407407407
],
[
"2020-04-20T21:50:00Z",
"Memory",
703.1111111111111
]
]
}
]
}
@@ -0,0 +1,31 @@
{
"tables": [
{
"name": "PrimaryResult",
"columns": [
{
"name": "TimeGenerated",
"type": "datetime"
},
{
"name": "avg_CounterValue",
"type": "int"
}
],
"rows": [
[
"2020-04-19T19:16:06.5Z",
1
],
[
"2020-04-19T19:16:16.5Z",
2
],
[
"2020-04-19T19:16:26.5Z",
3
]
]
}
]
}
@@ -0,0 +1,31 @@
{
"tables": [
{
"name": "PrimaryResult",
"columns": [
{
"name": "Computer",
"type": "string"
},
{
"name": "avg_CounterValue",
"type": "real"
}
],
"rows": [
[
"grafana-vm",
1.1
],
[
"grafana-vm",
2.2
],
[
"grafana-vm",
3.3
]
]
}
]
}
@@ -0,0 +1,31 @@
{
"tables": [
{
"name": "PrimaryResult",
"columns": [
{
"name": "TimeGenerated",
"type": "datetime"
},
{
"name": "Computer",
"type": "string"
}
],
"rows": [
[
"2020-04-19T19:16:06.5Z",
"grafana-vm"
],
[
"2020-04-19T19:16:16.5Z",
"grafana-vm"
],
[
"2020-04-19T19:16:26.5Z",
"grafana-vm"
]
]
}
]
}
@@ -0,0 +1,87 @@
{
"tables": [
{
"name": "PrimaryResult",
"columns": [
{
"name": "TenantId",
"type": "string"
},
{
"name": "Computer",
"type": "string"
},
{
"name": "ObjectName",
"type": "string"
},
{
"name": "CounterName",
"type": "string"
},
{
"name": "InstanceName",
"type": "string"
},
{
"name": "Min",
"type": "real"
},
{
"name": "Max",
"type": "real"
},
{
"name": "SampleCount",
"type": "int"
},
{
"name": "CounterValue",
"type": "real"
},
{
"name": "TimeGenerated",
"type": "datetime"
}
],
"rows": [
[
"a2c1b44e-3e57-4410-b027-6cc0ae6dee67",
"grafana-vm",
"Memory",
"Available MBytes Memory",
"Memory",
null,
null,
null,
2040,
"2020-04-23T11:46:03.857Z"
],
[
"a2c1b44e-3e57-4410-b027-6cc0ae6dee67",
"grafana-vm",
"Memory",
"Available MBytes Memory",
"Memory",
null,
null,
null,
2066,
"2020-04-23T11:46:13.857Z"
],
[
"a2c1b44e-3e57-4410-b027-6cc0ae6dee67",
"grafana-vm",
"Memory",
"Available MBytes Memory",
"Memory",
null,
null,
null,
2066,
"2020-04-23T11:46:23.857Z"
]
]
}
]
}