update prometheus dependencies (#5520)
Signed-off-by: junot <junotxiang@kubesphere.io>
This commit is contained in:
@@ -27,7 +27,7 @@ import (
|
||||
"github.com/emicklei/go-restful"
|
||||
"github.com/pkg/errors"
|
||||
prommodel "github.com/prometheus/common/model"
|
||||
"github.com/prometheus/prometheus/pkg/timestamp"
|
||||
"github.com/prometheus/prometheus/model/timestamp"
|
||||
"github.com/prometheus/prometheus/promql/parser"
|
||||
"github.com/prometheus/prometheus/template"
|
||||
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
||||
@@ -46,7 +46,7 @@ var (
|
||||
ErrAlertingRuleAlreadyExists = errors.New("The alerting rule already exists")
|
||||
ErrAlertingAPIV2NotEnabled = errors.New("The alerting v2 API is not enabled")
|
||||
|
||||
templateTestData = template.AlertTemplateData(map[string]string{}, map[string]string{}, 0)
|
||||
templateTestData = template.AlertTemplateData(map[string]string{}, map[string]string{}, "", 0)
|
||||
templateTestTextPrefix = "{{$labels := .Labels}}{{$externalLabels := .ExternalLabels}}{{$value := .Value}}"
|
||||
|
||||
ruleNameMatcher = regexp.MustCompile(`^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`)
|
||||
@@ -99,6 +99,7 @@ func (r *PostableAlertingRule) Validate() error {
|
||||
prommodel.Time(timestamp.FromTime(time.Now())),
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
return tmpl.ParseTest()
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
|
||||
"github.com/go-logr/logr"
|
||||
promresourcesv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
|
||||
promlabels "github.com/prometheus/prometheus/pkg/labels"
|
||||
promlabels "github.com/prometheus/prometheus/model/labels"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
|
||||
@@ -19,7 +19,7 @@ import (
|
||||
|
||||
"github.com/go-logr/logr"
|
||||
promresourcesv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
|
||||
promlabels "github.com/prometheus/prometheus/pkg/labels"
|
||||
promlabels "github.com/prometheus/prometheus/model/labels"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
@@ -23,7 +23,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prometheus-community/prom-label-proxy/injectproxy"
|
||||
promresourcesv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
|
||||
promlabels "github.com/prometheus/prometheus/pkg/labels"
|
||||
promlabels "github.com/prometheus/prometheus/model/labels"
|
||||
"github.com/prometheus/prometheus/promql/parser"
|
||||
"gopkg.in/yaml.v2"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
@@ -87,7 +87,7 @@ var emptyEnforceExprFunc = func(expr string) (string, error) {
|
||||
|
||||
func CreateEnforceExprFunc(enforceRuleMatchers []*promlabels.Matcher) EnforceExprFunc {
|
||||
if len(enforceRuleMatchers) > 0 {
|
||||
enforcer := injectproxy.NewEnforcer(enforceRuleMatchers...)
|
||||
enforcer := injectproxy.NewEnforcer(false, enforceRuleMatchers...)
|
||||
return func(expr string) (string, error) {
|
||||
parsedExpr, err := parser.ParseExpr(expr)
|
||||
if err != nil {
|
||||
@@ -152,7 +152,7 @@ func makePrometheusRuleGroups(log logr.Logger, groupList client.ObjectList,
|
||||
|
||||
prule := promresourcesv1.Rule{
|
||||
Alert: rule.Alert,
|
||||
For: string(rule.For),
|
||||
For: promresourcesv1.Duration(rule.For),
|
||||
Expr: rule.Expr,
|
||||
Labels: rule.Labels,
|
||||
Annotations: rule.Annotations,
|
||||
@@ -201,7 +201,7 @@ func makePrometheusRuleGroups(log logr.Logger, groupList client.ObjectList,
|
||||
}
|
||||
rulegroups = append(rulegroups, &promresourcesv1.RuleGroup{
|
||||
Name: group.Name,
|
||||
Interval: group.Spec.Interval,
|
||||
Interval: promresourcesv1.Duration(group.Spec.Interval),
|
||||
PartialResponseStrategy: group.Spec.PartialResponseStrategy,
|
||||
Rules: prules,
|
||||
})
|
||||
@@ -224,7 +224,7 @@ func makePrometheusRuleGroups(log logr.Logger, groupList client.ObjectList,
|
||||
}
|
||||
rulegroups = append(rulegroups, &promresourcesv1.RuleGroup{
|
||||
Name: group.Name,
|
||||
Interval: group.Spec.Interval,
|
||||
Interval: promresourcesv1.Duration(group.Spec.Interval),
|
||||
PartialResponseStrategy: group.Spec.PartialResponseStrategy,
|
||||
Rules: prules,
|
||||
})
|
||||
@@ -249,7 +249,7 @@ func makePrometheusRuleGroups(log logr.Logger, groupList client.ObjectList,
|
||||
}
|
||||
rulegroups = append(rulegroups, &promresourcesv1.RuleGroup{
|
||||
Name: group.Name,
|
||||
Interval: group.Spec.Interval,
|
||||
Interval: promresourcesv1.Duration(group.Spec.Interval),
|
||||
PartialResponseStrategy: group.Spec.PartialResponseStrategy,
|
||||
Rules: prules,
|
||||
})
|
||||
|
||||
@@ -855,7 +855,7 @@ func parseToPrometheusRule(rule *v2alpha1.PostableAlertingRule) *promresourcesv1
|
||||
return &promresourcesv1.Rule{
|
||||
Alert: rule.Name,
|
||||
Expr: intstr.FromString(rule.Query),
|
||||
For: rule.Duration,
|
||||
For: promresourcesv1.Duration(rule.Duration),
|
||||
Labels: rule.Labels,
|
||||
Annotations: rule.Annotations,
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
promlabels "github.com/prometheus/prometheus/pkg/labels"
|
||||
promlabels "github.com/prometheus/prometheus/model/labels"
|
||||
"github.com/prometheus/prometheus/promql/parser"
|
||||
promrules "github.com/prometheus/prometheus/rules"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
|
||||
@@ -23,7 +23,7 @@ import (
|
||||
"github.com/prometheus-community/prom-label-proxy/injectproxy"
|
||||
promresourcesv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
|
||||
prommodel "github.com/prometheus/common/model"
|
||||
promlabels "github.com/prometheus/prometheus/pkg/labels"
|
||||
promlabels "github.com/prometheus/prometheus/model/labels"
|
||||
"github.com/prometheus/prometheus/promql/parser"
|
||||
"github.com/prometheus/prometheus/rules"
|
||||
"k8s.io/klog/v2"
|
||||
@@ -64,7 +64,7 @@ func InjectExprNamespaceLabel(expr, namespace string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err = injectproxy.NewEnforcer(&promlabels.Matcher{
|
||||
if err = injectproxy.NewEnforcer(false, &promlabels.Matcher{
|
||||
Type: promlabels.MatchEqual,
|
||||
Name: "namespace",
|
||||
Value: namespace,
|
||||
@@ -96,10 +96,10 @@ func GenResourceRuleIdIgnoreFormat(group string, rule *promresourcesv1.Rule) str
|
||||
klog.Warning(errors.Wrapf(err, "invalid alerting rule(%s)", rule.Alert))
|
||||
query = rule.Expr.String()
|
||||
}
|
||||
duration, err := FormatDuration(rule.For)
|
||||
duration, err := FormatDuration(string(rule.For))
|
||||
if err != nil {
|
||||
klog.Warning(errors.Wrapf(err, "invalid alerting rule(%s)", rule.Alert))
|
||||
duration = rule.For
|
||||
duration = string(rule.For)
|
||||
}
|
||||
|
||||
lbls := make(map[string]string)
|
||||
@@ -282,7 +282,7 @@ func getAlertingRuleStatus(resRule *ResourceRuleItem, epRule *alerting.AlertingR
|
||||
Id: resRule.Id,
|
||||
Name: resRule.Rule.Alert,
|
||||
Query: resRule.Rule.Expr.String(),
|
||||
Duration: resRule.Rule.For,
|
||||
Duration: string(resRule.Rule.For),
|
||||
Labels: resRule.Rule.Labels,
|
||||
Annotations: resRule.Rule.Annotations,
|
||||
},
|
||||
|
||||
@@ -18,7 +18,7 @@ package expressions
|
||||
|
||||
import (
|
||||
"github.com/prometheus-community/prom-label-proxy/injectproxy"
|
||||
"github.com/prometheus/prometheus/pkg/labels"
|
||||
"github.com/prometheus/prometheus/model/labels"
|
||||
"github.com/prometheus/prometheus/promql/parser"
|
||||
)
|
||||
|
||||
@@ -32,7 +32,7 @@ func labelReplace(input, ns string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
|
||||
err = injectproxy.NewEnforcer(&labels.Matcher{
|
||||
err = injectproxy.NewEnforcer(false, &labels.Matcher{
|
||||
Type: labels.MatchEqual,
|
||||
Name: "namespace",
|
||||
Value: ns,
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prometheus/client_golang/api"
|
||||
"github.com/prometheus/prometheus/pkg/labels"
|
||||
"github.com/prometheus/prometheus/model/labels"
|
||||
"github.com/prometheus/prometheus/promql/parser"
|
||||
)
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import (
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
"k8s.io/klog/v2"
|
||||
|
||||
promlabels "github.com/prometheus/prometheus/pkg/labels"
|
||||
promlabels "github.com/prometheus/prometheus/model/labels"
|
||||
metricsapi "k8s.io/metrics/pkg/apis/metrics"
|
||||
metricsV1beta1 "k8s.io/metrics/pkg/apis/metrics/v1beta1"
|
||||
metricsclient "k8s.io/metrics/pkg/client/clientset/versioned"
|
||||
|
||||
Reference in New Issue
Block a user