mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-01-20 15:16:42 +00:00
Merge branch 'public-single-node' into victorialogs-wip
This commit is contained in:
commit
f644fa6251
13 changed files with 152 additions and 50 deletions
|
@ -3027,7 +3027,7 @@ Pass `-help` to VictoriaMetrics in order to see the list of supported command-li
|
|||
-promscrape.kumaSDCheckInterval duration
|
||||
Interval for checking for changes in kuma service discovery. This works only if kuma_sd_configs is configured in '-promscrape.config' file. See https://docs.victoriametrics.com/sd_configs/#kuma_sd_configs for details (default 30s)
|
||||
-promscrape.maxDroppedTargets int
|
||||
The maximum number of droppedTargets to show at /api/v1/targets page. Increase this value if your setup drops more scrape targets during relabeling and you need investigating labels for all the dropped targets. Note that the increased number of tracked dropped targets may result in increased memory usage (default 1000)
|
||||
The maximum number of droppedTargets to show at /api/v1/targets page. Increase this value if your setup drops more scrape targets during relabeling and you need investigating labels for all the dropped targets. Note that the increased number of tracked dropped targets may result in increased memory usage (default 10000)
|
||||
-promscrape.maxResponseHeadersSize size
|
||||
The maximum size of http response headers from Prometheus scrape targets
|
||||
Supports the following optional suffixes for size values: KB, MB, GB, TB, KiB, MiB, GiB, TiB (default 4096)
|
||||
|
|
|
@ -353,7 +353,7 @@ func (up *URLPrefix) discoverBackendAddrsIfNeeded() {
|
|||
logger.Warnf("cannot discover backend SRV records for %s: %s; use it literally", bu, err)
|
||||
resolvedAddrs = []string{host}
|
||||
} else {
|
||||
resolvedAddrs := make([]string, len(addrs))
|
||||
resolvedAddrs = make([]string, len(addrs))
|
||||
for i, addr := range addrs {
|
||||
resolvedAddrs[i] = fmt.Sprintf("%s:%d", addr.Target, addr.Port)
|
||||
}
|
||||
|
@ -380,6 +380,7 @@ func (up *URLPrefix) discoverBackendAddrsIfNeeded() {
|
|||
var busNew []*backendURL
|
||||
for _, bu := range up.busOriginal {
|
||||
host := bu.Hostname()
|
||||
host = strings.TrimPrefix(host, "srv+")
|
||||
port := bu.Port()
|
||||
for _, addr := range hostToAddrs[host] {
|
||||
buCopy := *bu
|
||||
|
@ -1011,6 +1012,8 @@ func (up *URLPrefix) sanitizeAndInitialize() error {
|
|||
}
|
||||
}
|
||||
up.bus.Store(&bus)
|
||||
up.nextDiscoveryDeadline.Store(0)
|
||||
up.n.Store(0)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/url"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/netutil"
|
||||
)
|
||||
|
||||
func TestDropPrefixParts(t *testing.T) {
|
||||
|
@ -92,7 +96,7 @@ func TestCreateTargetURLSuccess(t *testing.T) {
|
|||
u = normalizeURL(u)
|
||||
up, hc := ui.getURLPrefixAndHeaders(u, nil)
|
||||
if up == nil {
|
||||
t.Fatalf("cannot determie backend: %s", err)
|
||||
t.Fatalf("cannot match available backend: %s", err)
|
||||
}
|
||||
bu := up.getBackendURL()
|
||||
target := mergeURLs(bu.url, u, up.dropSrcPathPrefixParts)
|
||||
|
@ -256,6 +260,53 @@ func TestCreateTargetURLSuccess(t *testing.T) {
|
|||
f(ui, `/api/v1/query?query=up{env="prod"}`, `http://vmselect/1/prometheus/api/v1/query?query=up%7Benv%3D%22prod%22%7D`, "", "", nil, "least_loaded", 0)
|
||||
f(ui, `/api/v1/query?query=up{foo="bar",env="dev",pod!=""}`, `http://vmselect/0/prometheus/api/v1/query?query=up%7Bfoo%3D%22bar%22%2Cenv%3D%22dev%22%2Cpod%21%3D%22%22%7D`, "", "", nil, "least_loaded", 0)
|
||||
f(ui, `/api/v1/query?query=up{foo="bar"}`, `http://default-server/api/v1/query?query=up%7Bfoo%3D%22bar%22%7D`, "", "", nil, "least_loaded", 0)
|
||||
|
||||
customResolver := &fakeResolver{
|
||||
Resolver: &net.Resolver{},
|
||||
lookupSRVResults: map[string][]*net.SRV{
|
||||
"vmselect": {
|
||||
{
|
||||
Target: "10.6.142.50",
|
||||
Port: 8481,
|
||||
},
|
||||
{
|
||||
Target: "10.6.142.51",
|
||||
Port: 8481,
|
||||
},
|
||||
},
|
||||
},
|
||||
lookupIPAddrResults: map[string][]net.IPAddr{
|
||||
"vminsert": {
|
||||
{
|
||||
IP: net.ParseIP("10.6.142.52"),
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
netutil.Resolver = customResolver
|
||||
|
||||
// Discover backendURL
|
||||
allowed := true
|
||||
ui = &UserInfo{
|
||||
URLMaps: []URLMap{
|
||||
{
|
||||
SrcPaths: getRegexs([]string{"/select/.+"}),
|
||||
URLPrefix: mustParseURL("http://srv+vmselect"),
|
||||
},
|
||||
{
|
||||
SrcPaths: getRegexs([]string{"/insert/.+"}),
|
||||
URLPrefix: mustParseURL("http://vminsert:8480"),
|
||||
},
|
||||
},
|
||||
DiscoverBackendIPs: &allowed,
|
||||
URLPrefix: mustParseURL("http://non-exist-dns-addr"),
|
||||
}
|
||||
f(ui, `/select/0/prometheus/api/v1/query?query=up`, "http://10.6.142.51:8481/select/0/prometheus/api/v1/query?query=up", "", "", nil, "least_loaded", 0)
|
||||
// url_prefix counter will be reset, still go to 10.6.142.51
|
||||
f(ui, `/select/0/prometheus/api/v1/query?query=up`, "http://10.6.142.51:8481/select/0/prometheus/api/v1/query?query=up", "", "", nil, "least_loaded", 0)
|
||||
f(ui, `/insert/0/prometheus/api/v1/write`, "http://10.6.142.52:8480/insert/0/prometheus/api/v1/write", "", "", nil, "least_loaded", 0)
|
||||
// unsuccessful dns resolve
|
||||
f(ui, `/test`, "http://non-exist-dns-addr/test", "", "", nil, "least_loaded", 0)
|
||||
}
|
||||
|
||||
func TestCreateTargetURLFailure(t *testing.T) {
|
||||
|
@ -295,3 +346,29 @@ func headersToString(hs []*Header) string {
|
|||
}
|
||||
return strings.Join(a, "\n")
|
||||
}
|
||||
|
||||
type fakeResolver struct {
|
||||
Resolver *net.Resolver
|
||||
lookupSRVResults map[string][]*net.SRV
|
||||
lookupIPAddrResults map[string][]net.IPAddr
|
||||
}
|
||||
|
||||
func (r *fakeResolver) LookupSRV(_ context.Context, _, _, name string) (string, []*net.SRV, error) {
|
||||
if results, ok := r.lookupSRVResults[name]; ok {
|
||||
return name, results, nil
|
||||
}
|
||||
|
||||
return name, nil, fmt.Errorf("no srv results found for host: %s", name)
|
||||
}
|
||||
|
||||
func (r *fakeResolver) LookupIPAddr(_ context.Context, host string) ([]net.IPAddr, error) {
|
||||
if results, ok := r.lookupIPAddrResults[host]; ok {
|
||||
return results, nil
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("no results found for host: %s", host)
|
||||
}
|
||||
|
||||
func (r *fakeResolver) LookupMX(_ context.Context, _ string) ([]*net.MX, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ See also [LTS releases](https://docs.victoriametrics.com/lts-releases/).
|
|||
* FEATURE: [dashboards/vmagent](https://grafana.com/grafana/dashboards/12683): add row `Streaming aggregation` with panels related to [streaming aggregation](https://docs.victoriametrics.com/stream-aggregation/) process.
|
||||
* FEATURE: [vmauth](https://docs.victoriametrics.com/vmauth/): add `idleConnTimeout` flag set to 50s by default. It should reduce the probability of `broken pipe` or `connection reset by peer` errors in vmauth logs.
|
||||
* FEATURE: [vmauth](https://docs.victoriametrics.com/vmauth/): add auto request retry for trivial network errors, such as `broken pipe` and `connection reset` for requests to the configured backends.
|
||||
* FEATURE: [vmagent](https://docs.victoriametrics.com/vmagent/): increase default value of `-promscrape.maxDroppedTargets` command-line flag to 10_000 from 1000. This makes it easier to track down large number of dropped targets.
|
||||
|
||||
* BUGFIX: all VictoriaMetrics components: prioritize `-configAuthKey` and `-reloadAuthKey` over `-httpAuth.*` settings. This change aligns behavior of mentioned flags with other auth flags like `-metricsAuthKey`, `-flagsAuthKey`, `-pprofAuthKey`. Check [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/6329).
|
||||
* BUGFIX: [vmctl](https://docs.victoriametrics.com/vmctl/): add `--disable-progress-bar` global command-line flag. It can be used for disabling dynamic progress bar for all migration modes. `--vm-disable-progress-bar` command-line flag is deprecated and will be removed in the future releases. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/6367).
|
||||
|
@ -90,6 +91,7 @@ Released at 2024-06-07
|
|||
* BUGFIX: [Single-node VictoriaMetrics](https://docs.victoriametrics.com/) and `vmstorage` in [VictoriaMetrics cluster](https://docs.victoriametrics.com/cluster-victoriametrics/): correctly apply `-inmemoryDataFlushInterval` when it's set to minimum supported value 1s.
|
||||
* BUGFIX: [Single-node VictoriaMetrics](https://docs.victoriametrics.com/) and `vminsert` in [VictoriaMetrics cluster](https://docs.victoriametrics.com/cluster-victoriametrics/): reduce the default value for `-maxLabelValueLen` command-line flag from `16KiB` to `1KiB`. This should prevent from issues like [this one](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/6176) when time series with too long labels are ingested into VictoriaMetrics.
|
||||
* BUGFIX: [vmauth](https://docs.victoriametrics.com/vmauth/): properly release memory used for metrics during config reload. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/6247).
|
||||
* BUGFIX: [vmauth](https://docs.victoriametrics.com/vmauth/): fix discovering backend IPs when `url_prefix` contains hostname with srv+ prefix. Thanks to @shichanglin5 for the [pull request](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/6401).
|
||||
* BUGFIX: [dashboards](https://grafana.com/orgs/victoriametrics): fix `AnnotationQueryRunner` error in Grafana when executing annotations query against Prometheus backend. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/6309) for details.
|
||||
* BUGFIX: [Single-node VictoriaMetrics](https://docs.victoriametrics.com/) and `vmselect` in [VictoriaMetrics cluster](https://docs.victoriametrics.com/cluster-victoriametrics/): filter deleted label names and values from [`/api/v1/labels`](https://docs.victoriametrics.com/url-examples/#apiv1labels) and [`/api/v1/label/.../values`](https://docs.victoriametrics.com/url-examples/#apiv1labelvalues) responses when `match[]` filter matches small number of time series. The issue was introduced [v1.81.0](https://docs.victoriametrics.com/changelog_2022/#v1810).
|
||||
* BUGFIX: [vmalert-tool](https://docs.victoriametrics.com/vmalert-tool/): fix float values template in `input_series`. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/6391).
|
||||
|
|
|
@ -34,22 +34,24 @@ Before sending a pull request to [VictoriaMetrics repository](https://github.com
|
|||
- Commit messages contain concise yet clear descriptions. Include links to related GitHub issues in commit messages, if such issues exist.
|
||||
- All the commits are signed and include `Signed-off-by` line. Use `git commit -s` to include `Signed-off-by` your commits.
|
||||
See [this doc](https://git-scm.com/book/en/v2/Git-Tools-Signing-Your-Work) about how to sign git commits.
|
||||
- Tests are passing locally. Use `make test` to run all tests locally.
|
||||
- Linting is passing locally. Use `make check-all` to run all linters locally.
|
||||
- If the change fixes some bug, it would be great to cover it by [tests](https://pkg.go.dev/testing) (if it isn't covered yet by existsing tests).
|
||||
- All the lint checks are passing locally via `make check-all` command run from the VictoriaMetrics repository root.
|
||||
- All the tests are passing locally via `make test-full` command run from the VictoriaMetrics repository root.
|
||||
- If the change fixes some bug, it would be great to cover it by [tests](https://pkg.go.dev/testing) if it isn't covered yet by existsing tests.
|
||||
- If the change improves performance or reduces resource usage, then it would be great to add [benchmarks](https://pkg.go.dev/testing#hdr-Benchmarks)
|
||||
and mention benchmark results before and after the change in the description to the pull request.
|
||||
- If the change implements some specifics or uses some APIs, then please provide permanent links to these specs and APIs directly in the relevant source code,
|
||||
in order to simplify further maintenance of the code.
|
||||
- If the change implements some specifications or uses some external APIs, then please provide permanent links to these specs and APIs
|
||||
directly in the relevant source code, in order to simplify further maintenance of the code.
|
||||
- If the change modifies the existing logic, make sure it doesn't break existing user setups after the upgrade.
|
||||
- Please investigate git commit history for the code you change in order to make sure your change doesn't break historical conventions in the modified code.
|
||||
|
||||
Further checks are optional for External Contributions:
|
||||
Further checks are optional for external contributions:
|
||||
|
||||
- The change is described in **clear user-readable** form at [docs/CHANGELOG.md](https://github.com/VictoriaMetrics/VictoriaMetrics/blob/master/docs/CHANGELOG.md),
|
||||
- The change must be described in **clear user-readable** form at [docs/CHANGELOG.md](https://github.com/VictoriaMetrics/VictoriaMetrics/blob/master/docs/CHANGELOG.md),
|
||||
since it is read by **VictoriaMetrics users** who may not know implementation details of VictoriaMetrics products. The change description must **clearly** answer the following questions:
|
||||
- What does this change do?
|
||||
- Why this change is needed?
|
||||
|
||||
The change description must link to related GitHub issues and the related docs, if any.
|
||||
The change description must link to the related GitHub issues and the related docs, if any.
|
||||
|
||||
Tips for writing a good changelog message:
|
||||
|
||||
|
@ -58,9 +60,9 @@ Further checks are optional for External Contributions:
|
|||
- Provide a link to the related GitHub issue or pull request.
|
||||
- Provide a link to the relevant documentation if the change modifies user-visible behaviour of VictoriaMetrics producs.
|
||||
|
||||
- After your pull request is merged, please add a message to the issue with instructions for how to test the fix or try the feature you added before the new release.
|
||||
- After your pull request is merged, please add a message to the issue with instructions for how to test the change you added before the new release.
|
||||
[Here is an example](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4048#issuecomment-1546453726).
|
||||
- Do not close the original issue before the change is released. Please note, in some cases Github can automatically closes the issue once PR is merged. Re-open the issue in such case.
|
||||
- Do not close the original issue before the change is released. In some cases Github can automatically close the issue once PR is merged. Re-open the issue in such case.
|
||||
- If the change introduces a new feature, this feature must be documented in **user-readable** form at the appropriate parts of [VictoriaMetrics docs](https://docs.victoriametrics.com/).
|
||||
The docs' sources are located in the [`docs` folder](https://github.com/VictoriaMetrics/VictoriaMetrics/tree/master/docs).
|
||||
|
||||
|
@ -90,7 +92,7 @@ Due to `KISS`, [cluster version of VictoriaMetrics](https://docs.victoriametrics
|
|||
|
||||
- Fragile gossip protocols. See [failed attempt in Thanos](https://github.com/improbable-eng/thanos/blob/030bc345c12c446962225221795f4973848caab5/docs/proposals/completed/201809_gossip-removal.md).
|
||||
- Hard-to-understand-and-implement-properly [Paxos protocols](https://www.quora.com/In-distributed-systems-what-is-a-simple-explanation-of-the-Paxos-algorithm).
|
||||
- Complex replication schemes, which may go nuts in unforeseen edge cases. See [replication docs](#replication-and-data-safety) for details.
|
||||
- Complex replication schemes, which may go nuts in unforeseen edge cases. See [replication docs](https://docs.victoriametrics.com/cluster-victoriametrics/#replication-and-data-safety) for details.
|
||||
- Automatic data reshuffling between storage nodes, which may hurt cluster performance and availability.
|
||||
- Automatic cluster resizing, which may cost you a lot of money if improperly configured.
|
||||
- Automatic discovering and addition of new nodes in the cluster, which may mix data between dev and prod clusters :)
|
||||
|
|
|
@ -3030,7 +3030,7 @@ Pass `-help` to VictoriaMetrics in order to see the list of supported command-li
|
|||
-promscrape.kumaSDCheckInterval duration
|
||||
Interval for checking for changes in kuma service discovery. This works only if kuma_sd_configs is configured in '-promscrape.config' file. See https://docs.victoriametrics.com/sd_configs/#kuma_sd_configs for details (default 30s)
|
||||
-promscrape.maxDroppedTargets int
|
||||
The maximum number of droppedTargets to show at /api/v1/targets page. Increase this value if your setup drops more scrape targets during relabeling and you need investigating labels for all the dropped targets. Note that the increased number of tracked dropped targets may result in increased memory usage (default 1000)
|
||||
The maximum number of droppedTargets to show at /api/v1/targets page. Increase this value if your setup drops more scrape targets during relabeling and you need investigating labels for all the dropped targets. Note that the increased number of tracked dropped targets may result in increased memory usage (default 10000)
|
||||
-promscrape.maxResponseHeadersSize size
|
||||
The maximum size of http response headers from Prometheus scrape targets
|
||||
Supports the following optional suffixes for size values: KB, MB, GB, TB, KiB, MiB, GiB, TiB (default 4096)
|
||||
|
|
|
@ -3038,7 +3038,7 @@ Pass `-help` to VictoriaMetrics in order to see the list of supported command-li
|
|||
-promscrape.kumaSDCheckInterval duration
|
||||
Interval for checking for changes in kuma service discovery. This works only if kuma_sd_configs is configured in '-promscrape.config' file. See https://docs.victoriametrics.com/sd_configs/#kuma_sd_configs for details (default 30s)
|
||||
-promscrape.maxDroppedTargets int
|
||||
The maximum number of droppedTargets to show at /api/v1/targets page. Increase this value if your setup drops more scrape targets during relabeling and you need investigating labels for all the dropped targets. Note that the increased number of tracked dropped targets may result in increased memory usage (default 1000)
|
||||
The maximum number of droppedTargets to show at /api/v1/targets page. Increase this value if your setup drops more scrape targets during relabeling and you need investigating labels for all the dropped targets. Note that the increased number of tracked dropped targets may result in increased memory usage (default 10000)
|
||||
-promscrape.maxResponseHeadersSize size
|
||||
The maximum size of http response headers from Prometheus scrape targets
|
||||
Supports the following optional suffixes for size values: KB, MB, GB, TB, KiB, MiB, GiB, TiB (default 4096)
|
||||
|
|
|
@ -456,3 +456,13 @@ _time:4w _time:week_range[Mon, Fri] _time:day_range[08:00, 18:00)
|
|||
|
||||
It uses implicit [`AND` logical filtere](https://docs.victoriametrics.com/victorialogs/logsql/#logical-filter) for joining multiple filters
|
||||
on [`_time` field](https://docs.victoriametrics.com/victorialogs/keyconcepts/#time-field).
|
||||
|
||||
## How to find logs with the given phrase containing whitespace?
|
||||
|
||||
Use [`phrase filter`](https://docs.victoriametrics.com/victorialogs/logsql/#phrase-filter). For example, the following [LogsQL query](https://docs.victoriametrics.com/victorialogs/logsql/)
|
||||
returns logs with the `cannot open file` phrase over the last 5 minutes:
|
||||
|
||||
|
||||
```logsql
|
||||
_time:5m "cannot open file"
|
||||
```
|
||||
|
|
|
@ -1955,7 +1955,7 @@ See the docs at https://docs.victoriametrics.com/vmagent/ .
|
|||
-promscrape.kumaSDCheckInterval duration
|
||||
Interval for checking for changes in kuma service discovery. This works only if kuma_sd_configs is configured in '-promscrape.config' file. See https://docs.victoriametrics.com/sd_configs/#kuma_sd_configs for details (default 30s)
|
||||
-promscrape.maxDroppedTargets int
|
||||
The maximum number of droppedTargets to show at /api/v1/targets page. Increase this value if your setup drops more scrape targets during relabeling and you need investigating labels for all the dropped targets. Note that the increased number of tracked dropped targets may result in increased memory usage (default 1000)
|
||||
The maximum number of droppedTargets to show at /api/v1/targets page. Increase this value if your setup drops more scrape targets during relabeling and you need investigating labels for all the dropped targets. Note that the increased number of tracked dropped targets may result in increased memory usage (default 10000)
|
||||
-promscrape.maxResponseHeadersSize size
|
||||
The maximum size of http response headers from Prometheus scrape targets
|
||||
Supports the following optional suffixes for size values: KB, MB, GB, TB, KiB, MiB, GiB, TiB (default 4096)
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/fasttime"
|
||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/timeutil"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -20,14 +21,11 @@ var (
|
|||
)
|
||||
|
||||
type internStringMap struct {
|
||||
mu sync.Mutex
|
||||
mutableLock sync.Mutex
|
||||
mutable map[string]string
|
||||
mutableReads uint64
|
||||
|
||||
readonly atomic.Pointer[map[string]internStringMapEntry]
|
||||
|
||||
cleanupInterval uint64
|
||||
nextCleanupTime atomic.Uint64
|
||||
}
|
||||
|
||||
type internStringMapEntry struct {
|
||||
|
@ -41,8 +39,15 @@ func newInternStringMap() *internStringMap {
|
|||
}
|
||||
readonly := make(map[string]internStringMapEntry)
|
||||
m.readonly.Store(&readonly)
|
||||
m.cleanupInterval = uint64(cacheExpireDuration.Seconds() / 3)
|
||||
m.nextCleanupTime.Store(fasttime.UnixTimestamp() + m.cleanupInterval)
|
||||
|
||||
go func() {
|
||||
cleanupInterval := timeutil.AddJitterToDuration(*cacheExpireDuration) / 2
|
||||
ticker := time.NewTicker(cleanupInterval)
|
||||
for range ticker.C {
|
||||
m.cleanup()
|
||||
}
|
||||
}()
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
|
@ -54,21 +59,16 @@ func (m *internStringMap) intern(s string) string {
|
|||
if isSkipCache(s) {
|
||||
return strings.Clone(s)
|
||||
}
|
||||
currentTime := fasttime.UnixTimestamp()
|
||||
if currentTime >= m.nextCleanupTime.Load() {
|
||||
m.nextCleanupTime.Store(currentTime + m.cleanupInterval)
|
||||
m.cleanup()
|
||||
}
|
||||
|
||||
readonly := m.getReadonly()
|
||||
e, ok := readonly[s]
|
||||
if ok {
|
||||
// Fast path - the string has been found in readonly map
|
||||
// Fast path - the string has been found in readonly map.
|
||||
return e.s
|
||||
}
|
||||
|
||||
// Slower path - search for the string in mutable map under the lock.
|
||||
m.mu.Lock()
|
||||
m.mutableLock.Lock()
|
||||
sInterned, ok := m.mutable[s]
|
||||
if !ok {
|
||||
// Verify whether s has been already registered by concurrent goroutines in m.readonly
|
||||
|
@ -88,7 +88,7 @@ func (m *internStringMap) intern(s string) string {
|
|||
m.migrateMutableToReadonlyLocked()
|
||||
m.mutableReads = 0
|
||||
}
|
||||
m.mu.Unlock()
|
||||
m.mutableLock.Unlock()
|
||||
|
||||
return sInterned
|
||||
}
|
||||
|
@ -111,9 +111,6 @@ func (m *internStringMap) migrateMutableToReadonlyLocked() {
|
|||
}
|
||||
|
||||
func (m *internStringMap) cleanup() {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
|
||||
readonly := m.getReadonly()
|
||||
currentTime := fasttime.UnixTimestamp()
|
||||
needCleanup := false
|
||||
|
|
|
@ -9,15 +9,15 @@ import (
|
|||
|
||||
// pools contains pools for byte slices of various capacities.
|
||||
//
|
||||
// pools[0] is for capacities from 0 to 8
|
||||
// pools[1] is for capacities from 9 to 16
|
||||
// pools[2] is for capacities from 17 to 32
|
||||
// pools[0] is for capacities from 0 to 64
|
||||
// pools[1] is for capacities from 65 to 128
|
||||
// pools[2] is for capacities from 129 to 256
|
||||
// ...
|
||||
// pools[n] is for capacities from 2^(n+2)+1 to 2^(n+3)
|
||||
// pools[n] is for capacities from 2^(n+5)+1 to 2^(n+6)
|
||||
//
|
||||
// Limit the maximum capacity to 2^18, since there are no performance benefits
|
||||
// in caching byte slices with bigger capacities.
|
||||
var pools [17]sync.Pool
|
||||
var pools [12]sync.Pool
|
||||
|
||||
// Get returns byte buffer with the given capacity.
|
||||
func Get(capacity int) *bytesutil.ByteBuffer {
|
||||
|
@ -51,10 +51,10 @@ func getPoolIDAndCapacity(size int) (int, int) {
|
|||
if size < 0 {
|
||||
size = 0
|
||||
}
|
||||
size >>= 3
|
||||
size >>= 6
|
||||
id := bits.Len(uint(size))
|
||||
if id >= len(pools) {
|
||||
id = len(pools) - 1
|
||||
}
|
||||
return id, (1 << (id + 3))
|
||||
return id, (1 << (id + 6))
|
||||
}
|
||||
|
|
|
@ -9,6 +9,22 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
type resolver interface {
|
||||
LookupSRV(ctx context.Context, service, proto, name string) (cname string, addrs []*net.SRV, err error)
|
||||
LookupIPAddr(ctx context.Context, host string) ([]net.IPAddr, error)
|
||||
LookupMX(ctx context.Context, name string) ([]*net.MX, error)
|
||||
}
|
||||
|
||||
// Resolver is default DNS resolver.
|
||||
var Resolver resolver
|
||||
|
||||
func init() {
|
||||
Resolver = &net.Resolver{
|
||||
PreferGo: true,
|
||||
StrictErrors: true,
|
||||
}
|
||||
}
|
||||
|
||||
// IsTrivialNetworkError returns true if the err can be ignored during logging.
|
||||
func IsTrivialNetworkError(err error) bool {
|
||||
// Suppress trivial network errors, which could occur at remote side.
|
||||
|
@ -43,12 +59,6 @@ func DialMaybeSRV(ctx context.Context, network, addr string) (net.Conn, error) {
|
|||
return Dialer.DialContext(ctx, network, addr)
|
||||
}
|
||||
|
||||
// Resolver is default DNS resolver.
|
||||
var Resolver = &net.Resolver{
|
||||
PreferGo: true,
|
||||
StrictErrors: true,
|
||||
}
|
||||
|
||||
// Dialer is default network dialer.
|
||||
var Dialer = &net.Dialer{
|
||||
Timeout: 30 * time.Second,
|
||||
|
|
|
@ -13,14 +13,15 @@ import (
|
|||
"time"
|
||||
"unsafe"
|
||||
|
||||
"github.com/VictoriaMetrics/metrics"
|
||||
"github.com/cespare/xxhash/v2"
|
||||
|
||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/logger"
|
||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/promrelabel"
|
||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/promutils"
|
||||
"github.com/VictoriaMetrics/metrics"
|
||||
"github.com/cespare/xxhash/v2"
|
||||
)
|
||||
|
||||
var maxDroppedTargets = flag.Int("promscrape.maxDroppedTargets", 1000, "The maximum number of droppedTargets to show at /api/v1/targets page. "+
|
||||
var maxDroppedTargets = flag.Int("promscrape.maxDroppedTargets", 10000, "The maximum number of droppedTargets to show at /api/v1/targets page. "+
|
||||
"Increase this value if your setup drops more scrape targets during relabeling and you need investigating labels for all the dropped targets. "+
|
||||
"Note that the increased number of tracked dropped targets may result in increased memory usage")
|
||||
|
||||
|
|
Loading…
Reference in a new issue