Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
skywalking-cli
提交
61a80813
S
skywalking-cli
项目概览
apache
/
skywalking-cli
通知
19
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
skywalking-cli
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
61a80813
编写于
7月 30, 2020
作者:
H
Hoshea Jiang
提交者:
GitHub
7月 30, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix `dashboard global` command cannot return json result (#49)
上级
6ae6ca04
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
46 addition
and
8 deletion
+46
-8
assets/graphqls/dashboard/LabeledMetricsValues.graphql
assets/graphqls/dashboard/LabeledMetricsValues.graphql
+2
-2
commands/dashboard/global/global.go
commands/dashboard/global/global.go
+11
-1
graphql/dashboard/global.go
graphql/dashboard/global.go
+33
-5
未找到文件。
assets/graphqls/dashboard/LabeledMetricsValues.graphql
浏览文件 @
61a80813
...
...
@@ -15,8 +15,8 @@
# specific language governing permissions and limitations
# under the License.
query
(
$condition
:
MetricsCondition
!,
$label
:
[
String
!]!,
$duration
:
Duration
!)
{
result
:
readLabeledMetricsValues
(
condition
:
$condition
,
labels
:
$label
,
duration
:
$duration
)
{
query
(
$condition
:
MetricsCondition
!,
$label
s
:
[
String
!]!,
$duration
:
Duration
!)
{
result
:
readLabeledMetricsValues
(
condition
:
$condition
,
labels
:
$label
s
,
duration
:
$duration
)
{
label
values
{
values
{
...
...
commands/dashboard/global/global.go
浏览文件 @
61a80813
...
...
@@ -36,7 +36,17 @@ var GlobalCommand = cli.Command{
ShortName
:
"g"
,
Usage
:
"Display global data"
,
Description
:
"Display global data"
,
Flags
:
flags
.
DurationFlags
,
Flags
:
flags
.
Flags
(
flags
.
DurationFlags
,
[]
cli
.
Flag
{
cli
.
StringFlag
{
Name
:
"template"
,
Usage
:
"load dashboard UI template"
,
Required
:
false
,
Value
:
dashboard
.
DefaultTemplatePath
,
},
},
),
Before
:
interceptor
.
BeforeChain
([]
cli
.
BeforeFunc
{
interceptor
.
TimezoneInterceptor
,
interceptor
.
DurationInterceptor
,
...
...
graphql/dashboard/global.go
浏览文件 @
61a80813
...
...
@@ -21,6 +21,7 @@ import (
"encoding/json"
"io/ioutil"
"os"
"strings"
"github.com/machinebox/graphql"
"github.com/urfave/cli"
...
...
@@ -56,10 +57,18 @@ type GlobalData struct {
HeatMap
schema
.
HeatMap
`json:"heatMap"`
}
// Use singleton pattern to make sure to load template only once.
var
globalTemplate
*
GlobalTemplate
const
DefaultTemplatePath
=
"templates/Dashboard.Global.json"
// LoadTemplate reads UI template from file.
func
LoadTemplate
(
filename
string
)
(
*
GlobalTemplate
,
error
)
{
var
config
GlobalTemplate
if
globalTemplate
!=
nil
{
return
globalTemplate
,
nil
}
var
t
GlobalTemplate
var
byteValue
[]
byte
if
filename
==
DefaultTemplatePath
{
...
...
@@ -78,20 +87,22 @@ func LoadTemplate(filename string) (*GlobalTemplate, error) {
}
}
if
err
:=
json
.
Unmarshal
(
byteValue
,
&
config
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
(
byteValue
,
&
t
);
err
!=
nil
{
return
nil
,
err
}
return
&
config
,
nil
globalTemplate
=
&
t
return
globalTemplate
,
nil
}
func
Metrics
(
ctx
*
cli
.
Context
,
duration
schema
.
Duration
)
[][]
*
schema
.
SelectedRecord
{
var
ret
[][]
*
schema
.
SelectedRecord
configs
,
err
:=
LoadTemplate
(
ctx
.
String
(
"template"
))
template
,
err
:=
LoadTemplate
(
ctx
.
String
(
"template"
))
if
err
!=
nil
{
return
nil
}
for
_
,
m
:=
range
configs
.
Metrics
{
for
_
,
m
:=
range
template
.
Metrics
{
var
response
map
[
string
][]
*
schema
.
SelectedRecord
request
:=
graphql
.
NewRequest
(
assets
.
Read
(
"graphqls/dashboard/SortMetrics.graphql"
))
request
.
Var
(
"condition"
,
m
.
Condition
)
...
...
@@ -107,8 +118,19 @@ func Metrics(ctx *cli.Context, duration schema.Duration) [][]*schema.SelectedRec
func
responseLatency
(
ctx
*
cli
.
Context
,
duration
schema
.
Duration
)
[]
*
schema
.
MetricsValues
{
var
response
map
[
string
][]
*
schema
.
MetricsValues
template
,
err
:=
LoadTemplate
(
ctx
.
String
(
"template"
))
if
err
!=
nil
{
return
nil
}
// labels in the template file is string type,
// need to convert to string array for graphql query.
labels
:=
strings
.
Split
(
template
.
ResponseLatency
.
Labels
,
","
)
request
:=
graphql
.
NewRequest
(
assets
.
Read
(
"graphqls/dashboard/LabeledMetricsValues.graphql"
))
request
.
Var
(
"duration"
,
duration
)
request
.
Var
(
"condition"
,
template
.
ResponseLatency
.
Condition
)
request
.
Var
(
"labels"
,
labels
)
client
.
ExecuteQueryOrFail
(
ctx
,
request
,
&
response
)
...
...
@@ -118,8 +140,14 @@ func responseLatency(ctx *cli.Context, duration schema.Duration) []*schema.Metri
func
heatMap
(
ctx
*
cli
.
Context
,
duration
schema
.
Duration
)
schema
.
HeatMap
{
var
response
map
[
string
]
schema
.
HeatMap
template
,
err
:=
LoadTemplate
(
ctx
.
String
(
"template"
))
if
err
!=
nil
{
return
schema
.
HeatMap
{}
}
request
:=
graphql
.
NewRequest
(
assets
.
Read
(
"graphqls/dashboard/HeatMap.graphql"
))
request
.
Var
(
"duration"
,
duration
)
request
.
Var
(
"condition"
,
template
.
HeatMap
.
Condition
)
client
.
ExecuteQueryOrFail
(
ctx
,
request
,
&
response
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录