mirror of https://github.com/prometheus/prometheus
Merge pull request #1078 from prometheus/whats-our-vector-victor
Remove optional vector() 2nd argumentpull/1080/head
commit
29de4ee2b0
|
@ -650,24 +650,11 @@ func funcLabelReplace(ev *evaluator, args Expressions) model.Value {
|
||||||
return vector
|
return vector
|
||||||
}
|
}
|
||||||
|
|
||||||
// === vector(s scalar, vector model.ValVectora={}) Vector ===
|
// === vector(s scalar) Vector ===
|
||||||
func funcVector(ev *evaluator, args Expressions) model.Value {
|
func funcVector(ev *evaluator, args Expressions) model.Value {
|
||||||
m := model.Metric{}
|
|
||||||
if len(args) >= 2 {
|
|
||||||
if vs, ok := args[1].(*VectorSelector); ok {
|
|
||||||
for _, matcher := range vs.LabelMatchers {
|
|
||||||
if matcher.Type == metric.Equal && matcher.Name != model.MetricNameLabel {
|
|
||||||
m[matcher.Name] = matcher.Value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return vector{
|
return vector{
|
||||||
&sample{
|
&sample{
|
||||||
Metric: metric.Metric{
|
Metric: metric.Metric{},
|
||||||
Metric: m,
|
|
||||||
Copied: true,
|
|
||||||
},
|
|
||||||
Value: model.SampleValue(ev.evalFloat(args[0])),
|
Value: model.SampleValue(ev.evalFloat(args[0])),
|
||||||
Timestamp: ev.Timestamp,
|
Timestamp: ev.Timestamp,
|
||||||
},
|
},
|
||||||
|
@ -871,9 +858,8 @@ var functions = map[string]*Function{
|
||||||
},
|
},
|
||||||
"vector": {
|
"vector": {
|
||||||
Name: "vector",
|
Name: "vector",
|
||||||
ArgTypes: []model.ValueType{model.ValScalar, model.ValVector},
|
ArgTypes: []model.ValueType{model.ValScalar},
|
||||||
ReturnType: model.ValVector,
|
ReturnType: model.ValVector,
|
||||||
OptionalArgs: 1,
|
|
||||||
Call: funcVector,
|
Call: funcVector,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,9 +155,3 @@ eval instant at 0m vector(1)
|
||||||
|
|
||||||
eval instant at 60m vector(time())
|
eval instant at 60m vector(time())
|
||||||
{} 3600
|
{} 3600
|
||||||
|
|
||||||
eval instant at 0m vector(1, {a="b"})
|
|
||||||
{a="b"} 1
|
|
||||||
|
|
||||||
eval instant at 0m vector(1, {a="b", c=~"d", e!="f", g!~"h", a="z"})
|
|
||||||
{a="z"} 1
|
|
||||||
|
|
Loading…
Reference in New Issue