Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
doodoocoder
prometheus
提交
ab3d7a0e
P
prometheus
项目概览
doodoocoder
/
prometheus
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
prometheus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
ab3d7a0e
编写于
3月 23, 2016
作者:
F
Fabian Reinartz
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove old alerting syntax
上级
d3b53bd7
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
4 addition
and
93 deletion
+4
-93
promql/lex.go
promql/lex.go
+0
-11
promql/lex_test.go
promql/lex_test.go
+0
-12
promql/parse.go
promql/parse.go
+4
-44
promql/parse_test.go
promql/parse_test.go
+0
-26
未找到文件。
promql/lex.go
浏览文件 @
ab3d7a0e
...
...
@@ -163,11 +163,6 @@ const (
itemGroupLeft
itemGroupRight
itemBool
// Old alerting syntax
itemWith
itemSummary
itemRunbook
itemDescription
keywordsEnd
)
...
...
@@ -200,12 +195,6 @@ var key = map[string]itemType{
"group_left"
:
itemGroupLeft
,
"group_right"
:
itemGroupRight
,
"bool"
:
itemBool
,
// Old alerting syntax.
"with"
:
itemWith
,
"summary"
:
itemSummary
,
"runbook"
:
itemRunbook
,
"description"
:
itemDescription
,
}
// These are the default string representations for common items. It does not
...
...
promql/lex_test.go
浏览文件 @
ab3d7a0e
...
...
@@ -263,18 +263,6 @@ var tests = []struct {
},
{
input
:
"annotations"
,
expected
:
[]
item
{{
itemAnnotations
,
0
,
"annotations"
}},
},
{
input
:
"description"
,
expected
:
[]
item
{{
itemDescription
,
0
,
"description"
}},
},
{
input
:
"summary"
,
expected
:
[]
item
{{
itemSummary
,
0
,
"summary"
}},
},
{
input
:
"runbook"
,
expected
:
[]
item
{{
itemRunbook
,
0
,
"runbook"
}},
},
{
input
:
"with"
,
expected
:
[]
item
{{
itemWith
,
0
,
"with"
}},
},
{
input
:
"offset"
,
expected
:
[]
item
{{
itemOffset
,
0
,
"offset"
}},
...
...
promql/parse.go
浏览文件 @
ab3d7a0e
...
...
@@ -384,57 +384,17 @@ func (p *parser) alertStmt() *AlertStmt {
}
}
// Accepting WITH instead of LABELS is temporary compatibility
// with the old alerting syntax.
var
(
hasLabels
bool
oldSyntax
bool
labels
=
model
.
LabelSet
{}
annotations
=
model
.
LabelSet
{}
)
if
t
:=
p
.
peek
()
.
typ
;
t
==
itemLabels
{
if
p
.
peek
()
.
typ
==
itemLabels
{
p
.
expect
(
itemLabels
,
ctx
)
labels
=
p
.
labelSet
()
hasLabels
=
true
}
else
if
t
==
itemWith
{
p
.
expect
(
itemWith
,
ctx
)
labels
=
p
.
labelSet
()
oldSyntax
=
true
}
// Only allow old annotation syntax if new label syntax isn't used.
if
!
hasLabels
{
Loop
:
for
{
switch
p
.
next
()
.
typ
{
case
itemSummary
:
annotations
[
"summary"
]
=
model
.
LabelValue
(
p
.
unquoteString
(
p
.
expect
(
itemString
,
ctx
)
.
val
))
case
itemDescription
:
annotations
[
"description"
]
=
model
.
LabelValue
(
p
.
unquoteString
(
p
.
expect
(
itemString
,
ctx
)
.
val
))
case
itemRunbook
:
annotations
[
"runbook"
]
=
model
.
LabelValue
(
p
.
unquoteString
(
p
.
expect
(
itemString
,
ctx
)
.
val
))
default
:
p
.
backup
()
break
Loop
}
}
if
len
(
annotations
)
>
0
{
oldSyntax
=
true
}
}
// Only allow new annotation syntax if WITH or old annotation
// syntax weren't used.
if
!
oldSyntax
{
if
p
.
peek
()
.
typ
==
itemAnnotations
{
p
.
expect
(
itemAnnotations
,
ctx
)
annotations
=
p
.
labelSet
()
}
}
else
{
log
.
Warnf
(
"Alerting rule with old syntax found. Support for this syntax will be removed with 0.18. Please update to the new syntax."
)
if
p
.
peek
()
.
typ
==
itemAnnotations
{
p
.
expect
(
itemAnnotations
,
ctx
)
annotations
=
p
.
labelSet
()
}
return
&
AlertStmt
{
...
...
promql/parse_test.go
浏览文件 @
ab3d7a0e
...
...
@@ -1311,32 +1311,6 @@ var testStatement = []struct {
Labels
:
model
.
LabelSet
{
"x"
:
""
,
"a"
:
"z"
},
},
},
},
{
input
:
`ALERT SomeName IF some_metric > 1
WITH {}
SUMMARY "Global request rate low"
DESCRIPTION "The global request rate is low"
`
,
expected
:
Statements
{
&
AlertStmt
{
Name
:
"SomeName"
,
Expr
:
&
BinaryExpr
{
Op
:
itemGTR
,
LHS
:
&
VectorSelector
{
Name
:
"some_metric"
,
LabelMatchers
:
metric
.
LabelMatchers
{
{
Type
:
metric
.
Equal
,
Name
:
model
.
MetricNameLabel
,
Value
:
"some_metric"
},
},
},
RHS
:
&
NumberLiteral
{
1
},
},
Labels
:
model
.
LabelSet
{},
Annotations
:
model
.
LabelSet
{
"summary"
:
"Global request rate low"
,
"description"
:
"The global request rate is low"
,
},
},
},
},
{
input
:
`ALERT SomeName IF some_metric > 1
LABELS {}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录