feat: allow `influx -import` to import from stdin (#25472)
Allow `influx -import` to import from stdin by specifying `-` as the path. Example: `influx -import -path -`gw_fix_load_log
parent
3c87f524ed
commit
86e81167b8
|
@ -101,7 +101,7 @@ func main() {
|
||||||
-pps
|
-pps
|
||||||
How many points per second the import will allow. By default it is zero and will not throttle importing.
|
How many points per second the import will allow. By default it is zero and will not throttle importing.
|
||||||
-path
|
-path
|
||||||
Path to file to import
|
Path to file to import ('-' for stdin)
|
||||||
-compressed
|
-compressed
|
||||||
Set to true if the import file is compressed
|
Set to true if the import file is compressed
|
||||||
|
|
||||||
|
|
|
@ -87,11 +87,16 @@ func (i *Importer) Import() error {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// Open the file
|
// Open the file
|
||||||
f, err := os.Open(i.config.Path)
|
var f *os.File
|
||||||
if err != nil {
|
if i.config.Path == "-" {
|
||||||
|
f = os.Stdin
|
||||||
|
} else {
|
||||||
|
var err error
|
||||||
|
if f, err = os.Open(i.config.Path); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
}
|
||||||
|
|
||||||
var r io.Reader
|
var r io.Reader
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue