mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
cmd/promtool: use log.NewNopLogger() (#5531)
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
This commit is contained in:
parent
03b90b4645
commit
9c69eec82a
|
@ -25,6 +25,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/go-kit/kit/log"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
yaml "gopkg.in/yaml.v2"
|
yaml "gopkg.in/yaml.v2"
|
||||||
|
|
||||||
|
@ -160,7 +161,7 @@ func (tg *testGroup) test(mint, maxt time.Time, evalInterval time.Duration, grou
|
||||||
Appendable: suite.Storage(),
|
Appendable: suite.Storage(),
|
||||||
Context: context.Background(),
|
Context: context.Background(),
|
||||||
NotifyFunc: func(ctx context.Context, expr string, alerts ...*rules.Alert) {},
|
NotifyFunc: func(ctx context.Context, expr string, alerts ...*rules.Alert) {},
|
||||||
Logger: &dummyLogger{},
|
Logger: log.NewNopLogger(),
|
||||||
}
|
}
|
||||||
m := rules.NewManager(opts)
|
m := rules.NewManager(opts)
|
||||||
// TODO(beorn7): Provide a way to pass in external labels.
|
// TODO(beorn7): Provide a way to pass in external labels.
|
||||||
|
@ -502,9 +503,3 @@ func parsedSamplesString(pss []parsedSample) string {
|
||||||
func (ps *parsedSample) String() string {
|
func (ps *parsedSample) String() string {
|
||||||
return ps.Labels.String() + " " + strconv.FormatFloat(ps.Value, 'E', -1, 64)
|
return ps.Labels.String() + " " + strconv.FormatFloat(ps.Value, 'E', -1, 64)
|
||||||
}
|
}
|
||||||
|
|
||||||
type dummyLogger struct{}
|
|
||||||
|
|
||||||
func (l *dummyLogger) Log(keyvals ...interface{}) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
|
@ -25,8 +25,8 @@ rule_files:
|
||||||
# optional, default = 1m
|
# optional, default = 1m
|
||||||
evaluation_interval: <duration>
|
evaluation_interval: <duration>
|
||||||
|
|
||||||
# The order in which group names are listed below will be the order of evaluation of
|
# The order in which group names are listed below will be the order of evaluation of
|
||||||
# rule groups (at a given evaluation time). The order is guaranteed only for the groups mentioned below.
|
# rule groups (at a given evaluation time). The order is guaranteed only for the groups mentioned below.
|
||||||
# All the groups need not be mentioned below.
|
# All the groups need not be mentioned below.
|
||||||
group_eval_order:
|
group_eval_order:
|
||||||
[ - <group_name> ]
|
[ - <group_name> ]
|
||||||
|
@ -59,13 +59,13 @@ promql_expr_test:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# This follows the usual series notation '<metric name>{<label name>=<label value>, ...}'
|
# This follows the usual series notation '<metric name>{<label name>=<label value>, ...}'
|
||||||
# Examples:
|
# Examples:
|
||||||
# series_name{label1="value1", label2="value2"}
|
# series_name{label1="value1", label2="value2"}
|
||||||
# go_goroutines{job="prometheus", instance="localhost:9090"}
|
# go_goroutines{job="prometheus", instance="localhost:9090"}
|
||||||
series: <string>
|
series: <string>
|
||||||
|
|
||||||
# This uses expanding notation.
|
# This uses expanding notation.
|
||||||
# Expanding notation:
|
# Expanding notation:
|
||||||
# 'a+bxc' becomes 'a a+b a+(2*b) a+(3*b) … a+(c*b)'
|
# 'a+bxc' becomes 'a a+b a+(2*b) a+(3*b) … a+(c*b)'
|
||||||
# 'a-bxc' becomes 'a a-b a-(2*b) a-(3*b) … a-(c*b)'
|
# 'a-bxc' becomes 'a a-b a-(2*b) a-(3*b) … a-(c*b)'
|
||||||
# Examples:
|
# Examples:
|
||||||
|
@ -85,8 +85,8 @@ eval_time: <duration>
|
||||||
# Name of the alert to be tested.
|
# Name of the alert to be tested.
|
||||||
alertname: <string>
|
alertname: <string>
|
||||||
|
|
||||||
# List of expected alerts which are firing under the given alertname at
|
# List of expected alerts which are firing under the given alertname at
|
||||||
# given evaluation time. If you want to test if an alerting rule should
|
# given evaluation time. If you want to test if an alerting rule should
|
||||||
# not be firing, then you can mention the above fields and leave 'exp_alerts' empty.
|
# not be firing, then you can mention the above fields and leave 'exp_alerts' empty.
|
||||||
exp_alerts:
|
exp_alerts:
|
||||||
[ - <alert> ]
|
[ - <alert> ]
|
||||||
|
@ -95,8 +95,8 @@ exp_alerts:
|
||||||
### `<alert>`
|
### `<alert>`
|
||||||
|
|
||||||
``` yaml
|
``` yaml
|
||||||
# These are the expanded labels and annotations of the expected alert.
|
# These are the expanded labels and annotations of the expected alert.
|
||||||
# Note: labels also include the labels of the sample associated with the
|
# Note: labels also include the labels of the sample associated with the
|
||||||
# alert (same as what you see in `/alerts`, without series `__name__` and `alertname`)
|
# alert (same as what you see in `/alerts`, without series `__name__` and `alertname`)
|
||||||
exp_labels:
|
exp_labels:
|
||||||
[ <labelname>: <string> ]
|
[ <labelname>: <string> ]
|
||||||
|
@ -122,7 +122,7 @@ exp_samples:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# Labels of the sample in usual series notation '<metric name>{<label name>=<label value>, ...}'
|
# Labels of the sample in usual series notation '<metric name>{<label name>=<label value>, ...}'
|
||||||
# Examples:
|
# Examples:
|
||||||
# series_name{label1="value1", label2="value2"}
|
# series_name{label1="value1", label2="value2"}
|
||||||
# go_goroutines{job="prometheus", instance="localhost:9090"}
|
# go_goroutines{job="prometheus", instance="localhost:9090"}
|
||||||
labels: <string>
|
labels: <string>
|
||||||
|
@ -131,7 +131,7 @@ labels: <string>
|
||||||
value: <number>
|
value: <number>
|
||||||
```
|
```
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
This is an example input file for unit testing which passes the test. `test.yml` is the test file which follows the syntax above and `alerts.yml` contains the alerting rules.
|
This is an example input file for unit testing which passes the test. `test.yml` is the test file which follows the syntax above and `alerts.yml` contains the alerting rules.
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ With `alerts.yml` in the same directory, run `./promtool test rules test.yml`.
|
||||||
### `test.yml`
|
### `test.yml`
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# This is the main input for unit testing.
|
# This is the main input for unit testing.
|
||||||
# Only this file is passed as command line argument.
|
# Only this file is passed as command line argument.
|
||||||
|
|
||||||
rule_files:
|
rule_files:
|
||||||
|
|
Loading…
Reference in a new issue