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
b3edad40
Commit
b3edad40
authored
Oct 29, 2018
by
Erik Sundell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stackdriver: add resource types query
parent
cb0d563a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
22 deletions
+63
-22
public/app/plugins/datasource/stackdriver/StackdriverMetricFindQuery.ts
+32
-2
public/app/plugins/datasource/stackdriver/components/TemplateQueryComponent.tsx
+31
-20
No files found.
public/app/plugins/datasource/stackdriver/StackdriverMetricFindQuery.ts
View file @
b3edad40
...
@@ -13,6 +13,8 @@ export default class StackdriverMetricFindQuery {
...
@@ -13,6 +13,8 @@ export default class StackdriverMetricFindQuery {
case
'metricLabels'
:
case
'metricLabels'
:
case
'resourceLabels'
:
case
'resourceLabels'
:
return
this
.
handleLabelQueryType
(
query
);
return
this
.
handleLabelQueryType
(
query
);
case
'resourceTypes'
:
return
this
.
handleResourceType
(
query
);
default
:
default
:
return
[];
return
[];
}
}
...
@@ -40,11 +42,23 @@ export default class StackdriverMetricFindQuery {
...
@@ -40,11 +42,23 @@ export default class StackdriverMetricFindQuery {
}));
}));
}
}
async
handleLabelQueryType
({
type
,
metricType
,
metricLabelKey
,
resourceLabelKey
})
{
getLabelKey
({
type
,
metricLabelKey
,
resourceLabelKey
})
{
switch
(
type
)
{
case
'metricLabels'
:
return
metricLabelKey
;
break
;
case
'resourceLabels'
:
return
resourceLabelKey
;
default
:
return
''
;
}
}
async
handleLabelQueryType
({
type
,
metricType
,
metricLabelKey
,
resourceLabelKey
,
resourceTypeKey
})
{
if
(
!
metricType
)
{
if
(
!
metricType
)
{
return
[];
return
[];
}
}
const
key
=
t
ype
===
'metricLabels'
?
metricLabelKey
:
resourceLabelKey
;
const
key
=
t
his
.
getLabelKey
({
type
,
metricLabelKey
,
resourceLabelKey
})
;
const
refId
=
'handleLabelsQueryType'
;
const
refId
=
'handleLabelsQueryType'
;
const
response
=
await
this
.
datasource
.
getLabels
(
metricType
,
refId
);
const
response
=
await
this
.
datasource
.
getLabels
(
metricType
,
refId
);
if
(
!
has
(
response
,
`meta.
${
type
}
.
${
key
}
`
))
{
if
(
!
has
(
response
,
`meta.
${
type
}
.
${
key
}
`
))
{
...
@@ -55,4 +69,20 @@ export default class StackdriverMetricFindQuery {
...
@@ -55,4 +69,20 @@ export default class StackdriverMetricFindQuery {
expandable
:
true
,
expandable
:
true
,
}));
}));
}
}
async
handleResourceType
({
metricType
})
{
if
(
!
metricType
)
{
return
[];
}
try
{
const
refId
=
'handleResourceTypeQueryType'
;
const
response
=
await
this
.
datasource
.
getLabels
(
metricType
,
refId
);
return
response
.
meta
.
resourceTypes
.
map
(
s
=>
({
text
:
s
,
expandable
:
true
,
}));
}
catch
(
error
)
{
return
[];
}
}
}
}
public/app/plugins/datasource/stackdriver/components/TemplateQueryComponent.tsx
View file @
b3edad40
...
@@ -44,6 +44,10 @@ export class StackdriverTemplateQueryComponent extends PureComponent<TemplateQue
...
@@ -44,6 +44,10 @@ export class StackdriverTemplateQueryComponent extends PureComponent<TemplateQue
this
.
setState
({
metricDescriptors
});
this
.
setState
({
metricDescriptors
});
}
}
isLabelQuery
(
queryType
)
{
return
[
'metricLabels'
,
'resourceLabels'
].
indexOf
(
queryType
)
!==
-
1
;
}
async
loadTimeSeriesData
()
{
async
loadTimeSeriesData
()
{
const
refId
=
'StackdriverTemplateQueryComponent'
;
const
refId
=
'StackdriverTemplateQueryComponent'
;
const
response
=
await
this
.
props
.
datasource
.
getLabels
(
this
.
state
.
metricType
,
refId
);
const
response
=
await
this
.
props
.
datasource
.
getLabels
(
this
.
state
.
metricType
,
refId
);
...
@@ -52,10 +56,6 @@ export class StackdriverTemplateQueryComponent extends PureComponent<TemplateQue
...
@@ -52,10 +56,6 @@ export class StackdriverTemplateQueryComponent extends PureComponent<TemplateQue
}
}
}
}
isLabelQuery
(
queryType
)
{
return
[
'metricLabels'
,
'resourceLabels'
].
indexOf
(
queryType
)
!==
-
1
;
}
handleQueryTypeChange
(
event
)
{
handleQueryTypeChange
(
event
)
{
this
.
setState
({
type
:
event
.
target
.
value
});
this
.
setState
({
type
:
event
.
target
.
value
});
if
(
this
.
isLabelQuery
(
event
.
target
.
value
))
{
if
(
this
.
isLabelQuery
(
event
.
target
.
value
))
{
...
@@ -87,6 +87,31 @@ export class StackdriverTemplateQueryComponent extends PureComponent<TemplateQue
...
@@ -87,6 +87,31 @@ export class StackdriverTemplateQueryComponent extends PureComponent<TemplateQue
this
.
props
.
onChange
(
queryModel
);
this
.
props
.
onChange
(
queryModel
);
}
}
switchMetaType
(
queryType
)
{
switch
(
queryType
)
{
case
'resourceLabels'
:
return
(
<
SimpleDropdown
value=
{
this
.
state
.
resourceLabelKey
}
options=
{
this
.
state
.
resourceLabels
}
onValueChange=
{
this
.
onResourceLabelKeyChange
}
label=
"Resource Labels"
/>
);
case
'metricLabels'
:
return
(
<
SimpleDropdown
value=
{
this
.
state
.
metricLabelKey
}
options=
{
this
.
state
.
metricLabels
}
onValueChange=
{
this
.
onMetricLabelKeyChange
}
label=
"Metric Labels"
/>
);
default
:
return
''
;
}
}
renderSwitch
(
queryType
)
{
renderSwitch
(
queryType
)
{
switch
(
queryType
)
{
switch
(
queryType
)
{
case
'metricTypes'
:
case
'metricTypes'
:
...
@@ -95,22 +120,8 @@ export class StackdriverTemplateQueryComponent extends PureComponent<TemplateQue
...
@@ -95,22 +120,8 @@ export class StackdriverTemplateQueryComponent extends PureComponent<TemplateQue
);
);
case
'metricLabels'
:
case
'metricLabels'
:
case
'resourceLabels'
:
case
'resourceLabels'
:
const
dropdown
=
case
'resourceTypes'
:
queryType
===
'resourceLabels'
?
(
const
dropdown
=
this
.
switchMetaType
(
queryType
);
<
SimpleDropdown
value=
{
this
.
state
.
resourceLabelKey
}
options=
{
this
.
state
.
resourceLabels
}
onValueChange=
{
this
.
onResourceLabelKeyChange
}
label=
"Resource Labels"
/>
)
:
(
<
SimpleDropdown
value=
{
this
.
state
.
metricLabelKey
}
options=
{
this
.
state
.
metricLabels
}
onValueChange=
{
this
.
onMetricLabelKeyChange
}
label=
"Metric Labels"
/>
);
return
(
return
(
<
React
.
Fragment
>
<
React
.
Fragment
>
<
ServiceSelector
metricDescriptors=
{
this
.
state
.
metricDescriptors
}
onServiceChange=
{
this
.
onServiceChange
}
/>
<
ServiceSelector
metricDescriptors=
{
this
.
state
.
metricDescriptors
}
onServiceChange=
{
this
.
onServiceChange
}
/>
...
...
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