Skip to content

Commit

Permalink
Merge pull request #27 from VictoriaMetrics/issue-26
Browse files Browse the repository at this point in the history
Support string values for `vm-account-id` flag
  • Loading branch information
hagen1778 authored Sep 25, 2020
2 parents 2c3b5e2 + 1f0081d commit 7c89c7f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ Should be the same as --httpListenAddr value for single-node version or VMInsert
Please note, that vmctl performs initial readiness check for the given address by checking `/health` endpoint. (default: "http://localhost:8428")
--vm-user value VictoriaMetrics username for basic auth [$VM_USERNAME]
--vm-password value VictoriaMetrics password for basic auth [$VM_PASSWORD]
--vm-account-id value Account(tenant) ID - is required for cluster VM. (default: -1)
--vm-account-id value AccountID is an arbitrary 32-bit integer identifying namespace for data ingestion (aka tenant).
It is possible to set it as accountID:projectID, where projectID is also arbitrary 32-bit integer.
If projectID isn't set, then it equals to 0
--vm-concurrency value Number of workers concurrently performing import requests to VM (default: 2)
--vm-compress Whether to apply gzip compression to import requests (default: true)
--vm-batch-size value How many samples importer collects before sending the import request to VM (default: 200000)
Expand Down Expand Up @@ -194,7 +196,9 @@ Should be the same as --httpListenAddr value for single-node version or VMInsert
Please note, that vmctl performs initial readiness check for the given address by checking `/health` endpoint. (default: "http://localhost:8428")
--vm-user value VictoriaMetrics username for basic auth [$VM_USERNAME]
--vm-password value VictoriaMetrics password for basic auth [$VM_PASSWORD]
--vm-account-id value Account(tenant) ID - is required for cluster VM. (default: -1)
--vm-account-id value AccountID is an arbitrary 32-bit integer identifying namespace for data ingestion (aka tenant).
It is possible to set it as accountID:projectID, where projectID is also arbitrary 32-bit integer.
If projectID isn't set, then it equals to 0
--vm-concurrency value Number of workers concurrently performing import requests to VM (default: 2)
--vm-compress Whether to apply gzip compression to import requests (default: true)
--vm-batch-size value How many samples importer collects before sending the import request to VM (default: 200000)
Expand Down
9 changes: 5 additions & 4 deletions flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ var (
Usage: "VictoriaMetrics password for basic auth",
EnvVars: []string{"VM_PASSWORD"},
},
&cli.IntFlag{
Name: vmAccountID,
Value: -1,
Usage: "Account(tenant) ID - is required for cluster VM.",
&cli.StringFlag{
Name: vmAccountID,
Usage: "AccountID is an arbitrary 32-bit integer identifying namespace for data ingestion (aka tenant). \n" +
"It is possible to set it as accountID:projectID, where projectID is also arbitrary 32-bit integer. \n" +
"If projectID isn't set, then it equals to 0",
},
&cli.UintFlag{
Name: vmConcurrency,
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func initConfigVM(c *cli.Context) vm.Config {
Password: c.String(vmPassword),
Concurrency: uint8(c.Int(vmConcurrency)),
Compress: c.Bool(vmCompress),
AccountID: c.Int(vmAccountID),
AccountID: c.String(vmAccountID),
BatchSize: c.Int(vmBatchSize),
SignificantFigures: c.Int(vmSignificantFigures),
}
Expand Down
10 changes: 5 additions & 5 deletions vm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ type Config struct {
Concurrency uint8
// Whether to apply gzip compression
Compress bool
// AccountID for cluster version
// Less than 0 assumes single node version
AccountID int
// AccountID for cluster version.
// Empty value assumes it is a single node version
AccountID string
// BatchSize defines how many samples
// importer collects before sending the import request
BatchSize int
Expand Down Expand Up @@ -83,10 +83,10 @@ func NewImporter(cfg Config) (*Importer, error) {
// if single version
// see https://github.com/VictoriaMetrics/VictoriaMetrics/tree/master#how-to-import-time-series-data
importPath := addr + "/api/v1/import"
if cfg.AccountID != -1 {
if cfg.AccountID != "" {
// if cluster version
// see https://github.com/VictoriaMetrics/VictoriaMetrics/tree/cluster#url-format
importPath = fmt.Sprintf("%s/insert/%d/prometheus/api/v1/import", addr, uint32(cfg.AccountID))
importPath = fmt.Sprintf("%s/insert/%s/prometheus/api/v1/import", addr, cfg.AccountID)
}

im := &Importer{
Expand Down

0 comments on commit 7c89c7f

Please sign in to comment.