Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
c724449d
Unverified
Commit
c724449d
authored
Aug 21, 2020
by
Kyle Brandt
Committed by
GitHub
Aug 21, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AzureMonitor: fix panic introduced in 7.1.4 (#27113)
happens when unit was "Unspecified" and alias is being used
parent
a6cc6429
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
1 deletions
+61
-1
pkg/tsdb/azuremonitor/azuremonitor-datasource.go
+9
-1
pkg/tsdb/azuremonitor/azuremonitor-datasource_test.go
+21
-0
pkg/tsdb/azuremonitor/testdata/azuremonitor/8-azure-monitor-response-unspecified-unit.json
+31
-0
No files found.
pkg/tsdb/azuremonitor/azuremonitor-datasource.go
View file @
c724449d
...
...
@@ -299,8 +299,16 @@ func (e *AzureMonitorDatasource) parseResponse(queryRes *tsdb.QueryResult, amr A
})
}
if
query
.
Alias
!=
""
{
d
ataField
.
Config
.
DisplayName
=
formatAzureMonitorLegendKey
(
query
.
Alias
,
query
.
UrlComponents
[
"resourceName"
],
d
isplayName
:
=
formatAzureMonitorLegendKey
(
query
.
Alias
,
query
.
UrlComponents
[
"resourceName"
],
amr
.
Value
[
0
]
.
Name
.
LocalizedValue
,
""
,
""
,
amr
.
Namespace
,
amr
.
Value
[
0
]
.
ID
,
labels
)
if
dataField
.
Config
!=
nil
{
dataField
.
Config
.
DisplayName
=
displayName
}
else
{
dataField
.
SetConfig
(
&
data
.
FieldConfig
{
DisplayName
:
displayName
,
})
}
}
requestedAgg
:=
query
.
Params
.
Get
(
"aggregation"
)
...
...
pkg/tsdb/azuremonitor/azuremonitor-datasource_test.go
View file @
c724449d
...
...
@@ -405,6 +405,27 @@ func TestAzureMonitorParseResponse(t *testing.T) {
&
data
.
FieldConfig
{
Unit
:
"decbytes"
,
DisplayName
:
"danieltest {Blob Type=Azure Data Lake Storage, Tier=Cool}"
})),
},
},
{
name
:
"unspecified unit with alias should not panic"
,
responseFile
:
"8-azure-monitor-response-unspecified-unit.json"
,
mockQuery
:
&
AzureMonitorQuery
{
Alias
:
"custom"
,
UrlComponents
:
map
[
string
]
string
{
"resourceName"
:
"grafana"
,
},
Params
:
url
.
Values
{
"aggregation"
:
{
"Average"
},
},
},
expectedFrames
:
data
.
Frames
{
data
.
NewFrame
(
""
,
data
.
NewField
(
""
,
nil
,
[]
time
.
Time
{
time
.
Date
(
2019
,
2
,
8
,
10
,
13
,
0
,
0
,
time
.
UTC
)}),
data
.
NewField
(
"Percentage CPU"
,
nil
,
[]
float64
{
2.0875
,
})
.
SetConfig
(
&
data
.
FieldConfig
{
DisplayName
:
"custom"
})),
},
},
}
datasource
:=
&
AzureMonitorDatasource
{}
...
...
pkg/tsdb/azuremonitor/testdata/azuremonitor/8-azure-monitor-response-unspecified-unit.json
0 → 100644
View file @
c724449d
{
"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"
:
"Unspecified"
,
"timeseries"
:
[
{
"metadatavalues"
:
[
],
"data"
:
[
{
"timeStamp"
:
"2019-02-08T10:13:00Z"
,
"average"
:
2.0875
}
]
}
]
}
],
"namespace"
:
"Microsoft.Compute
\/
virtualMachines"
,
"resourceregion"
:
"westeurope"
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment