app:=kingpin.New(filepath.Base(os.Args[0]),"Tooling for the Prometheus monitoring system.").UsageWriter(os.Stdout)
app:=kingpin.New(filepath.Base(os.Args[0]),"Tooling for the Prometheus monitoring system.").UsageWriter(os.Stdout)
app.Version(version.Print("promtool"))
app.Version(version.Print("promtool"))
app.HelpFlag.Short('h')
app.HelpFlag.Short('h')
@ -124,14 +131,15 @@ func main() {
queryCmd:=app.Command("query","Run query against a Prometheus server.")
queryCmd:=app.Command("query","Run query against a Prometheus server.")
queryCmdFmt:=queryCmd.Flag("format","Output format of the query.").Short('o').Default("promql").Enum("promql","json")
queryCmdFmt:=queryCmd.Flag("format","Output format of the query.").Short('o').Default("promql").Enum("promql","json")
queryCmd.Flag("http.config.file","HTTP client configuration file for promtool to connect to Prometheus.").PlaceHolder("<filename>").ExistingFileVar(&httpConfigFilePath)
queryLabelsServer :=queryLabelsCmd.Arg("server","Prometheus server to query.").Required().URL()
queryLabelsCmd.Arg("server","Prometheus server to query.").Required().URLVar(&serverURL)
queryLabelsName:=queryLabelsCmd.Arg("name","Label name to provide label values for.").Required().String()
queryLabelsName:=queryLabelsCmd.Arg("name","Label name to provide label values for.").Required().String()
queryLabelsBegin:=queryLabelsCmd.Flag("start","Start time (RFC3339 or Unix timestamp).").String()
queryLabelsBegin:=queryLabelsCmd.Flag("start","Start time (RFC3339 or Unix timestamp).").String()
queryLabelsEnd:=queryLabelsCmd.Flag("end","End time (RFC3339 or Unix timestamp).").String()
queryLabelsEnd:=queryLabelsCmd.Flag("end","End time (RFC3339 or Unix timestamp).").String()
@ -200,7 +208,8 @@ func main() {
importFilePath:=openMetricsImportCmd.Arg("input file","OpenMetrics file to read samples from.").Required().String()
importFilePath:=openMetricsImportCmd.Arg("input file","OpenMetrics file to read samples from.").Required().String()
importDBPath:=openMetricsImportCmd.Arg("output directory","Output directory for generated blocks.").Default(defaultDBPath).String()
importDBPath:=openMetricsImportCmd.Arg("output directory","Output directory for generated blocks.").Default(defaultDBPath).String()
importRulesCmd:=importCmd.Command("rules","Create blocks of data for new recording rules.")
importRulesCmd:=importCmd.Command("rules","Create blocks of data for new recording rules.")
importRulesURL:=importRulesCmd.Flag("url","The URL for the Prometheus API with the data where the rule will be backfilled from.").Default("http://localhost:9090").URL()
importRulesCmd.Flag("http.config.file","HTTP client configuration file for promtool to connect to Prometheus.").PlaceHolder("<filename>").ExistingFileVar(&httpConfigFilePath)
importRulesCmd.Flag("url","The URL for the Prometheus API with the data where the rule will be backfilled from.").Default("http://localhost:9090").URLVar(&serverURL)
importRulesStart:=importRulesCmd.Flag("start","The time to start backfilling the new rule from. Must be a RFC3339 formatted date or Unix timestamp. Required.").
importRulesStart:=importRulesCmd.Flag("start","The time to start backfilling the new rule from. Must be a RFC3339 formatted date or Unix timestamp. Required.").
Required().String()
Required().String()
importRulesEnd:=importRulesCmd.Flag("end","If an end time is provided, all recording rules in the rule files provided will be backfilled to the end time. Default will backfill up to 3 hours ago. Must be a RFC3339 formatted date or Unix timestamp.").String()
importRulesEnd:=importRulesCmd.Flag("end","If an end time is provided, all recording rules in the rule files provided will be backfilled to the end time. Default will backfill up to 3 hours ago. Must be a RFC3339 formatted date or Unix timestamp.").String()
@ -224,6 +233,22 @@ func main() {
p=&promqlPrinter{}
p=&promqlPrinter{}
}
}
ifhttpConfigFilePath!=""{
ifserverURL!=nil&&serverURL.User.Username()!=""{
kingpin.Fatalf("Cannot set base auth in the server URL and use a http.config.file at the same time")