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
b8c2ba33
Commit
b8c2ba33
authored
Jan 08, 2019
by
Erik Sundell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add typing for metric descriptor
parent
8867d8e9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
8 deletions
+21
-8
public/app/plugins/datasource/stackdriver/components/Metrics.tsx
+6
-5
public/app/plugins/datasource/stackdriver/components/QueryEditor.tsx
+2
-2
public/app/plugins/datasource/stackdriver/datasource.ts
+2
-1
public/app/plugins/datasource/stackdriver/types.ts
+11
-0
No files found.
public/app/plugins/datasource/stackdriver/components/Metrics.tsx
View file @
b8c2ba33
...
@@ -2,10 +2,11 @@ import React from 'react';
...
@@ -2,10 +2,11 @@ import React from 'react';
import
_
from
'lodash'
;
import
_
from
'lodash'
;
import
appEvents
from
'app/core/app_events'
;
import
appEvents
from
'app/core/app_events'
;
import
{
MetricDescriptor
}
from
'../types'
;
import
{
MetricSelect
}
from
'app/core/components/Select/MetricSelect'
;
import
{
MetricSelect
}
from
'app/core/components/Select/MetricSelect'
;
export
interface
Props
{
export
interface
Props
{
onChange
:
(
metricDescriptor
)
=>
void
;
onChange
:
(
metricDescriptor
:
MetricDescriptor
)
=>
void
;
templateSrv
:
any
;
templateSrv
:
any
;
datasource
:
any
;
datasource
:
any
;
defaultProject
:
string
;
defaultProject
:
string
;
...
@@ -14,12 +15,12 @@ export interface Props {
...
@@ -14,12 +15,12 @@ export interface Props {
}
}
interface
State
{
interface
State
{
metricDescriptors
:
any
[];
metricDescriptors
:
MetricDescriptor
[];
metrics
:
any
[];
metrics
:
any
[];
services
:
any
[];
services
:
any
[];
service
:
string
;
service
:
string
;
metric
:
string
;
metric
:
string
;
metricDescriptor
:
any
;
metricDescriptor
:
MetricDescriptor
;
defaultProject
:
string
;
defaultProject
:
string
;
}
}
...
@@ -84,7 +85,7 @@ export class Metrics extends React.Component<Props, State> {
...
@@ -84,7 +85,7 @@ export class Metrics extends React.Component<Props, State> {
return
this
.
state
.
metricDescriptors
.
find
(
md
=>
md
.
type
===
this
.
props
.
templateSrv
.
replace
(
metricType
));
return
this
.
state
.
metricDescriptors
.
find
(
md
=>
md
.
type
===
this
.
props
.
templateSrv
.
replace
(
metricType
));
}
}
getMetricsList
(
metricDescriptors
)
{
getMetricsList
(
metricDescriptors
:
MetricDescriptor
[]
)
{
const
selectedMetricDescriptor
=
this
.
getSelectedMetricDescriptor
(
this
.
props
.
metricType
);
const
selectedMetricDescriptor
=
this
.
getSelectedMetricDescriptor
(
this
.
props
.
metricType
);
if
(
!
selectedMetricDescriptor
)
{
if
(
!
selectedMetricDescriptor
)
{
return
[];
return
[];
...
@@ -122,7 +123,7 @@ export class Metrics extends React.Component<Props, State> {
...
@@ -122,7 +123,7 @@ export class Metrics extends React.Component<Props, State> {
this
.
props
.
onChange
({
...
metricDescriptor
,
type
:
value
});
this
.
props
.
onChange
({
...
metricDescriptor
,
type
:
value
});
}
}
getServicesList
(
metricDescriptors
)
{
getServicesList
(
metricDescriptors
:
MetricDescriptor
[]
)
{
const
services
=
metricDescriptors
.
map
(
m
=>
({
const
services
=
metricDescriptors
.
map
(
m
=>
({
value
:
m
.
service
,
value
:
m
.
service
,
label
:
_
.
startCase
(
m
.
serviceShortName
),
label
:
_
.
startCase
(
m
.
serviceShortName
),
...
...
public/app/plugins/datasource/stackdriver/components/QueryEditor.tsx
View file @
b8c2ba33
...
@@ -8,7 +8,7 @@ import { Alignments } from './Alignments';
...
@@ -8,7 +8,7 @@ import { Alignments } from './Alignments';
import
{
AlignmentPeriods
}
from
'./AlignmentPeriods'
;
import
{
AlignmentPeriods
}
from
'./AlignmentPeriods'
;
import
{
AliasBy
}
from
'./AliasBy'
;
import
{
AliasBy
}
from
'./AliasBy'
;
import
{
Help
}
from
'./Help'
;
import
{
Help
}
from
'./Help'
;
import
{
Target
}
from
'../types'
;
import
{
Target
,
MetricDescriptor
}
from
'../types'
;
import
{
getAlignmentPickerData
}
from
'../functions'
;
import
{
getAlignmentPickerData
}
from
'../functions'
;
export
interface
Props
{
export
interface
Props
{
...
@@ -92,7 +92,7 @@ export class QueryEditor extends React.Component<Props, State> {
...
@@ -92,7 +92,7 @@ export class QueryEditor extends React.Component<Props, State> {
this
.
setState
({
lastQuery
,
lastQueryError
});
this
.
setState
({
lastQuery
,
lastQueryError
});
}
}
onMetricTypeChange
({
valueType
,
metricKind
,
type
,
unit
})
{
onMetricTypeChange
({
valueType
,
metricKind
,
type
,
unit
}
:
MetricDescriptor
)
{
const
{
templateSrv
,
onQueryChange
,
onExecuteQuery
}
=
this
.
props
;
const
{
templateSrv
,
onQueryChange
,
onExecuteQuery
}
=
this
.
props
;
const
{
perSeriesAligner
,
alignOptions
}
=
getAlignmentPickerData
(
const
{
perSeriesAligner
,
alignOptions
}
=
getAlignmentPickerData
(
{
valueType
,
metricKind
,
perSeriesAligner
:
this
.
state
.
perSeriesAligner
},
{
valueType
,
metricKind
,
perSeriesAligner
:
this
.
state
.
perSeriesAligner
},
...
...
public/app/plugins/datasource/stackdriver/datasource.ts
View file @
b8c2ba33
...
@@ -2,6 +2,7 @@ import { stackdriverUnitMappings } from './constants';
...
@@ -2,6 +2,7 @@ import { stackdriverUnitMappings } from './constants';
import
appEvents
from
'app/core/app_events'
;
import
appEvents
from
'app/core/app_events'
;
import
_
from
'lodash'
;
import
_
from
'lodash'
;
import
StackdriverMetricFindQuery
from
'./StackdriverMetricFindQuery'
;
import
StackdriverMetricFindQuery
from
'./StackdriverMetricFindQuery'
;
import
{
MetricDescriptor
}
from
'./types'
;
export
default
class
StackdriverDatasource
{
export
default
class
StackdriverDatasource
{
id
:
number
;
id
:
number
;
...
@@ -253,7 +254,7 @@ export default class StackdriverDatasource {
...
@@ -253,7 +254,7 @@ export default class StackdriverDatasource {
}
}
}
}
async
getMetricTypes
(
projectName
:
string
)
{
async
getMetricTypes
(
projectName
:
string
)
:
Promise
<
MetricDescriptor
[]
>
{
try
{
try
{
if
(
this
.
metricTypes
.
length
===
0
)
{
if
(
this
.
metricTypes
.
length
===
0
)
{
const
metricsApiPath
=
`v3/projects/
${
projectName
}
/metricDescriptors`
;
const
metricsApiPath
=
`v3/projects/
${
projectName
}
/metricDescriptors`
;
...
...
public/app/plugins/datasource/stackdriver/types.ts
View file @
b8c2ba33
...
@@ -55,3 +55,14 @@ export interface QueryMeta {
...
@@ -55,3 +55,14 @@ export interface QueryMeta {
resourceLabels
:
{
[
key
:
string
]:
string
[]
};
resourceLabels
:
{
[
key
:
string
]:
string
[]
};
resourceTypes
:
string
[];
resourceTypes
:
string
[];
}
}
export
interface
MetricDescriptor
{
valueType
:
string
;
metricKind
:
string
;
type
:
string
;
unit
:
string
;
service
:
string
;
serviceShortName
:
string
;
displayName
:
string
;
description
:
string
;
}
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