mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-10 23:54:05 -08:00
commit
2b5d915953
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -13,6 +13,7 @@
|
|||
.*.swo
|
||||
*.iml
|
||||
.idea
|
||||
tags
|
||||
|
||||
/prometheus
|
||||
/promtool
|
||||
|
|
|
@ -1283,7 +1283,7 @@ func (a *RelabelAction) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
|||
type RelabelConfig struct {
|
||||
// A list of labels from which values are taken and concatenated
|
||||
// with the configured separator in order.
|
||||
SourceLabels model.LabelNames `yaml:"source_labels,flow"`
|
||||
SourceLabels model.LabelNames `yaml:"source_labels,flow,omitempty"`
|
||||
// Separator is the string between concatenated values from the source labels.
|
||||
Separator string `yaml:"separator,omitempty"`
|
||||
// Regex against which the concatenation is matched.
|
||||
|
|
28
config/config_default_test.go
Normal file
28
config/config_default_test.go
Normal file
|
@ -0,0 +1,28 @@
|
|||
// Copyright 2017 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.
|
||||
|
||||
// +build !windows
|
||||
|
||||
package config
|
||||
|
||||
const ruleFilesConfigFile = "testdata/rules_abs_path.good.yml"
|
||||
|
||||
var ruleFilesExpectedConf = &Config{
|
||||
GlobalConfig: DefaultGlobalConfig,
|
||||
RuleFiles: []string{
|
||||
"testdata/first.rules",
|
||||
"testdata/rules/second.rules",
|
||||
"/absolute/third.rules",
|
||||
},
|
||||
original: "",
|
||||
}
|
|
@ -17,6 +17,7 @@ import (
|
|||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"net/url"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
@ -48,9 +49,8 @@ var expectedConf = &Config{
|
|||
},
|
||||
|
||||
RuleFiles: []string{
|
||||
"testdata/first.rules",
|
||||
"/absolute/second.rules",
|
||||
"testdata/my/*.rules",
|
||||
filepath.FromSlash("testdata/first.rules"),
|
||||
filepath.FromSlash("testdata/my/*.rules"),
|
||||
},
|
||||
|
||||
RemoteWriteConfigs: []*RemoteWriteConfig{
|
||||
|
@ -85,7 +85,7 @@ var expectedConf = &Config{
|
|||
Scheme: DefaultScrapeConfig.Scheme,
|
||||
|
||||
HTTPClientConfig: HTTPClientConfig{
|
||||
BearerTokenFile: "testdata/valid_token_file",
|
||||
BearerTokenFile: filepath.FromSlash("testdata/valid_token_file"),
|
||||
},
|
||||
|
||||
ServiceDiscoveryConfig: ServiceDiscoveryConfig{
|
||||
|
@ -252,9 +252,9 @@ var expectedConf = &Config{
|
|||
TagSeparator: DefaultConsulSDConfig.TagSeparator,
|
||||
Scheme: "https",
|
||||
TLSConfig: TLSConfig{
|
||||
CertFile: "testdata/valid_cert_file",
|
||||
KeyFile: "testdata/valid_key_file",
|
||||
CAFile: "testdata/valid_ca_file",
|
||||
CertFile: filepath.FromSlash("testdata/valid_cert_file"),
|
||||
KeyFile: filepath.FromSlash("testdata/valid_key_file"),
|
||||
CAFile: filepath.FromSlash("testdata/valid_ca_file"),
|
||||
InsecureSkipVerify: false,
|
||||
},
|
||||
},
|
||||
|
@ -283,8 +283,8 @@ var expectedConf = &Config{
|
|||
|
||||
HTTPClientConfig: HTTPClientConfig{
|
||||
TLSConfig: TLSConfig{
|
||||
CertFile: "testdata/valid_cert_file",
|
||||
KeyFile: "testdata/valid_key_file",
|
||||
CertFile: filepath.FromSlash("testdata/valid_cert_file"),
|
||||
KeyFile: filepath.FromSlash("testdata/valid_key_file"),
|
||||
},
|
||||
|
||||
BearerToken: "mysecret",
|
||||
|
@ -354,8 +354,8 @@ var expectedConf = &Config{
|
|||
Timeout: model.Duration(30 * time.Second),
|
||||
RefreshInterval: model.Duration(30 * time.Second),
|
||||
TLSConfig: TLSConfig{
|
||||
CertFile: "testdata/valid_cert_file",
|
||||
KeyFile: "testdata/valid_key_file",
|
||||
CertFile: filepath.FromSlash("testdata/valid_cert_file"),
|
||||
KeyFile: filepath.FromSlash("testdata/valid_key_file"),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -549,6 +549,29 @@ func TestLoadConfig(t *testing.T) {
|
|||
|
||||
}
|
||||
|
||||
func TestLoadConfigRuleFilesAbsolutePath(t *testing.T) {
|
||||
// Parse a valid file that sets a rule files with an absolute path
|
||||
c, err := LoadFile(ruleFilesConfigFile)
|
||||
if err != nil {
|
||||
t.Errorf("Error parsing %s: %s", ruleFilesConfigFile, err)
|
||||
}
|
||||
|
||||
bgot, err := yaml.Marshal(c)
|
||||
if err != nil {
|
||||
t.Fatalf("%s", err)
|
||||
}
|
||||
|
||||
bexp, err := yaml.Marshal(ruleFilesExpectedConf)
|
||||
if err != nil {
|
||||
t.Fatalf("%s", err)
|
||||
}
|
||||
ruleFilesExpectedConf.original = c.original
|
||||
|
||||
if !reflect.DeepEqual(c, ruleFilesExpectedConf) {
|
||||
t.Fatalf("%s: unexpected config result: \n\n%s\n expected\n\n%s", ruleFilesConfigFile, bgot, bexp)
|
||||
}
|
||||
}
|
||||
|
||||
var expectedErrors = []struct {
|
||||
filename string
|
||||
errMsg string
|
||||
|
|
26
config/config_windows_test.go
Normal file
26
config/config_windows_test.go
Normal file
|
@ -0,0 +1,26 @@
|
|||
// Copyright 2017 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 config
|
||||
|
||||
const ruleFilesConfigFile = "testdata/rules_abs_path_windows.good.yml"
|
||||
|
||||
var ruleFilesExpectedConf = &Config{
|
||||
GlobalConfig: DefaultGlobalConfig,
|
||||
RuleFiles: []string{
|
||||
"testdata\\first.rules",
|
||||
"testdata\\rules\\second.rules",
|
||||
"c:\\absolute\\third.rules",
|
||||
},
|
||||
original: "",
|
||||
}
|
1
config/testdata/conf.good.yml
vendored
1
config/testdata/conf.good.yml
vendored
|
@ -10,7 +10,6 @@ global:
|
|||
|
||||
rule_files:
|
||||
- "first.rules"
|
||||
- "/absolute/second.rules"
|
||||
- "my/*.rules"
|
||||
|
||||
remote_write:
|
||||
|
|
4
config/testdata/rules_abs_path.good.yml
vendored
Normal file
4
config/testdata/rules_abs_path.good.yml
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
rule_files:
|
||||
- 'first.rules'
|
||||
- 'rules/second.rules'
|
||||
- '/absolute/third.rules'
|
4
config/testdata/rules_abs_path_windows.good.yml
vendored
Normal file
4
config/testdata/rules_abs_path_windows.good.yml
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
rule_files:
|
||||
- 'first.rules'
|
||||
- 'rules\second.rules'
|
||||
- 'c:\absolute\third.rules'
|
|
@ -17,6 +17,7 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
@ -89,12 +90,12 @@ retry:
|
|||
if _, ok := tg.Labels["foo"]; !ok {
|
||||
t.Fatalf("Label not parsed")
|
||||
}
|
||||
if tg.String() != fmt.Sprintf("fixtures/_test%s:0", ext) {
|
||||
if tg.String() != filepath.FromSlash(fmt.Sprintf("fixtures/_test%s:0", ext)) {
|
||||
t.Fatalf("Unexpected target group %s", tg)
|
||||
}
|
||||
|
||||
tg = tgs[1]
|
||||
if tg.String() != fmt.Sprintf("fixtures/_test%s:1", ext) {
|
||||
if tg.String() != filepath.FromSlash(fmt.Sprintf("fixtures/_test%s:1", ext)) {
|
||||
t.Fatalf("Unexpected target groups %s", tg)
|
||||
}
|
||||
break retry
|
||||
|
|
|
@ -20,6 +20,7 @@ import (
|
|||
"math/rand"
|
||||
"net"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -43,6 +44,9 @@ const (
|
|||
appLabel model.LabelName = metaLabelPrefix + "app"
|
||||
// imageLabel is the label that is used for the docker image running the service.
|
||||
imageLabel model.LabelName = metaLabelPrefix + "image"
|
||||
// portIndexLabel is the integer port index when multiple ports are defined;
|
||||
// e.g. PORT1 would have a value of '1'
|
||||
portIndexLabel model.LabelName = metaLabelPrefix + "port_index"
|
||||
// taskLabel contains the mesos task name of the app instance.
|
||||
taskLabel model.LabelName = metaLabelPrefix + "task"
|
||||
|
||||
|
@ -323,6 +327,7 @@ func targetsForApp(app *App) []model.LabelSet {
|
|||
target := model.LabelSet{
|
||||
model.AddressLabel: model.LabelValue(targetAddress),
|
||||
taskLabel: model.LabelValue(t.ID),
|
||||
portIndexLabel: model.LabelValue(strconv.Itoa(i)),
|
||||
}
|
||||
if i < len(app.PortDefinitions) {
|
||||
for ln, lv := range app.PortDefinitions[i].Labels {
|
||||
|
|
|
@ -425,32 +425,6 @@ func (cmd clearCmd) String() string {
|
|||
return "clear"
|
||||
}
|
||||
|
||||
// RunAsBenchmark runs the test in benchmark mode.
|
||||
// This will not count any loads or non eval functions.
|
||||
func (t *Test) RunAsBenchmark(b *Benchmark) error {
|
||||
for _, cmd := range t.cmds {
|
||||
|
||||
switch cmd.(type) {
|
||||
// Only time the "eval" command.
|
||||
case *evalCmd:
|
||||
err := t.exec(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
default:
|
||||
if b.iterCount == 0 {
|
||||
b.b.StopTimer()
|
||||
err := t.exec(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
b.b.StartTimer()
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Run executes the command sequence of the test. Until the maximum error number
|
||||
// is reached, evaluation errors do not terminate execution.
|
||||
func (t *Test) Run() error {
|
||||
|
|
40
promql/test_test.go
Normal file
40
promql/test_test.go
Normal file
|
@ -0,0 +1,40 @@
|
|||
// Copyright 2015 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, softwar
|
||||
// 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
|
||||
|
||||
// RunAsBenchmark runs the test in benchmark mode.
|
||||
// This will not count any loads or non eval functions.
|
||||
func (t *Test) RunAsBenchmark(b *Benchmark) error {
|
||||
for _, cmd := range t.cmds {
|
||||
|
||||
switch cmd.(type) {
|
||||
// Only time the "eval" command.
|
||||
case *evalCmd:
|
||||
err := t.exec(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
default:
|
||||
if b.iterCount == 0 {
|
||||
b.b.StopTimer()
|
||||
err := t.exec(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
b.b.StartTimer()
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
|
@ -90,7 +90,7 @@ func (tm *TargetManager) Stop() {
|
|||
// Wait for all scrape inserts to complete.
|
||||
tm.wg.Wait()
|
||||
|
||||
tm.logger.Debugln("Target manager stopped")
|
||||
tm.logger.Infoln("Target manager stopped.")
|
||||
}
|
||||
|
||||
func (tm *TargetManager) reload() {
|
||||
|
|
|
@ -26,6 +26,9 @@ const (
|
|||
|
||||
// NilCloser is a no-op Closer.
|
||||
NilCloser = nilCloser(true)
|
||||
|
||||
// The number of times that a TemporaryDirectory will retry its removal
|
||||
temporaryDirectoryRemoveRetries = 2
|
||||
)
|
||||
|
||||
type (
|
||||
|
@ -84,15 +87,20 @@ func NewCallbackCloser(fn func()) Closer {
|
|||
}
|
||||
|
||||
func (t temporaryDirectory) Close() {
|
||||
retries := temporaryDirectoryRemoveRetries
|
||||
err := os.RemoveAll(t.path)
|
||||
if err != nil {
|
||||
for err != nil && retries > 0 {
|
||||
switch {
|
||||
case os.IsNotExist(err):
|
||||
return
|
||||
err = nil
|
||||
default:
|
||||
t.tester.Fatal(err)
|
||||
retries--
|
||||
err = os.RemoveAll(t.path)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
t.tester.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (t temporaryDirectory) Path() string {
|
||||
|
|
2
vendor/github.com/prometheus/tsdb/db.go
generated
vendored
2
vendor/github.com/prometheus/tsdb/db.go
generated
vendored
|
@ -710,7 +710,7 @@ func (db *DB) ensureHead(t int64) error {
|
|||
}
|
||||
// Create another block of buffer in front if the DB is initialized or retrieving
|
||||
// new data after a long gap.
|
||||
// This ensures we always have a full block width if append window.
|
||||
// This ensures we always have a full block width of append window.
|
||||
if addBuffer {
|
||||
if _, err := db.createHeadBlock(mint-int64(db.opts.MinBlockDuration), mint); err != nil {
|
||||
return err
|
||||
|
|
1
vendor/github.com/prometheus/tsdb/head.go
generated
vendored
1
vendor/github.com/prometheus/tsdb/head.go
generated
vendored
|
@ -302,6 +302,7 @@ func (h *HeadBlock) Snapshot(snapshotDir string) error {
|
|||
return errors.Wrap(err, "write snapshot")
|
||||
}
|
||||
meta.ULID = uid
|
||||
meta.MaxTime = h.highTimestamp
|
||||
|
||||
if err = writeMetaFile(tmp, meta); err != nil {
|
||||
return errors.Wrap(err, "write merged meta")
|
||||
|
|
6
vendor/vendor.json
vendored
6
vendor/vendor.json
vendored
|
@ -853,10 +853,10 @@
|
|||
"revisionTime": "2016-04-11T19:08:41Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "kT9X/dKXjFCoxV48N2C9NZhPRvA=",
|
||||
"checksumSHA1": "GgHaU/6pJjJ7I8aTfaZXnV/OWxA=",
|
||||
"path": "github.com/prometheus/tsdb",
|
||||
"revision": "d492bfd973c24026ab784c1c1821af426bc80e90",
|
||||
"revisionTime": "2017-06-30T13:17:34Z"
|
||||
"revision": "969c407335d68cbd8154dcd1bca6259786b27f53",
|
||||
"revisionTime": "2017-07-12T11:54:31Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "9EH3v+JdbikCUJAgD4VEOPIaWfs=",
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -311,6 +311,9 @@ PromConsole.graphDefaults = {
|
|||
yAxisFormatter: PromConsole.NumberFormatter.humanize,
|
||||
// Number formatter for y values hover detail.
|
||||
yHoverFormatter: PromConsole.NumberFormatter.humanizeExact,
|
||||
// Color scheme to be used by the plots. Can be either a list of hex color
|
||||
// codes or one of the color scheme names supported by Rickshaw.
|
||||
colorScheme: null,
|
||||
};
|
||||
|
||||
PromConsole.Graph = function(params) {
|
||||
|
@ -420,7 +423,7 @@ PromConsole.Graph.prototype._escapeHTML = function(string) {
|
|||
|
||||
PromConsole.Graph.prototype._render = function(data) {
|
||||
var self = this;
|
||||
var palette = new Rickshaw.Color.Palette();
|
||||
var palette = new Rickshaw.Color.Palette({scheme: this.params.colorScheme});
|
||||
var series = [];
|
||||
|
||||
// This will be used on resize.
|
||||
|
|
Loading…
Reference in a new issue