Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
阿信在这里
SkyWalking
提交
a8171978
S
SkyWalking
项目概览
阿信在这里
/
SkyWalking
与 Fork 源项目一致
Fork自
山不在高_有仙则灵 / SkyWalking
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SkyWalking
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a8171978
编写于
2月 08, 2018
作者:
P
peng-yongsheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Provide the getSlowService query.
上级
90c820d1
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
168 addition
and
14 deletion
+168
-14
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceMetricUIDAO.java
...ing/apm/collector/storage/dao/ui/IServiceMetricUIDAO.java
+4
-0
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/alarm/Alarm.java
...ache/skywalking/apm/collector/storage/ui/alarm/Alarm.java
+5
-5
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/alarm/AlarmItem.java
.../skywalking/apm/collector/storage/ui/alarm/AlarmItem.java
+1
-1
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/service/ServiceMetric.java
...lking/apm/collector/storage/ui/service/ServiceMetric.java
+61
-0
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceMetricEsUIDAO.java
...apm/collector/storage/es/dao/ui/ServiceMetricEsUIDAO.java
+60
-0
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceMetricH2UIDAO.java
...apm/collector/storage/h2/dao/ui/ServiceMetricH2UIDAO.java
+7
-2
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/AlarmQuery.java
.../apache/skywalking/apm/collector/ui/query/AlarmQuery.java
+2
-2
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQuery.java
...e/skywalking/apm/collector/ui/query/ApplicationQuery.java
+6
-3
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationService.java
...ywalking/apm/collector/ui/service/ApplicationService.java
+21
-0
apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/application-layer.graphqls
.../src/main/resources/ui-graphql/application-layer.graphqls
+1
-1
未找到文件。
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceMetricUIDAO.java
浏览文件 @
a8171978
...
...
@@ -24,6 +24,7 @@ import org.apache.skywalking.apm.collector.storage.base.dao.DAO;
import
org.apache.skywalking.apm.collector.storage.table.MetricSource
;
import
org.apache.skywalking.apm.collector.storage.ui.common.Node
;
import
org.apache.skywalking.apm.collector.storage.ui.common.Step
;
import
org.apache.skywalking.apm.collector.storage.ui.service.ServiceMetric
;
import
org.apache.skywalking.apm.collector.storage.utils.DurationPoint
;
/**
...
...
@@ -36,4 +37,7 @@ public interface IServiceMetricUIDAO extends DAO {
List
<
Node
>
getServicesMetric
(
Step
step
,
long
startTime
,
long
endTime
,
MetricSource
metricSource
,
Collection
<
Integer
>
serviceIds
);
List
<
ServiceMetric
>
getSlowService
(
int
applicationId
,
Step
step
,
long
start
,
long
end
,
Integer
top
,
MetricSource
metricSource
);
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/alarm/Alarm.java
浏览文件 @
a8171978
...
...
@@ -25,7 +25,7 @@ import java.util.List;
*/
public
class
Alarm
{
private
List
<
AlarmItem
>
items
;
private
Integer
count
;
private
int
total
;
public
List
<
AlarmItem
>
getItems
()
{
return
items
;
...
...
@@ -35,11 +35,11 @@ public class Alarm {
this
.
items
=
items
;
}
public
Integer
getCount
()
{
return
count
;
public
int
getTotal
()
{
return
total
;
}
public
void
set
Count
(
Integer
count
)
{
this
.
count
=
count
;
public
void
set
Total
(
int
total
)
{
this
.
total
=
total
;
}
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/alarm/AlarmItem.java
浏览文件 @
a8171978
...
...
@@ -25,6 +25,6 @@ public class AlarmItem {
private
String
title
;
private
String
content
;
private
String
startTime
;
private
AlarmType
al
ert
Type
;
private
AlarmType
al
arm
Type
;
private
CauseType
causeType
;
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/service/ServiceMetric.java
0 → 100644
浏览文件 @
a8171978
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org.apache.skywalking.apm.collector.storage.ui.service
;
/**
* @author peng-yongsheng
*/
public
class
ServiceMetric
{
private
int
id
;
private
String
name
;
private
int
avgResponseTime
;
private
int
tps
;
public
int
getId
()
{
return
id
;
}
public
void
setId
(
int
id
)
{
this
.
id
=
id
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
int
getAvgResponseTime
()
{
return
avgResponseTime
;
}
public
void
setAvgResponseTime
(
int
avgResponseTime
)
{
this
.
avgResponseTime
=
avgResponseTime
;
}
public
int
getTps
()
{
return
tps
;
}
public
void
setTps
(
int
tps
)
{
this
.
tps
=
tps
;
}
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceMetricEsUIDAO.java
浏览文件 @
a8171978
...
...
@@ -19,8 +19,10 @@
package
org.apache.skywalking.apm.collector.storage.es.dao.ui
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.Map
;
import
org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient
;
import
org.apache.skywalking.apm.collector.core.util.Const
;
import
org.apache.skywalking.apm.collector.storage.dao.ui.IServiceMetricUIDAO
;
...
...
@@ -29,6 +31,7 @@ import org.apache.skywalking.apm.collector.storage.table.MetricSource;
import
org.apache.skywalking.apm.collector.storage.table.service.ServiceMetricTable
;
import
org.apache.skywalking.apm.collector.storage.ui.common.Node
;
import
org.apache.skywalking.apm.collector.storage.ui.common.Step
;
import
org.apache.skywalking.apm.collector.storage.ui.service.ServiceMetric
;
import
org.apache.skywalking.apm.collector.storage.ui.service.ServiceNode
;
import
org.apache.skywalking.apm.collector.storage.utils.DurationPoint
;
import
org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder
;
...
...
@@ -40,16 +43,21 @@ import org.elasticsearch.action.search.SearchResponse;
import
org.elasticsearch.action.search.SearchType
;
import
org.elasticsearch.index.query.BoolQueryBuilder
;
import
org.elasticsearch.index.query.QueryBuilders
;
import
org.elasticsearch.script.Script
;
import
org.elasticsearch.search.aggregations.AggregationBuilders
;
import
org.elasticsearch.search.aggregations.bucket.terms.Terms
;
import
org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder
;
import
org.elasticsearch.search.aggregations.metrics.sum.Sum
;
import
org.elasticsearch.search.aggregations.pipeline.InternalSimpleValue
;
import
org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilders
;
/**
* @author peng-yongsheng
*/
public
class
ServiceMetricEsUIDAO
extends
EsDAO
implements
IServiceMetricUIDAO
{
private
static
final
String
AVG_DURATION
=
"avg_duration"
;
public
ServiceMetricEsUIDAO
(
ElasticSearchClient
client
)
{
super
(
client
);
}
...
...
@@ -143,4 +151,56 @@ public class ServiceMetricEsUIDAO extends EsDAO implements IServiceMetricUIDAO {
});
return
nodes
;
}
@Override
public
List
<
ServiceMetric
>
getSlowService
(
int
applicationId
,
Step
step
,
long
start
,
long
end
,
Integer
top
,
MetricSource
metricSource
)
{
String
tableName
=
TimePyramidTableNameBuilder
.
build
(
step
,
ServiceMetricTable
.
TABLE
);
SearchRequestBuilder
searchRequestBuilder
=
getClient
().
prepareSearch
(
tableName
);
searchRequestBuilder
.
setTypes
(
ServiceMetricTable
.
TABLE_TYPE
);
searchRequestBuilder
.
setSearchType
(
SearchType
.
DFS_QUERY_THEN_FETCH
);
BoolQueryBuilder
boolQuery
=
QueryBuilders
.
boolQuery
();
boolQuery
.
must
().
add
(
QueryBuilders
.
rangeQuery
(
ServiceMetricTable
.
COLUMN_TIME_BUCKET
).
gte
(
start
).
lte
(
end
));
boolQuery
.
must
().
add
(
QueryBuilders
.
termQuery
(
ServiceMetricTable
.
COLUMN_APPLICATION_ID
,
applicationId
));
boolQuery
.
must
().
add
(
QueryBuilders
.
termQuery
(
ServiceMetricTable
.
COLUMN_SOURCE_VALUE
,
metricSource
.
getValue
()));
searchRequestBuilder
.
setQuery
(
boolQuery
);
searchRequestBuilder
.
setSize
(
0
);
TermsAggregationBuilder
aggregationBuilder
=
AggregationBuilders
.
terms
(
ServiceMetricTable
.
COLUMN_SERVICE_ID
).
field
(
ServiceMetricTable
.
COLUMN_SERVICE_ID
).
size
(
100
);
aggregationBuilder
.
subAggregation
(
AggregationBuilders
.
sum
(
ServiceMetricTable
.
COLUMN_TRANSACTION_CALLS
).
field
(
ServiceMetricTable
.
COLUMN_TRANSACTION_CALLS
));
aggregationBuilder
.
subAggregation
(
AggregationBuilders
.
sum
(
ServiceMetricTable
.
COLUMN_TRANSACTION_ERROR_CALLS
).
field
(
ServiceMetricTable
.
COLUMN_TRANSACTION_ERROR_CALLS
));
aggregationBuilder
.
subAggregation
(
AggregationBuilders
.
sum
(
ServiceMetricTable
.
COLUMN_TRANSACTION_DURATION_SUM
).
field
(
ServiceMetricTable
.
COLUMN_TRANSACTION_DURATION_SUM
));
aggregationBuilder
.
subAggregation
(
AggregationBuilders
.
sum
(
ServiceMetricTable
.
COLUMN_TRANSACTION_ERROR_DURATION_SUM
).
field
(
ServiceMetricTable
.
COLUMN_TRANSACTION_ERROR_DURATION_SUM
));
Map
<
String
,
String
>
bucketsPathsMap
=
new
HashMap
<>();
bucketsPathsMap
.
put
(
ServiceMetricTable
.
COLUMN_TRANSACTION_CALLS
,
ServiceMetricTable
.
COLUMN_TRANSACTION_CALLS
);
bucketsPathsMap
.
put
(
ServiceMetricTable
.
COLUMN_TRANSACTION_ERROR_CALLS
,
ServiceMetricTable
.
COLUMN_TRANSACTION_ERROR_CALLS
);
bucketsPathsMap
.
put
(
ServiceMetricTable
.
COLUMN_TRANSACTION_DURATION_SUM
,
ServiceMetricTable
.
COLUMN_TRANSACTION_DURATION_SUM
);
bucketsPathsMap
.
put
(
ServiceMetricTable
.
COLUMN_TRANSACTION_ERROR_DURATION_SUM
,
ServiceMetricTable
.
COLUMN_TRANSACTION_ERROR_DURATION_SUM
);
String
idOrCode
=
"(params."
+
ServiceMetricTable
.
COLUMN_TRANSACTION_DURATION_SUM
+
" - params."
+
ServiceMetricTable
.
COLUMN_TRANSACTION_ERROR_DURATION_SUM
+
")"
+
" / "
+
"(params."
+
ServiceMetricTable
.
COLUMN_TRANSACTION_CALLS
+
" - params."
+
ServiceMetricTable
.
COLUMN_TRANSACTION_ERROR_CALLS
+
")"
;
Script
script
=
new
Script
(
idOrCode
);
aggregationBuilder
.
subAggregation
(
PipelineAggregatorBuilders
.
bucketScript
(
AVG_DURATION
,
bucketsPathsMap
,
script
));
searchRequestBuilder
.
addAggregation
(
aggregationBuilder
);
SearchResponse
searchResponse
=
searchRequestBuilder
.
execute
().
actionGet
();
List
<
ServiceMetric
>
serviceMetrics
=
new
LinkedList
<>();
Terms
serviceIdTerms
=
searchResponse
.
getAggregations
().
get
(
ServiceMetricTable
.
COLUMN_SERVICE_ID
);
serviceIdTerms
.
getBuckets
().
forEach
(
serviceIdTerm
->
{
int
serviceId
=
serviceIdTerm
.
getKeyAsNumber
().
intValue
();
ServiceMetric
serviceMetric
=
new
ServiceMetric
();
InternalSimpleValue
simpleValue
=
serviceIdTerm
.
getAggregations
().
get
(
AVG_DURATION
);
serviceMetric
.
setId
(
serviceId
);
serviceMetric
.
setAvgResponseTime
((
int
)
simpleValue
.
getValue
());
serviceMetrics
.
add
(
serviceMetric
);
});
return
serviceMetrics
;
}
}
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceMetricH2UIDAO.java
浏览文件 @
a8171978
...
...
@@ -33,6 +33,7 @@ import org.apache.skywalking.apm.collector.storage.table.MetricSource;
import
org.apache.skywalking.apm.collector.storage.table.service.ServiceMetricTable
;
import
org.apache.skywalking.apm.collector.storage.ui.common.Node
;
import
org.apache.skywalking.apm.collector.storage.ui.common.Step
;
import
org.apache.skywalking.apm.collector.storage.ui.service.ServiceMetric
;
import
org.apache.skywalking.apm.collector.storage.utils.DurationPoint
;
import
org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder
;
import
org.slf4j.Logger
;
...
...
@@ -106,9 +107,13 @@ public class ServiceMetricH2UIDAO extends H2DAO implements IServiceMetricUIDAO {
return
trends
;
}
@Override
public
List
<
Node
>
getServicesMetric
(
Step
step
,
long
startTime
,
long
endTime
,
MetricSource
metricSource
,
@Override
public
List
<
Node
>
getServicesMetric
(
Step
step
,
long
startTime
,
long
endTime
,
MetricSource
metricSource
,
Collection
<
Integer
>
serviceIds
)
{
return
null
;
}
@Override
public
List
<
ServiceMetric
>
getSlowService
(
int
applicationId
,
Step
step
,
long
start
,
long
end
,
Integer
top
,
MetricSource
metricSource
)
{
return
null
;
}
}
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/AlarmQuery.java
浏览文件 @
a8171978
...
...
@@ -29,9 +29,9 @@ import org.apache.skywalking.apm.collector.storage.ui.common.Pagination;
*/
public
class
AlarmQuery
implements
Query
{
public
Alarm
loadAl
ertList
(
String
keyword
,
AlarmType
alarmType
,
Duration
duration
,
Pagination
pagination
)
{
public
Alarm
loadAl
armList
(
String
keyword
,
AlarmType
alarmType
,
Duration
duration
,
Pagination
paging
)
{
Alarm
alarm
=
new
Alarm
();
alarm
.
set
Count
(
0
);
alarm
.
set
Total
(
0
);
return
alarm
;
}
}
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQuery.java
浏览文件 @
a8171978
...
...
@@ -26,7 +26,7 @@ import org.apache.skywalking.apm.collector.storage.ui.application.Application;
import
org.apache.skywalking.apm.collector.storage.ui.common.Duration
;
import
org.apache.skywalking.apm.collector.storage.ui.common.Topology
;
import
org.apache.skywalking.apm.collector.storage.ui.server.AppServerInfo
;
import
org.apache.skywalking.apm.collector.storage.ui.service.Service
Info
;
import
org.apache.skywalking.apm.collector.storage.ui.service.Service
Metric
;
import
org.apache.skywalking.apm.collector.ui.graphql.Query
;
import
org.apache.skywalking.apm.collector.ui.service.ApplicationService
;
import
org.apache.skywalking.apm.collector.ui.service.ApplicationTopologyService
;
...
...
@@ -73,8 +73,11 @@ public class ApplicationQuery implements Query {
return
getApplicationTopologyService
().
getApplicationTopology
(
duration
.
getStep
(),
applicationId
,
start
,
end
);
}
public
List
<
ServiceInfo
>
getSlowService
(
int
applicationId
,
Duration
duration
,
Integer
top
)
{
return
null
;
public
List
<
ServiceMetric
>
getSlowService
(
int
applicationId
,
Duration
duration
,
Integer
top
)
throws
ParseException
{
long
start
=
DurationUtils
.
INSTANCE
.
exchangeToTimeBucket
(
duration
.
getStart
());
long
end
=
DurationUtils
.
INSTANCE
.
exchangeToTimeBucket
(
duration
.
getEnd
());
return
getApplicationService
().
getSlowService
(
applicationId
,
duration
.
getStep
(),
start
,
end
,
top
);
}
public
List
<
AppServerInfo
>
getServerThroughput
(
int
applicationId
,
Duration
duration
,
Integer
top
)
{
...
...
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationService.java
浏览文件 @
a8171978
...
...
@@ -18,13 +18,19 @@
package
org.apache.skywalking.apm.collector.ui.service
;
import
java.text.ParseException
;
import
java.util.List
;
import
org.apache.skywalking.apm.collector.cache.CacheModule
;
import
org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService
;
import
org.apache.skywalking.apm.collector.cache.service.ServiceNameCacheService
;
import
org.apache.skywalking.apm.collector.core.module.ModuleManager
;
import
org.apache.skywalking.apm.collector.storage.StorageModule
;
import
org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceUIDAO
;
import
org.apache.skywalking.apm.collector.storage.dao.ui.IServiceMetricUIDAO
;
import
org.apache.skywalking.apm.collector.storage.table.MetricSource
;
import
org.apache.skywalking.apm.collector.storage.ui.application.Application
;
import
org.apache.skywalking.apm.collector.storage.ui.common.Step
;
import
org.apache.skywalking.apm.collector.storage.ui.service.ServiceMetric
;
/**
* @author peng-yongsheng
...
...
@@ -32,11 +38,15 @@ import org.apache.skywalking.apm.collector.storage.ui.application.Application;
public
class
ApplicationService
{
private
final
IInstanceUIDAO
instanceDAO
;
private
final
IServiceMetricUIDAO
serviceMetricUIDAO
;
private
final
ApplicationCacheService
applicationCacheService
;
private
final
ServiceNameCacheService
serviceNameCacheService
;
public
ApplicationService
(
ModuleManager
moduleManager
)
{
this
.
instanceDAO
=
moduleManager
.
find
(
StorageModule
.
NAME
).
getService
(
IInstanceUIDAO
.
class
);
this
.
serviceMetricUIDAO
=
moduleManager
.
find
(
StorageModule
.
NAME
).
getService
(
IServiceMetricUIDAO
.
class
);
this
.
applicationCacheService
=
moduleManager
.
find
(
CacheModule
.
NAME
).
getService
(
ApplicationCacheService
.
class
);
this
.
serviceNameCacheService
=
moduleManager
.
find
(
CacheModule
.
NAME
).
getService
(
ServiceNameCacheService
.
class
);
}
public
List
<
Application
>
getApplications
(
long
startTime
,
long
endTime
,
int
...
applicationIds
)
{
...
...
@@ -48,4 +58,15 @@ public class ApplicationService {
});
return
applications
;
}
public
List
<
ServiceMetric
>
getSlowService
(
int
applicationId
,
Step
step
,
long
start
,
long
end
,
Integer
top
)
throws
ParseException
{
List
<
ServiceMetric
>
slowServices
=
serviceMetricUIDAO
.
getSlowService
(
applicationId
,
step
,
start
,
end
,
top
,
MetricSource
.
Callee
);
slowServices
.
forEach
(
slowService
->
{
slowService
.
setName
(
serviceNameCacheService
.
get
(
slowService
.
getId
()).
getServiceName
());
//TODO
slowService
.
setTps
(
1
);
});
return
slowServices
;
}
}
apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/application-layer.graphqls
浏览文件 @
a8171978
...
...
@@ -43,6 +43,6 @@ type Application {
extend type Query {
getAllApplication(duration: Duration!): [Application!]!
getApplicationTopology(applicationId: ID!, duration: Duration!): Topology
getSlowService(applicationId: ID!, duration: Duration!, top: Int!): [Service
Info
!]!
getSlowService(applicationId: ID!, duration: Duration!, top: Int!): [Service
Metric
!]!
getServerThroughput(applicationId: ID!, duration: Duration!, top: Int!): [AppServerInfo!]!
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录