Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
KubeSphere
kubesphere
提交
4f8fc3d4
K
kubesphere
项目概览
KubeSphere
/
kubesphere
通知
138
Star
32
Fork
5
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
2
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kubesphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
2
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
4f8fc3d4
编写于
3月 11, 2021
作者:
K
KubeSphere CI Bot
提交者:
GitHub
3月 11, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3447 from wanjunlei/es
fix bug can not search auditing logs with nil namespace
上级
93ede4b7
a6cb91e6
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
15 addition
and
21 deletion
+15
-21
pkg/simple/client/auditing/elasticsearch/elasticsearch.go
pkg/simple/client/auditing/elasticsearch/elasticsearch.go
+5
-5
pkg/simple/client/auditing/elasticsearch/elasticsearch_test.go
...imple/client/auditing/elasticsearch/elasticsearch_test.go
+5
-5
pkg/simple/client/es/response.go
pkg/simple/client/es/response.go
+5
-5
pkg/simple/client/events/elasticsearch/elasticsearch.go
pkg/simple/client/events/elasticsearch/elasticsearch.go
+0
-6
未找到文件。
pkg/simple/client/auditing/elasticsearch/elasticsearch.go
浏览文件 @
4f8fc3d4
...
...
@@ -114,14 +114,14 @@ func parseToQueryPart(f *auditing.Filter) *query.Query {
bi
:=
query
.
NewBool
()
.
WithMinimumShouldMatch
(
mini
)
for
k
,
v
:=
range
f
.
ObjectRefNamespaceMap
{
bi
.
AppendShould
(
query
.
NewBool
()
.
AppendFilter
(
query
.
NewMatchPhrase
(
"ObjectRef.Namespace"
,
k
))
.
AppendFilter
(
query
.
NewMatchPhrase
(
"ObjectRef.Namespace
.keyword
"
,
k
))
.
AppendFilter
(
query
.
NewRange
(
"RequestReceivedTimestamp"
)
.
WithGTE
(
v
)))
}
for
k
,
v
:=
range
f
.
WorkspaceMap
{
bi
.
AppendShould
(
query
.
NewBool
()
.
AppendFilter
(
query
.
NewMatchPhrase
(
"Workspace"
,
k
))
.
AppendFilter
(
query
.
NewMatchPhrase
(
"Workspace
.keyword
"
,
k
))
.
AppendFilter
(
query
.
NewRange
(
"RequestReceivedTimestamp"
)
.
WithGTE
(
v
)))
}
...
...
@@ -159,10 +159,10 @@ func parseToQueryPart(f *auditing.Filter) *query.Query {
b
.
AppendFilter
(
bi
)
b
.
AppendFilter
(
query
.
NewBool
()
.
AppendMultiShould
(
query
.
NewMultiMatchPhrase
(
"Verb"
,
f
.
Verbs
))
.
AppendMultiShould
(
query
.
NewMultiMatchPhrase
(
"Verb
.keyword
"
,
f
.
Verbs
))
.
WithMinimumShouldMatch
(
mini
))
b
.
AppendFilter
(
query
.
NewBool
()
.
AppendMultiShould
(
query
.
NewMultiMatchPhrase
(
"Level"
,
f
.
Levels
))
.
AppendMultiShould
(
query
.
NewMultiMatchPhrase
(
"Level
.keyword
"
,
f
.
Levels
))
.
WithMinimumShouldMatch
(
mini
))
bi
=
query
.
NewBool
()
.
WithMinimumShouldMatch
(
mini
)
...
...
@@ -197,7 +197,7 @@ func parseToQueryPart(f *auditing.Filter) *query.Query {
AppendShould
(
query
.
NewTerms
(
"ResponseStatus.code"
,
f
.
ResponseCodes
))
.
WithMinimumShouldMatch
(
mini
))
b
.
AppendFilter
(
query
.
NewBool
()
.
AppendMultiShould
(
query
.
NewMultiMatchPhrase
(
"ResponseStatus.status"
,
f
.
ResponseStatus
))
.
AppendMultiShould
(
query
.
NewMultiMatchPhrase
(
"ResponseStatus.status
.keyword
"
,
f
.
ResponseStatus
))
.
WithMinimumShouldMatch
(
mini
))
r
:=
query
.
NewRange
(
"RequestReceivedTimestamp"
)
...
...
pkg/simple/client/auditing/elasticsearch/elasticsearch_test.go
浏览文件 @
4f8fc3d4
...
...
@@ -154,7 +154,7 @@ func TestParseToQueryPart(t *testing.T) {
"filter":[
{
"match_phrase":{
"ObjectRef.Namespace":"kubesphere-system"
"ObjectRef.Namespace
.keyword
":"kubesphere-system"
}
},
{
...
...
@@ -172,7 +172,7 @@ func TestParseToQueryPart(t *testing.T) {
"filter":[
{
"match_phrase":{
"Workspace":"system-workspace"
"Workspace
.keyword
":"system-workspace"
}
},
{
...
...
@@ -218,7 +218,7 @@ func TestParseToQueryPart(t *testing.T) {
"should":[
{
"match_phrase":{
"Verb":"create"
"Verb
.keyword
":"create"
}
}
],
...
...
@@ -230,7 +230,7 @@ func TestParseToQueryPart(t *testing.T) {
"should":[
{
"match_phrase":{
"Level":"Metadata"
"Level
.keyword
":"Metadata"
}
}
],
...
...
@@ -328,7 +328,7 @@ func TestParseToQueryPart(t *testing.T) {
"should":[
{
"match_phrase":{
"ResponseStatus.status":"Failure"
"ResponseStatus.status
.keyword
":"Failure"
}
}
],
...
...
pkg/simple/client/es/response.go
浏览文件 @
4f8fc3d4
...
...
@@ -6,9 +6,9 @@ import (
)
type
Response
struct
{
ScrollId
string
`json:"_scroll_id,omitempty"`
Hits
`json:"hits,omitempty"`
*
Aggregations
`json:"aggregations,omitempty"`
ScrollId
string
`json:"_scroll_id,omitempty"`
Hits
`json:"hits,omitempty"`
Aggregations
`json:"aggregations,omitempty"`
}
type
Hits
struct
{
...
...
@@ -22,8 +22,8 @@ type Hit struct {
}
type
Aggregations
struct
{
*
CardinalityAggregation
`json:"cardinality_aggregation,omitempty"`
*
DateHistogramAggregation
`json:"date_histogram_aggregation,omitempty"`
CardinalityAggregation
`json:"cardinality_aggregation,omitempty"`
DateHistogramAggregation
`json:"date_histogram_aggregation,omitempty"`
}
type
CardinalityAggregation
struct
{
...
...
pkg/simple/client/events/elasticsearch/elasticsearch.go
浏览文件 @
4f8fc3d4
...
...
@@ -74,9 +74,6 @@ func (c *client) CountOverTime(filter *events.Filter, interval string) (*events.
if
err
!=
nil
{
return
nil
,
err
}
if
resp
==
nil
||
resp
.
Aggregations
.
DateHistogramAggregation
==
nil
{
return
&
events
.
Histogram
{},
nil
}
histo
:=
events
.
Histogram
{
Total
:
c
.
c
.
GetTotalHitCount
(
resp
.
Total
)}
for
_
,
bucket
:=
range
resp
.
Buckets
{
...
...
@@ -98,9 +95,6 @@ func (c *client) StatisticsOnResources(filter *events.Filter) (*events.Statistic
if
err
!=
nil
{
return
nil
,
err
}
if
resp
==
nil
||
resp
.
Aggregations
.
CardinalityAggregation
==
nil
{
return
&
events
.
Statistics
{},
nil
}
return
&
events
.
Statistics
{
Resources
:
resp
.
Value
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录