diff --git a/promql/functions.go b/promql/functions.go index 98bc3ad54..d5a4e4899 100644 --- a/promql/functions.go +++ b/promql/functions.go @@ -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", diff --git a/promql/testdata/functions.test b/promql/testdata/functions.test index 6b1b578c3..731b50898 100644 --- a/promql/testdata/functions.test +++ b/promql/testdata/functions.test @@ -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.