mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
app/vmctl: add flag where use can define path to the source remote read protocol (#4744)
https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4655
This commit is contained in:
parent
5a5785292c
commit
dabce3cc5d
4 changed files with 38 additions and 16 deletions
|
@ -477,6 +477,7 @@ const (
|
||||||
remoteReadHTTPTimeout = "remote-read-http-timeout"
|
remoteReadHTTPTimeout = "remote-read-http-timeout"
|
||||||
remoteReadHeaders = "remote-read-headers"
|
remoteReadHeaders = "remote-read-headers"
|
||||||
remoteReadInsecureSkipVerify = "remote-read-insecure-skip-verify"
|
remoteReadInsecureSkipVerify = "remote-read-insecure-skip-verify"
|
||||||
|
remoteReadDisablePathAppend = "remote-read-disable-path-append"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -553,6 +554,11 @@ var (
|
||||||
Usage: "Whether to skip TLS certificate verification when connecting to the remote read address",
|
Usage: "Whether to skip TLS certificate verification when connecting to the remote read address",
|
||||||
Value: false,
|
Value: false,
|
||||||
},
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: remoteReadDisablePathAppend,
|
||||||
|
Usage: "Whether to disable automatic appending of the path to the remote storage.",
|
||||||
|
Value: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -133,6 +133,7 @@ func main() {
|
||||||
LabelName: c.String(remoteReadFilterLabel),
|
LabelName: c.String(remoteReadFilterLabel),
|
||||||
LabelValue: c.String(remoteReadFilterLabelValue),
|
LabelValue: c.String(remoteReadFilterLabelValue),
|
||||||
InsecureSkipVerify: c.Bool(remoteReadInsecureSkipVerify),
|
InsecureSkipVerify: c.Bool(remoteReadInsecureSkipVerify),
|
||||||
|
DisablePathAppend: c.Bool(remoteReadDisablePathAppend),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error create remote read client: %s", err)
|
return fmt.Errorf("error create remote read client: %s", err)
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -31,19 +32,22 @@ type StreamCallback func(series *vm.TimeSeries) error
|
||||||
// Client is an HTTP client for reading
|
// Client is an HTTP client for reading
|
||||||
// time series via remote read protocol.
|
// time series via remote read protocol.
|
||||||
type Client struct {
|
type Client struct {
|
||||||
addr string
|
addr string
|
||||||
c *http.Client
|
disablePathAppend bool
|
||||||
user string
|
c *http.Client
|
||||||
password string
|
user string
|
||||||
useStream bool
|
password string
|
||||||
headers []keyValue
|
useStream bool
|
||||||
matchers []*prompb.LabelMatcher
|
headers []keyValue
|
||||||
|
matchers []*prompb.LabelMatcher
|
||||||
}
|
}
|
||||||
|
|
||||||
// Config is config for remote read.
|
// Config is config for remote read.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
// Addr of remote storage
|
// Addr of remote storage
|
||||||
Addr string
|
Addr string
|
||||||
|
// DisablePathAppend disable automatic appending of the remote read path
|
||||||
|
DisablePathAppend bool
|
||||||
// Timeout defines timeout for HTTP requests
|
// Timeout defines timeout for HTTP requests
|
||||||
// made by remote read client
|
// made by remote read client
|
||||||
Timeout time.Duration
|
Timeout time.Duration
|
||||||
|
@ -104,13 +108,15 @@ func NewClient(cfg Config) (*Client, error) {
|
||||||
Timeout: cfg.Timeout,
|
Timeout: cfg.Timeout,
|
||||||
Transport: utils.Transport(cfg.Addr, cfg.InsecureSkipVerify),
|
Transport: utils.Transport(cfg.Addr, cfg.InsecureSkipVerify),
|
||||||
},
|
},
|
||||||
addr: strings.TrimSuffix(cfg.Addr, "/"),
|
addr: strings.TrimSuffix(cfg.Addr, "/"),
|
||||||
user: cfg.Username,
|
disablePathAppend: cfg.DisablePathAppend,
|
||||||
password: cfg.Password,
|
user: cfg.Username,
|
||||||
useStream: cfg.UseStream,
|
password: cfg.Password,
|
||||||
headers: headers,
|
useStream: cfg.UseStream,
|
||||||
matchers: []*prompb.LabelMatcher{m},
|
headers: headers,
|
||||||
|
matchers: []*prompb.LabelMatcher{m},
|
||||||
}
|
}
|
||||||
|
|
||||||
return c, nil
|
return c, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,8 +161,16 @@ func (c *Client) do(req *http.Request) (*http.Response, error) {
|
||||||
|
|
||||||
func (c *Client) fetch(ctx context.Context, data []byte, streamCb StreamCallback) error {
|
func (c *Client) fetch(ctx context.Context, data []byte, streamCb StreamCallback) error {
|
||||||
r := bytes.NewReader(data)
|
r := bytes.NewReader(data)
|
||||||
url := c.addr + remoteReadPath
|
// by default, we are using a common remote read path
|
||||||
req, err := http.NewRequest(http.MethodPost, url, r)
|
u, err := url.JoinPath(c.addr, remoteReadPath)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("error create url from addr %s and default remote read path %s", c.addr, remoteReadPath)
|
||||||
|
}
|
||||||
|
// we should use full address from the remote-read-src-addr flag
|
||||||
|
if c.disablePathAppend {
|
||||||
|
u = c.addr
|
||||||
|
}
|
||||||
|
req, err := http.NewRequest(http.MethodPost, u, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create new HTTP request: %w", err)
|
return fmt.Errorf("failed to create new HTTP request: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,9 +29,10 @@ The following `tip` changes can be tested by building VictoriaMetrics components
|
||||||
* FEATURE: [vmalert](https://docs.victoriametrics.com/vmalert.html): remove support of deprecated web links of `/api/v1/<groupID>/<alertID>/status` form in favour of `/api/v1/alerts?group_id=<>&alert_id=<>` links. Links of `/api/v1/<groupID>/<alertID>/status` form were deprecated in v1.79.0. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2825) for details.
|
* FEATURE: [vmalert](https://docs.victoriametrics.com/vmalert.html): remove support of deprecated web links of `/api/v1/<groupID>/<alertID>/status` form in favour of `/api/v1/alerts?group_id=<>&alert_id=<>` links. Links of `/api/v1/<groupID>/<alertID>/status` form were deprecated in v1.79.0. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2825) for details.
|
||||||
* FEATURE: [vmctl](https://docs.victoriametrics.com/vmctl.html): allow disabling binary export API protocol via `-vm-native-disable-binary-protocol` cmd-line flag when [migrating data from VictoriaMetrics](https://docs.victoriametrics.com/vmctl.html#migrating-data-from-victoriametrics). Disabling binary protocol can be useful for deduplication of the exported data before ingestion. For this, deduplication need [to be configured](https://docs.victoriametrics.com/#deduplication) at `-vm-native-src-addr` side and `-vm-native-disable-binary-protocol` should be set on vmctl side.
|
* FEATURE: [vmctl](https://docs.victoriametrics.com/vmctl.html): allow disabling binary export API protocol via `-vm-native-disable-binary-protocol` cmd-line flag when [migrating data from VictoriaMetrics](https://docs.victoriametrics.com/vmctl.html#migrating-data-from-victoriametrics). Disabling binary protocol can be useful for deduplication of the exported data before ingestion. For this, deduplication need [to be configured](https://docs.victoriametrics.com/#deduplication) at `-vm-native-src-addr` side and `-vm-native-disable-binary-protocol` should be set on vmctl side.
|
||||||
* FEATURE: [vmctl](https://docs.victoriametrics.com/vmctl.html): add support of `week` step for [time-based chunking migration](https://docs.victoriametrics.com/vmctl.html#using-time-based-chunking-of-migration). See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4738).
|
* FEATURE: [vmctl](https://docs.victoriametrics.com/vmctl.html): add support of `week` step for [time-based chunking migration](https://docs.victoriametrics.com/vmctl.html#using-time-based-chunking-of-migration). See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4738).
|
||||||
|
* FEATURE: [vmctl](https://docs.victoriametrics.com/vmctl.html): do not add `/api/v1/read` suffix to remote read storage address defined by `--remote-read-src-addr` if a `--remote-read-disable-path-append` command-line flag is set. It allows an overriding path for remote-read API via `--remote-read-src-addr`. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4655).
|
||||||
|
|
||||||
* BUGFIX: [vmbackupmanager](https://docs.victoriametrics.com/vmbackupmanager.html): fix panic when creating a backup to a local filesystem on Windows. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4704).
|
|
||||||
* BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): use local scrape timestamps for the scraped metrics unless `honor_timestamps: true` option is explicitly set at [scrape_config](https://docs.victoriametrics.com/sd_configs.html#scrape_configs). This fixes gaps for metrics collected from [cadvisor](https://github.com/google/cadvisor) or similar exporters, which export metrics with invalid timestamps. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4697) and [this comment](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4697#issuecomment-1654614799) for details. The issue has been introduced in [v1.68.0](#v1680).
|
* BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): use local scrape timestamps for the scraped metrics unless `honor_timestamps: true` option is explicitly set at [scrape_config](https://docs.victoriametrics.com/sd_configs.html#scrape_configs). This fixes gaps for metrics collected from [cadvisor](https://github.com/google/cadvisor) or similar exporters, which export metrics with invalid timestamps. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4697) and [this comment](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4697#issuecomment-1654614799) for details. The issue has been introduced in [v1.68.0](#v1680).
|
||||||
|
* BUGFIX: [vmbackupmanager](https://docs.victoriametrics.com/vmbackupmanager.html): fix panic when creating a backup to a local filesystem on Windows. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4704).
|
||||||
|
|
||||||
|
|
||||||
## [v1.92.1](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.92.1)
|
## [v1.92.1](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.92.1)
|
||||||
|
|
Loading…
Reference in a new issue