app/vmctl: fix arguments order in httputils.TLSConfig

follow-up after 9d5bf5ba5d

Signed-off-by: hagen1778 <roman@victoriametrics.com>
This commit is contained in:
hagen1778 2024-03-14 11:45:39 +01:00
parent 9d5bf5ba5d
commit a2ea8bc97b
No known key found for this signature in database
GPG Key ID: 3BF75F3741CA9640
3 changed files with 36 additions and 34 deletions

View File

@ -57,7 +57,7 @@ func main() {
insecureSkipVerify := c.Bool(otsdbInsecureSkipVerify) insecureSkipVerify := c.Bool(otsdbInsecureSkipVerify)
addr := c.String(otsdbAddr) addr := c.String(otsdbAddr)
tr, err := httputils.Transport(addr, certFile, caFile, keyFile, serverName, insecureSkipVerify) tr, err := httputils.Transport(addr, certFile, keyFile, caFile, serverName, insecureSkipVerify)
if err != nil { if err != nil {
return fmt.Errorf("failed to create Transport: %s", err) return fmt.Errorf("failed to create Transport: %s", err)
} }
@ -107,7 +107,7 @@ func main() {
serverName := c.String(influxServerName) serverName := c.String(influxServerName)
insecureSkipVerify := c.Bool(influxInsecureSkipVerify) insecureSkipVerify := c.Bool(influxInsecureSkipVerify)
tc, err := httputils.TLSConfig(certFile, caFile, keyFile, serverName, insecureSkipVerify) tc, err := httputils.TLSConfig(certFile, keyFile, caFile, serverName, insecureSkipVerify)
if err != nil { if err != nil {
return fmt.Errorf("failed to create TLS Config: %s", err) return fmt.Errorf("failed to create TLS Config: %s", err)
} }
@ -158,21 +158,33 @@ func main() {
Usage: "Migrate time series via Prometheus remote-read protocol", Usage: "Migrate time series via Prometheus remote-read protocol",
Flags: mergeFlags(globalFlags, remoteReadFlags, vmFlags), Flags: mergeFlags(globalFlags, remoteReadFlags, vmFlags),
Action: func(c *cli.Context) error { Action: func(c *cli.Context) error {
fmt.Println("Remote-read import mode")
addr := c.String(remoteReadSrcAddr)
// create TLS config
certFile := c.String(remoteReadCertFile)
keyFile := c.String(remoteReadKeyFile)
caFile := c.String(remoteReadCAFile)
serverName := c.String(remoteReadServerName)
insecureSkipVerify := c.Bool(remoteReadInsecureSkipVerify)
tr, err := httputils.Transport(addr, certFile, keyFile, caFile, serverName, insecureSkipVerify)
if err != nil {
return fmt.Errorf("failed to create transport: %s", err)
}
rr, err := remoteread.NewClient(remoteread.Config{ rr, err := remoteread.NewClient(remoteread.Config{
Addr: c.String(remoteReadSrcAddr), Addr: addr,
Username: c.String(remoteReadUser), Transport: tr,
Password: c.String(remoteReadPassword), Username: c.String(remoteReadUser),
Timeout: c.Duration(remoteReadHTTPTimeout), Password: c.String(remoteReadPassword),
UseStream: c.Bool(remoteReadUseStream), Timeout: c.Duration(remoteReadHTTPTimeout),
Headers: c.String(remoteReadHeaders), UseStream: c.Bool(remoteReadUseStream),
LabelName: c.String(remoteReadFilterLabel), Headers: c.String(remoteReadHeaders),
LabelValue: c.String(remoteReadFilterLabelValue), LabelName: c.String(remoteReadFilterLabel),
CertFile: c.String(remoteReadCertFile), LabelValue: c.String(remoteReadFilterLabelValue),
KeyFile: c.String(remoteReadKeyFile), DisablePathAppend: c.Bool(remoteReadDisablePathAppend),
CAFile: c.String(remoteReadCAFile),
ServerName: c.String(remoteReadServerName),
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)
@ -402,7 +414,7 @@ func initConfigVM(c *cli.Context) (vm.Config, error) {
serverName := c.String(vmServerName) serverName := c.String(vmServerName)
insecureSkipVerify := c.Bool(vmInsecureSkipVerify) insecureSkipVerify := c.Bool(vmInsecureSkipVerify)
tr, err := httputils.Transport(addr, certFile, caFile, keyFile, serverName, insecureSkipVerify) tr, err := httputils.Transport(addr, certFile, keyFile, caFile, serverName, insecureSkipVerify)
if err != nil { if err != nil {
return vm.Config{}, fmt.Errorf("failed to create Transport: %s", err) return vm.Config{}, fmt.Errorf("failed to create Transport: %s", err)
} }

View File

@ -13,7 +13,6 @@ import (
"github.com/VictoriaMetrics/VictoriaMetrics/app/vmctl/vm" "github.com/VictoriaMetrics/VictoriaMetrics/app/vmctl/vm"
"github.com/VictoriaMetrics/VictoriaMetrics/lib/bytesutil" "github.com/VictoriaMetrics/VictoriaMetrics/lib/bytesutil"
"github.com/VictoriaMetrics/VictoriaMetrics/lib/httputils"
"github.com/gogo/protobuf/proto" "github.com/gogo/protobuf/proto"
"github.com/golang/snappy" "github.com/golang/snappy"
"github.com/prometheus/prometheus/prompb" "github.com/prometheus/prometheus/prompb"
@ -46,6 +45,8 @@ type Client struct {
type Config struct { type Config struct {
// Addr of remote storage // Addr of remote storage
Addr string Addr string
// Transport allows specifying custom http.Transport
Transport *http.Transport
// DisablePathAppend disable automatic appending of the remote read path // DisablePathAppend disable automatic appending of the remote read path
DisablePathAppend bool DisablePathAppend bool
// Timeout defines timeout for HTTP requests // Timeout defines timeout for HTTP requests
@ -64,15 +65,6 @@ type Config struct {
// LabelName, LabelValue stands for label=~value pair used for read requests. // LabelName, LabelValue stands for label=~value pair used for read requests.
// Is optional. // Is optional.
LabelName, LabelValue string LabelName, LabelValue string
// Optional cert file, key file, CA file and server name for client side TLS configuration
CertFile string
KeyFile string
CAFile string
ServerName string
// TLSSkipVerify defines whether to skip TLS certificate verification when connecting to the remote read address.
InsecureSkipVerify bool
} }
// Filter defines a list of filters applied to requested data // Filter defines a list of filters applied to requested data
@ -110,16 +102,13 @@ func NewClient(cfg Config) (*Client, error) {
} }
} }
tr, err := httputils.Transport(cfg.Addr, cfg.CertFile, cfg.KeyFile, cfg.CAFile, cfg.ServerName, cfg.InsecureSkipVerify) client := &http.Client{Timeout: cfg.Timeout}
if err != nil { if cfg.Transport != nil {
return nil, fmt.Errorf("failed to create transport: %s", err) client.Transport = cfg.Transport
} }
c := &Client{ c := &Client{
c: &http.Client{ c: client,
Timeout: cfg.Timeout,
Transport: tr,
},
addr: strings.TrimSuffix(cfg.Addr, "/"), addr: strings.TrimSuffix(cfg.Addr, "/"),
disablePathAppend: cfg.DisablePathAppend, disablePathAppend: cfg.DisablePathAppend,
user: cfg.Username, user: cfg.Username,

View File

@ -54,6 +54,7 @@ See also [LTS releases](https://docs.victoriametrics.com/lts-releases/).
* BUGFIX: do not drop `match[]` filter at [`/api/v1/series`](https://docs.victoriametrics.com/url-examples/#apiv1series) if `-search.ignoreExtraFiltersAtLabelsAPI` command-line flag is set, since missing `match[]` filter breaks `/api/v1/series` requests. * BUGFIX: do not drop `match[]` filter at [`/api/v1/series`](https://docs.victoriametrics.com/url-examples/#apiv1series) if `-search.ignoreExtraFiltersAtLabelsAPI` command-line flag is set, since missing `match[]` filter breaks `/api/v1/series` requests.
* BUGFIX: [stream aggregation](https://docs.victoriametrics.com/stream-aggregation/): take into account sample timestamp during [deduplication](https://docs.victoriametrics.com/stream-aggregation/#deduplication). If multiple samples have the same timestamp on the configured deduplication interval, then the sample with the biggest value is kept. The logic is aligned with [`-dedup.minScrapeInterval`](https://docs.victoriametrics.com/#deduplication). * BUGFIX: [stream aggregation](https://docs.victoriametrics.com/stream-aggregation/): take into account sample timestamp during [deduplication](https://docs.victoriametrics.com/stream-aggregation/#deduplication). If multiple samples have the same timestamp on the configured deduplication interval, then the sample with the biggest value is kept. The logic is aligned with [`-dedup.minScrapeInterval`](https://docs.victoriametrics.com/#deduplication).
* BUGFIX: [vmctl](https://docs.victoriametrics.com/vmctl.html): properly parse TLS key and CA files for [InfluxDB](https://docs.victoriametrics.com/vmctl/#migrating-data-from-influxdb-1x) and [OpenTSDB](https://docs.victoriametrics.com/vmctl/#migrating-data-from-opentsdb) migration modes.
## [v1.99.0](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.99.0) ## [v1.99.0](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.99.0)