mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-14 07:17:52 -08:00
PromQL: Add minute() function
Returns the minutes from the current time in UTC. Related to the `hour()` function. Fixes #1983.
This commit is contained in:
parent
3fd992d2d1
commit
9628eb5998
|
@ -909,6 +909,13 @@ func funcHour(ev *evaluator, args Expressions) model.Value {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// === minute(v vector) scalar ===
|
||||||
|
func funcMinute(ev *evaluator, args Expressions) model.Value {
|
||||||
|
return dateWrapper(ev, args, func(t time.Time) model.SampleValue {
|
||||||
|
return model.SampleValue(t.Minute())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// === month(v vector) scalar ===
|
// === month(v vector) scalar ===
|
||||||
func funcMonth(ev *evaluator, args Expressions) model.Value {
|
func funcMonth(ev *evaluator, args Expressions) model.Value {
|
||||||
return dateWrapper(ev, args, func(t time.Time) model.SampleValue {
|
return dateWrapper(ev, args, func(t time.Time) model.SampleValue {
|
||||||
|
@ -1102,6 +1109,13 @@ var functions = map[string]*Function{
|
||||||
ReturnType: model.ValVector,
|
ReturnType: model.ValVector,
|
||||||
Call: funcMinOverTime,
|
Call: funcMinOverTime,
|
||||||
},
|
},
|
||||||
|
"minute": {
|
||||||
|
Name: "minute",
|
||||||
|
ArgTypes: []model.ValueType{model.ValVector},
|
||||||
|
OptionalArgs: 1,
|
||||||
|
ReturnType: model.ValVector,
|
||||||
|
Call: funcMinute,
|
||||||
|
},
|
||||||
"month": {
|
"month": {
|
||||||
Name: "month",
|
Name: "month",
|
||||||
ArgTypes: []model.ValueType{model.ValVector},
|
ArgTypes: []model.ValueType{model.ValVector},
|
||||||
|
|
3
promql/testdata/functions.test
vendored
3
promql/testdata/functions.test
vendored
|
@ -383,6 +383,9 @@ eval instant at 0m day_of_week()
|
||||||
eval instant at 0m hour()
|
eval instant at 0m hour()
|
||||||
{} 0
|
{} 0
|
||||||
|
|
||||||
|
eval instant at 0m minute()
|
||||||
|
{} 0
|
||||||
|
|
||||||
# 2008-12-31 23:59:59 just before leap second.
|
# 2008-12-31 23:59:59 just before leap second.
|
||||||
eval instant at 0m year(vector(1230767999))
|
eval instant at 0m year(vector(1230767999))
|
||||||
{} 2008
|
{} 2008
|
||||||
|
|
Loading…
Reference in a new issue