VictoriaMetrics / vmctl

Victoria Metrics command line tool
36 stars 8 forks source link

vmctl import to instance with httpAuth_username/password : missing error message on auth failure #19

Closed ulikl closed 4 years ago

ulikl commented 4 years ago

I would like to import data into a VictoriaMetrics instance, which is secured by by basic auth. I'm missing a flag to set the username and password.

The HTTP Url encoding of basic authentication doesn't work on any Victoriametrics URL, so the import in currently not possible.

Additionally the Victoriametrics error message is not displayed, only the stats are empty. e.g.

# vmctl influx --influx-addr https://localhost:8086 --influx-user .... --influx-password ... --influx-database migtest --vm-addr http://user:password@localhost:8432
InfluxDB import mode
2020/07/24 10:32:37 Exploring scheme for database "migtest"
2020/07/24 10:32:37 fetching fields: command: "show field keys"; database: "migtest"; retention: "autogen"
2020/07/24 10:32:37 found 3 fields
2020/07/24 10:32:37 fetching series: command: "show series"; database: "migtest"; retention: "autogen"
2020/07/24 10:32:37 found 2 series
Found 3 timeseries to import. Continue? [Y/n] Y
3 / 3 [-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 100.00% ? p/s
2020/07/24 10:32:39 Import finished!
2020/07/24 10:32:39 VictoriaMetrics importer stats:
  time spent while waiting: 0s;
  time spent while importing: 0s;
  total samples: 0;
  samples/s: NaN;
  total bytes: 0 B;
  bytes/s: -9223372036854775808 B;
  import requests: 0;
  import requests retries: 0;
2020/07/24 10:32:39 Total time: 2.050544054s
hagen1778 commented 4 years ago

Hello @ulikl! Have you tried following flags:

./vmctl influx --help | grep basic
   --vm-user value         VictoriaMetrics username for basic auth [$VM_USERNAME]
   --vm-password value     VictoriaMetrics password for basic auth [$VM_PASSWORD]
ulikl commented 4 years ago

@hagen1778 , thanks for the hint. I have I overlooked these options. This works fine.

But the missing error message is really confusing. Could you improve the error handling?

hagen1778 commented 4 years ago

Right! The errors are usually processed and returned to user during the import. In current case the number of series was so small that it "fit" the importer buffers and process exited before reading it. In commit https://github.com/VictoriaMetrics/vmctl/commit/36b96a8accf43d66b67319228e565033d6be99c9 this issue should be addressed. Thanks for reporting!

ulikl commented 4 years ago

Hi @hagen1778 thank you very much, the request error is shown now immediately.

...
Found 5 timeseries to import. Continue? [Y/n] Y
2020/08/05 09:37:32 Import process failed:
test1_value{id="1",x="2",db="migtest"} for timestamps range 1595578136075 - 1595578136075
test2_w{id="1",x="2",db="migtest"} for timestamps range 1595578161760 - 1595578161760
test_influxline_field2{tag1="value1",tag2="value2",db="migtest"} for timestamps range 1593184 - 1593184
 with error: import request error for "http://127.0.0.1:8428": unexpected response code 401: