mirror of
https://github.com/prometheus/prometheus
synced 2024-12-23 23:13:11 +00:00
4eca4dffb8
* Introduce a metadata watcher Similarly to the WAL watcher, its purpose is to observe the scrape manager and pull metadata. Then, send it to a remote storage. Signed-off-by: gotjosh <josue@grafana.com> * Additional fixes after rebasing. Signed-off-by: Callum Styan <callumstyan@gmail.com> * Rework samples/metadata metrics. Signed-off-by: Callum Styan <callumstyan@gmail.com> * Use more descriptive variable names in MetadataWatcher collect. Signed-off-by: Callum Styan <callumstyan@gmail.com> * Fix issues caused during rebasing. Signed-off-by: Callum Styan <callumstyan@gmail.com> * Fix missing metric add and unneeded config code. Signed-off-by: Callum Styan <callumstyan@gmail.com> * Address some review comments. Signed-off-by: Callum Styan <callumstyan@gmail.com> * Fix metrics and docs Signed-off-by: Ganesh Vernekar <cs15btech11018@iith.ac.in> * Replace assert with require Signed-off-by: Ganesh Vernekar <cs15btech11018@iith.ac.in> * Bring back max_samples_per_send metric Signed-off-by: Ganesh Vernekar <cs15btech11018@iith.ac.in> * Fix tests Signed-off-by: Ganesh Vernekar <cs15btech11018@iith.ac.in> Co-authored-by: Callum Styan <callumstyan@gmail.com> Co-authored-by: Ganesh Vernekar <cs15btech11018@iith.ac.in>
89 lines
2.3 KiB
Go
89 lines
2.3 KiB
Go
// Copyright 2019 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 remote
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"net/url"
|
|
"os"
|
|
"testing"
|
|
|
|
common_config "github.com/prometheus/common/config"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/prometheus/prometheus/config"
|
|
)
|
|
|
|
func TestStorageLifecycle(t *testing.T) {
|
|
dir, err := ioutil.TempDir("", "TestStorageLifecycle")
|
|
require.NoError(t, err)
|
|
defer os.RemoveAll(dir)
|
|
|
|
s := NewStorage(nil, nil, nil, dir, defaultFlushDeadline, nil)
|
|
conf := &config.Config{
|
|
GlobalConfig: config.DefaultGlobalConfig,
|
|
RemoteWriteConfigs: []*config.RemoteWriteConfig{
|
|
&config.DefaultRemoteWriteConfig,
|
|
},
|
|
RemoteReadConfigs: []*config.RemoteReadConfig{
|
|
&config.DefaultRemoteReadConfig,
|
|
},
|
|
}
|
|
// We need to set URL's so that metric creation doesn't panic.
|
|
conf.RemoteWriteConfigs[0].URL = &common_config.URL{
|
|
URL: &url.URL{
|
|
Host: "http://test-storage.com",
|
|
},
|
|
}
|
|
conf.RemoteReadConfigs[0].URL = &common_config.URL{
|
|
URL: &url.URL{
|
|
Host: "http://test-storage.com",
|
|
},
|
|
}
|
|
|
|
require.NoError(t, s.ApplyConfig(conf))
|
|
|
|
// make sure remote write has a queue.
|
|
require.Equal(t, 1, len(s.rws.queues))
|
|
|
|
// make sure remote write has a queue.
|
|
require.Equal(t, 1, len(s.queryables))
|
|
|
|
err = s.Close()
|
|
require.NoError(t, err)
|
|
}
|
|
|
|
func TestUpdateRemoteReadConfigs(t *testing.T) {
|
|
dir, err := ioutil.TempDir("", "TestUpdateRemoteReadConfigs")
|
|
require.NoError(t, err)
|
|
defer os.RemoveAll(dir)
|
|
|
|
s := NewStorage(nil, nil, nil, dir, defaultFlushDeadline, nil)
|
|
|
|
conf := &config.Config{
|
|
GlobalConfig: config.GlobalConfig{},
|
|
}
|
|
require.NoError(t, s.ApplyConfig(conf))
|
|
require.Equal(t, 0, len(s.queryables))
|
|
|
|
conf.RemoteReadConfigs = []*config.RemoteReadConfig{
|
|
&config.DefaultRemoteReadConfig,
|
|
}
|
|
require.NoError(t, s.ApplyConfig(conf))
|
|
require.Equal(t, 1, len(s.queryables))
|
|
|
|
err = s.Close()
|
|
require.NoError(t, err)
|
|
}
|