-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathmain.go
48 lines (40 loc) · 1008 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"context"
"fmt"
"os"
"os/signal"
"syscall"
"github.com/pteich/configstruct"
"github.com/pteich/elastic-query-export/export"
"github.com/pteich/elastic-query-export/flags"
)
var Version string
func main() {
conf := flags.Flags{
ElasticURL: "http://localhost:9200",
ElasticVerifySSL: false,
Index: "logs-*",
Query: "*",
OutFormat: flags.FormatCSV,
Outfile: "output.csv",
ScrollSize: 1000,
Timefield: "@timestamp",
}
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGTERM, syscall.SIGINT)
defer cancel()
cmd := configstruct.NewCommand(
"",
"CLI tool to export data from ElasticSearch into a CSV or JSON file. https://github.com/pteich/elastic-query-export",
&conf,
func(c *configstruct.Command, cfg interface{}) error {
export.Run(ctx, cfg.(*flags.Flags))
return nil
},
)
err := cmd.ParseAndRun(os.Args)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
}