Skip to content

promtool command - Promtool command with extras

The PromTool cli with XTras

ie

  • driven by environment-variable
  • Prometheus Kubernetes Operator CRD aware
Terminal window
cat metrics.prom | promtool check metrics
curl -s http://localhost:9090/metrics | promtool check metrics
promtool test rules test.yml

The files (metrics.prom, test.yml) should be in the current directory.

The PromTool is executed with:

  • the Prometheus docker image
  • where only the working directory tree is available

The command check prometheusRule prometheusRuleFile permits to check a Prometheus Rule

This command enhances the promtool test command so that the rule_files is generated from Prometheus Rule.

The command test prometheusRule testFile will:

  • scan all directory recursively for Prometheus Rule
  • create a temporary rule file from them
  • inject it into the testFile as value of the rule_files property.

This script will set the --url flag (The URL for the Prometheus server) if the KUBEE_PROM_URL is set (default to http://localhost:9090)

This script will set the --http.config.file (It defines the HTTP client configuration file for promtool to connect to Prometheus) with Basic Auth configuration.

The Basic Auth credentials should be stored in pass

  • For the basic_auth user: the env KUBEE_PROM_BASIC_AUTH_PASS_USER gives its path
Terminal window
# ie this command should return the user
pass "$KUBEE_PROM_BASIC_AUTH_PASS_USER"
Terminal window
# ie this command should return the password
pass "$KUBEE_PROM_BASIC_AUTH_PASS_PASSWORD"