mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -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"
|
||||
"time"
|
||||
|
||||
"github.com/go-kit/kit/log"
|
||||
"github.com/pkg/errors"
|
||||
yaml "gopkg.in/yaml.v2"
|
||||
|
||||
|
@ -160,7 +161,7 @@ func (tg *testGroup) test(mint, maxt time.Time, evalInterval time.Duration, grou
|
|||
Appendable: suite.Storage(),
|
||||
Context: context.Background(),
|
||||
NotifyFunc: func(ctx context.Context, expr string, alerts ...*rules.Alert) {},
|
||||
Logger: &dummyLogger{},
|
||||
Logger: log.NewNopLogger(),
|
||||
}
|
||||
m := rules.NewManager(opts)
|
||||
// TODO(beorn7): Provide a way to pass in external labels.
|
||||
|
@ -502,9 +503,3 @@ func parsedSamplesString(pss []parsedSample) string {
|
|||
func (ps *parsedSample) String() string {
|
||||
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
|
||||
evaluation_interval: <duration>
|
||||
|
||||
# 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.
|
||||
# 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.
|
||||
# All the groups need not be mentioned below.
|
||||
group_eval_order:
|
||||
[ - <group_name> ]
|
||||
|
@ -59,13 +59,13 @@ promql_expr_test:
|
|||
|
||||
```yaml
|
||||
# This follows the usual series notation '<metric name>{<label name>=<label value>, ...}'
|
||||
# Examples:
|
||||
# Examples:
|
||||
# series_name{label1="value1", label2="value2"}
|
||||
# go_goroutines{job="prometheus", instance="localhost:9090"}
|
||||
series: <string>
|
||||
|
||||
# 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)'
|
||||
# Examples:
|
||||
|
@ -85,8 +85,8 @@ eval_time: <duration>
|
|||
# Name of the alert to be tested.
|
||||
alertname: <string>
|
||||
|
||||
# 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
|
||||
# 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
|
||||
# not be firing, then you can mention the above fields and leave 'exp_alerts' empty.
|
||||
exp_alerts:
|
||||
[ - <alert> ]
|
||||
|
@ -95,8 +95,8 @@ exp_alerts:
|
|||
### `<alert>`
|
||||
|
||||
``` yaml
|
||||
# These are the expanded labels and annotations of the expected alert.
|
||||
# Note: labels also include the labels of the sample associated with the
|
||||
# These are the expanded labels and annotations of the expected alert.
|
||||
# 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`)
|
||||
exp_labels:
|
||||
[ <labelname>: <string> ]
|
||||
|
@ -122,7 +122,7 @@ exp_samples:
|
|||
|
||||
```yaml
|
||||
# Labels of the sample in usual series notation '<metric name>{<label name>=<label value>, ...}'
|
||||
# Examples:
|
||||
# Examples:
|
||||
# series_name{label1="value1", label2="value2"}
|
||||
# go_goroutines{job="prometheus", instance="localhost:9090"}
|
||||
labels: <string>
|
||||
|
@ -131,7 +131,7 @@ labels: <string>
|
|||
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.
|
||||
|
||||
|
@ -140,7 +140,7 @@ With `alerts.yml` in the same directory, run `./promtool test rules test.yml`.
|
|||
### `test.yml`
|
||||
|
||||
```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.
|
||||
|
||||
rule_files:
|
||||
|
|
Loading…
Reference in a new issue