mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
Short names of some date related functions
This commit is contained in:
parent
d2ca2b496a
commit
ea1318f38b
|
@ -892,8 +892,8 @@ func funcDayOfWeek(ev *evaluator, args Expressions) model.Value {
|
|||
return vector
|
||||
}
|
||||
|
||||
// === hour_of_day(v vector) scalar ===
|
||||
func funcHourOfDay(ev *evaluator, args Expressions) model.Value {
|
||||
// === hour(v vector) scalar ===
|
||||
func funcHour(ev *evaluator, args Expressions) model.Value {
|
||||
vector := ev.evalVector(args[0])
|
||||
for _, el := range vector {
|
||||
el.Metric.Del(model.MetricNameLabel)
|
||||
|
@ -902,8 +902,8 @@ func funcHourOfDay(ev *evaluator, args Expressions) model.Value {
|
|||
return vector
|
||||
}
|
||||
|
||||
// === month_of_year(v vector) scalar ===
|
||||
func funcMonthOfYear(ev *evaluator, args Expressions) model.Value {
|
||||
// === month(v vector) scalar ===
|
||||
func funcMonth(ev *evaluator, args Expressions) model.Value {
|
||||
vector := ev.evalVector(args[0])
|
||||
for _, el := range vector {
|
||||
el.Metric.Del(model.MetricNameLabel)
|
||||
|
@ -1037,11 +1037,11 @@ var functions = map[string]*Function{
|
|||
ReturnType: model.ValVector,
|
||||
Call: funcHoltWinters,
|
||||
},
|
||||
"hour_of_day": {
|
||||
Name: "hour_of_day",
|
||||
"hour": {
|
||||
Name: "hour",
|
||||
ArgTypes: []model.ValueType{model.ValVector},
|
||||
ReturnType: model.ValVector,
|
||||
Call: funcHourOfDay,
|
||||
Call: funcHour,
|
||||
},
|
||||
"idelta": {
|
||||
Name: "idelta",
|
||||
|
@ -1097,11 +1097,11 @@ var functions = map[string]*Function{
|
|||
ReturnType: model.ValVector,
|
||||
Call: funcMinOverTime,
|
||||
},
|
||||
"month_of_year": {
|
||||
Name: "month_of_year",
|
||||
"month": {
|
||||
Name: "month",
|
||||
ArgTypes: []model.ValueType{model.ValVector},
|
||||
ReturnType: model.ValVector,
|
||||
Call: funcMonthOfYear,
|
||||
Call: funcMonth,
|
||||
},
|
||||
"predict_linear": {
|
||||
Name: "predict_linear",
|
||||
|
|
8
promql/testdata/functions.test
vendored
8
promql/testdata/functions.test
vendored
|
@ -370,7 +370,7 @@ clear
|
|||
eval instant at 0m year(vector(0))
|
||||
{} 1970
|
||||
|
||||
eval instant at 0m month_of_year(vector(0))
|
||||
eval instant at 0m month(vector(0))
|
||||
{} 1
|
||||
|
||||
eval instant at 0m day_of_month(vector(0))
|
||||
|
@ -380,7 +380,7 @@ eval instant at 0m day_of_month(vector(0))
|
|||
eval instant at 0m day_of_week(vector(0))
|
||||
{} 4
|
||||
|
||||
eval instant at 0m hour_of_day(vector(0))
|
||||
eval instant at 0m hour(vector(0))
|
||||
{} 0
|
||||
|
||||
# 2008-12-31 23:59:59 just before leap second.
|
||||
|
@ -392,11 +392,11 @@ eval instant at 0m year(vector(1230768000))
|
|||
{} 2009
|
||||
|
||||
# 2016-02-29 23:59:59 Febuary 29th in leap year.
|
||||
eval instant at 0m month_of_year(vector(1456790399)) + day_of_month(vector(1456790399)) / 100
|
||||
eval instant at 0m month(vector(1456790399)) + day_of_month(vector(1456790399)) / 100
|
||||
{} 2.29
|
||||
|
||||
# 2016-03-01 00:00:00 March 1st in leap year.
|
||||
eval instant at 0m month_of_year(vector(1456790400)) + day_of_month(vector(1456790400)) / 100
|
||||
eval instant at 0m month(vector(1456790400)) + day_of_month(vector(1456790400)) / 100
|
||||
{} 3.01
|
||||
|
||||
# Febuary 1st 2016 in leap year.
|
||||
|
|
Loading…
Reference in a new issue