mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-12 06:17:27 -08:00
Merge branch 'main' into sparsehistogram
This commit is contained in:
commit
53982c3562
|
@ -6,27 +6,31 @@ require (
|
|||
github.com/go-kit/log v0.2.1
|
||||
github.com/gogo/protobuf v1.3.2
|
||||
github.com/golang/snappy v0.0.4
|
||||
github.com/influxdata/influxdb v1.9.5
|
||||
github.com/influxdata/influxdb v1.9.8
|
||||
github.com/prometheus/client_golang v1.12.2
|
||||
github.com/prometheus/common v0.34.0
|
||||
github.com/prometheus/prometheus v1.8.2-0.20220202104425-d819219dd438
|
||||
github.com/stretchr/testify v1.7.2
|
||||
github.com/prometheus/common v0.36.0
|
||||
github.com/stretchr/testify v1.8.0
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
|
||||
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
|
||||
github.com/aws/aws-sdk-go v1.42.31 // indirect
|
||||
github.com/aws/aws-sdk-go v1.44.20 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/dennwc/varint v1.0.0 // indirect
|
||||
github.com/felixge/httpsnoop v1.0.2 // indirect
|
||||
github.com/felixge/httpsnoop v1.0.3 // indirect
|
||||
github.com/go-logfmt/logfmt v0.5.1 // indirect
|
||||
github.com/go-logr/logr v1.2.3 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/golang/protobuf v1.5.2 // indirect
|
||||
github.com/grafana/regexp v0.0.0-20220304095617-2e8d9baf4ac2 // indirect
|
||||
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
||||
github.com/jpillora/backoff v1.0.0 // indirect
|
||||
github.com/kr/pretty v0.2.1 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
|
@ -34,20 +38,35 @@ require (
|
|||
github.com/prometheus/client_model v0.2.0 // indirect
|
||||
github.com/prometheus/common/sigv4 v0.1.0 // indirect
|
||||
github.com/prometheus/procfs v0.7.3 // indirect
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.26.1 // indirect
|
||||
go.opentelemetry.io/otel v1.2.0 // indirect
|
||||
go.opentelemetry.io/otel/internal/metric v0.24.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v0.24.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.2.0 // indirect
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.32.0 // indirect
|
||||
go.opentelemetry.io/otel v1.7.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v0.30.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.7.0 // indirect
|
||||
go.uber.org/atomic v1.9.0 // indirect
|
||||
go.uber.org/goleak v1.1.12 // indirect
|
||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect
|
||||
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect
|
||||
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect
|
||||
golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e // indirect
|
||||
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f // indirect
|
||||
golang.org/x/sys v0.0.0-20220624220833-87e55d714810 // indirect
|
||||
golang.org/x/text v0.3.7 // indirect
|
||||
golang.org/x/time v0.0.0-20211116232009-f0f3c7e86c11 // indirect
|
||||
golang.org/x/time v0.0.0-20220224211638-0e9765cccd65 // indirect
|
||||
golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f // indirect
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
google.golang.org/protobuf v1.27.1 // indirect
|
||||
google.golang.org/genproto v0.0.0-20220628213854-d9e0b6570c03 // indirect
|
||||
google.golang.org/protobuf v1.28.0 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/prometheus/prometheus v0.36.2
|
||||
golang.org/x/oauth2 v0.0.0-20220630143837-2104d58473e0 // indirect
|
||||
)
|
||||
|
||||
exclude (
|
||||
// These excludes are needed because of some weird version collision.
|
||||
// Feel free to try removing them after future dependency updates.
|
||||
cloud.google.com/go v0.26.0
|
||||
cloud.google.com/go v0.34.0
|
||||
cloud.google.com/go v0.65.0
|
||||
cloud.google.com/go v0.82.0
|
||||
)
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -317,6 +317,20 @@
|
|||
description: '{{ printf "%%.0f" $value }} targets in Prometheus %(prometheusName)s have failed to sync because invalid configuration was supplied.' % $._config,
|
||||
},
|
||||
},
|
||||
{
|
||||
alert: 'PrometheusHighQueryLoad',
|
||||
expr: |||
|
||||
avg_over_time(prometheus_engine_queries{job="prometheus-k8s"}[5m]) / max_over_time(prometheus_engine_queries_concurrent_max{job="prometheus-k8s"}[5m]) > 0.8
|
||||
||| % $._config,
|
||||
'for': '15m',
|
||||
labels: {
|
||||
severity: 'warning',
|
||||
},
|
||||
annotations: {
|
||||
summary: 'Prometheus is reaching its maximum capacity serving concurrent requests.',
|
||||
description: 'Prometheus %(prometheusName)s query API has less than 20%% available capacity in its query engine for the last 15 minutes.' % $._config,
|
||||
},
|
||||
},
|
||||
] + if $._config.prometheusHAGroupLabels == '' then self.rulesWithoutHA else self.rulesWithHA,
|
||||
rulesWithoutHA:: [
|
||||
{
|
||||
|
|
|
@ -221,15 +221,22 @@ func (vec Vector) String() string {
|
|||
// Such a behavior is semantically undefined
|
||||
// https://github.com/prometheus/prometheus/issues/4562
|
||||
func (vec Vector) ContainsSameLabelset() bool {
|
||||
l := make(map[uint64]struct{}, len(vec))
|
||||
for _, s := range vec {
|
||||
hash := s.Metric.Hash()
|
||||
if _, ok := l[hash]; ok {
|
||||
return true
|
||||
switch len(vec) {
|
||||
case 0, 1:
|
||||
return false
|
||||
case 2:
|
||||
return vec[0].Metric.Hash() == vec[1].Metric.Hash()
|
||||
default:
|
||||
l := make(map[uint64]struct{}, len(vec))
|
||||
for _, ss := range vec {
|
||||
hash := ss.Metric.Hash()
|
||||
if _, ok := l[hash]; ok {
|
||||
return true
|
||||
}
|
||||
l[hash] = struct{}{}
|
||||
}
|
||||
l[hash] = struct{}{}
|
||||
return false
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Matrix is a slice of Series that implements sort.Interface and
|
||||
|
@ -264,15 +271,22 @@ func (m Matrix) Swap(i, j int) { m[i], m[j] = m[j], m[i] }
|
|||
// Such a behavior is semantically undefined.
|
||||
// https://github.com/prometheus/prometheus/issues/4562
|
||||
func (m Matrix) ContainsSameLabelset() bool {
|
||||
l := make(map[uint64]struct{}, len(m))
|
||||
for _, ss := range m {
|
||||
hash := ss.Metric.Hash()
|
||||
if _, ok := l[hash]; ok {
|
||||
return true
|
||||
switch len(m) {
|
||||
case 0, 1:
|
||||
return false
|
||||
case 2:
|
||||
return m[0].Metric.Hash() == m[1].Metric.Hash()
|
||||
default:
|
||||
l := make(map[uint64]struct{}, len(m))
|
||||
for _, ss := range m {
|
||||
hash := ss.Metric.Hash()
|
||||
if _, ok := l[hash]; ok {
|
||||
return true
|
||||
}
|
||||
l[hash] = struct{}{}
|
||||
}
|
||||
l[hash] = struct{}{}
|
||||
return false
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Result holds the resulting value of an execution or an error
|
||||
|
|
110
promql/value_test.go
Normal file
110
promql/value_test.go
Normal file
|
@ -0,0 +1,110 @@
|
|||
// Copyright 2022 The Prometheus Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package promql
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/prometheus/prometheus/model/labels"
|
||||
)
|
||||
|
||||
func TestVector_ContainsSameLabelset(t *testing.T) {
|
||||
for name, tc := range map[string]struct {
|
||||
vector Vector
|
||||
expected bool
|
||||
}{
|
||||
"empty vector": {
|
||||
vector: Vector{},
|
||||
expected: false,
|
||||
},
|
||||
"vector with one series": {
|
||||
vector: Vector{
|
||||
{Metric: labels.FromStrings("lbl", "a")},
|
||||
},
|
||||
expected: false,
|
||||
},
|
||||
"vector with two different series": {
|
||||
vector: Vector{
|
||||
{Metric: labels.FromStrings("lbl", "a")},
|
||||
{Metric: labels.FromStrings("lbl", "b")},
|
||||
},
|
||||
expected: false,
|
||||
},
|
||||
"vector with two equal series": {
|
||||
vector: Vector{
|
||||
{Metric: labels.FromStrings("lbl", "a")},
|
||||
{Metric: labels.FromStrings("lbl", "a")},
|
||||
},
|
||||
expected: true,
|
||||
},
|
||||
"vector with three series, two equal": {
|
||||
vector: Vector{
|
||||
{Metric: labels.FromStrings("lbl", "a")},
|
||||
{Metric: labels.FromStrings("lbl", "b")},
|
||||
{Metric: labels.FromStrings("lbl", "a")},
|
||||
},
|
||||
expected: true,
|
||||
},
|
||||
} {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
require.Equal(t, tc.expected, tc.vector.ContainsSameLabelset())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMatrix_ContainsSameLabelset(t *testing.T) {
|
||||
for name, tc := range map[string]struct {
|
||||
matrix Matrix
|
||||
expected bool
|
||||
}{
|
||||
"empty matrix": {
|
||||
matrix: Matrix{},
|
||||
expected: false,
|
||||
},
|
||||
"matrix with one series": {
|
||||
matrix: Matrix{
|
||||
{Metric: labels.FromStrings("lbl", "a")},
|
||||
},
|
||||
expected: false,
|
||||
},
|
||||
"matrix with two different series": {
|
||||
matrix: Matrix{
|
||||
{Metric: labels.FromStrings("lbl", "a")},
|
||||
{Metric: labels.FromStrings("lbl", "b")},
|
||||
},
|
||||
expected: false,
|
||||
},
|
||||
"matrix with two equal series": {
|
||||
matrix: Matrix{
|
||||
{Metric: labels.FromStrings("lbl", "a")},
|
||||
{Metric: labels.FromStrings("lbl", "a")},
|
||||
},
|
||||
expected: true,
|
||||
},
|
||||
"matrix with three series, two equal": {
|
||||
matrix: Matrix{
|
||||
{Metric: labels.FromStrings("lbl", "a")},
|
||||
{Metric: labels.FromStrings("lbl", "b")},
|
||||
{Metric: labels.FromStrings("lbl", "a")},
|
||||
},
|
||||
expected: true,
|
||||
},
|
||||
} {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
require.Equal(t, tc.expected, tc.matrix.ContainsSameLabelset())
|
||||
})
|
||||
}
|
||||
}
|
|
@ -217,7 +217,7 @@ interface [PrometheusClient](https://github.com/prometheus/codemirror-promql/blo
|
|||
.
|
||||
|
||||
```typescript
|
||||
const promQL = new PromQLExtension().setComplete({remote: {prometheusClient: MyPrometheusClient}})
|
||||
const promQL = new PromQLExtension().setComplete({remote: MyPrometheusClient})
|
||||
```
|
||||
|
||||
#### Provide your own implementation of the autocompletion
|
||||
|
|
Loading…
Reference in a new issue