mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
Check health & ready: move to flags (#12223)
This makes it more consistent with other command like import rules. We don't have stricts rules and uniformity accross promtool unfortunately, but I think it's better to only have the http config on relevant check commands to avoid thinking Prometheus can e.g. check the config over the wire. Signed-off-by: Julien Pivotto <roidelapluie@o11y.eu>
This commit is contained in:
parent
6cecb87941
commit
391473141d
|
@ -89,7 +89,6 @@ func main() {
|
|||
app.HelpFlag.Short('h')
|
||||
|
||||
checkCmd := app.Command("check", "Check the resources for validity.")
|
||||
checkCmd.Flag("http.config.file", "HTTP client configuration file for promtool to connect to Prometheus.").PlaceHolder("<filename>").ExistingFileVar(&httpConfigFilePath)
|
||||
|
||||
sdCheckCmd := checkCmd.Command("service-discovery", "Perform service discovery for the given job name and report the results, including relabeling.")
|
||||
sdConfigFile := sdCheckCmd.Arg("config-file", "The prometheus config file.").Required().ExistingFile()
|
||||
|
@ -117,16 +116,12 @@ func main() {
|
|||
).Required().ExistingFiles()
|
||||
|
||||
checkServerHealthCmd := checkCmd.Command("healthy", "Check if the Prometheus server is healthy.")
|
||||
serverHealthURLArg := checkServerHealthCmd.Arg(
|
||||
"server",
|
||||
"The URL of the Prometheus server to check (e.g. http://localhost:9090)",
|
||||
).URL()
|
||||
checkServerHealthCmd.Flag("http.config.file", "HTTP client configuration file for promtool to connect to Prometheus.").PlaceHolder("<filename>").ExistingFileVar(&httpConfigFilePath)
|
||||
checkServerHealthCmd.Flag("url", "The URL for the Prometheus server.").Default("http://localhost:9090").URLVar(&serverURL)
|
||||
|
||||
checkServerReadyCmd := checkCmd.Command("ready", "Check if the Prometheus server is ready.")
|
||||
serverReadyURLArg := checkServerReadyCmd.Arg(
|
||||
"server",
|
||||
"The URL of the Prometheus server to check (e.g. http://localhost:9090)",
|
||||
).URL()
|
||||
checkServerReadyCmd.Flag("http.config.file", "HTTP client configuration file for promtool to connect to Prometheus.").PlaceHolder("<filename>").ExistingFileVar(&httpConfigFilePath)
|
||||
checkServerReadyCmd.Flag("url", "The URL for the Prometheus server.").Default("http://localhost:9090").URLVar(&serverURL)
|
||||
|
||||
checkRulesCmd := checkCmd.Command("rules", "Check if the rule files are valid or not.")
|
||||
ruleFiles := checkRulesCmd.Arg(
|
||||
|
@ -292,10 +287,10 @@ func main() {
|
|||
os.Exit(CheckConfig(*agentMode, *checkConfigSyntaxOnly, newLintConfig(*checkConfigLint, *checkConfigLintFatal), *configFiles...))
|
||||
|
||||
case checkServerHealthCmd.FullCommand():
|
||||
os.Exit(checkErr(CheckServerStatus(*serverHealthURLArg, checkHealth, httpRoundTripper)))
|
||||
os.Exit(checkErr(CheckServerStatus(serverURL, checkHealth, httpRoundTripper)))
|
||||
|
||||
case checkServerReadyCmd.FullCommand():
|
||||
os.Exit(checkErr(CheckServerStatus(*serverReadyURLArg, checkReadiness, httpRoundTripper)))
|
||||
os.Exit(checkErr(CheckServerStatus(serverURL, checkReadiness, httpRoundTripper)))
|
||||
|
||||
case checkWebConfigCmd.FullCommand():
|
||||
os.Exit(CheckWebConfig(*webConfigFiles...))
|
||||
|
@ -390,12 +385,10 @@ func (ls lintConfig) lintDuplicateRules() bool {
|
|||
return ls.all || ls.duplicateRules
|
||||
}
|
||||
|
||||
const promDefaultURL = "http://localhost:9090"
|
||||
|
||||
// Check server status - healthy & ready.
|
||||
func CheckServerStatus(serverURL *url.URL, checkEndpoint string, roundTripper http.RoundTripper) error {
|
||||
if serverURL == nil {
|
||||
serverURL, _ = url.Parse(promDefaultURL)
|
||||
if serverURL.Scheme == "" {
|
||||
serverURL.Scheme = "http"
|
||||
}
|
||||
|
||||
config := api.Config{
|
||||
|
|
|
@ -58,7 +58,6 @@ Check the resources for validity.
|
|||
|
||||
| Flag | Description |
|
||||
| --- | --- |
|
||||
| <code class="text-nowrap">--http.config.file</code> | HTTP client configuration file for promtool to connect to Prometheus. |
|
||||
| <code class="text-nowrap">--extended</code> | Print extended information related to the cardinality of the metrics. |
|
||||
|
||||
|
||||
|
@ -137,11 +136,12 @@ Check if the Prometheus server is healthy.
|
|||
|
||||
|
||||
|
||||
###### Arguments
|
||||
###### Flags
|
||||
|
||||
| Argument | Description |
|
||||
| --- | --- |
|
||||
| server | The URL of the Prometheus server to check (e.g. http://localhost:9090) |
|
||||
| Flag | Description | Default |
|
||||
| --- | --- | --- |
|
||||
| <code class="text-nowrap">--http.config.file</code> | HTTP client configuration file for promtool to connect to Prometheus. | |
|
||||
| <code class="text-nowrap">--url</code> | The URL for the Prometheus server. | `http://localhost:9090` |
|
||||
|
||||
|
||||
|
||||
|
@ -152,11 +152,12 @@ Check if the Prometheus server is ready.
|
|||
|
||||
|
||||
|
||||
###### Arguments
|
||||
###### Flags
|
||||
|
||||
| Argument | Description |
|
||||
| --- | --- |
|
||||
| server | The URL of the Prometheus server to check (e.g. http://localhost:9090) |
|
||||
| Flag | Description | Default |
|
||||
| --- | --- | --- |
|
||||
| <code class="text-nowrap">--http.config.file</code> | HTTP client configuration file for promtool to connect to Prometheus. | |
|
||||
| <code class="text-nowrap">--url</code> | The URL for the Prometheus server. | `http://localhost:9090` |
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue