rpk generate prometheus-config

Generate the Prometheus configuration to scrape Redpanda nodes.

The output of this command should be included in the 'scrape_configs' array within the YAML configuration file of your Prometheus instance.

There are different options you can use when generating the configuration:

  • If you provide the --seed-addr flag, the command will use the address to discover the rest of the cluster hosts using Redpanda’s Kafka API.

  • If you provide the --node-addrs flag, the command will directly use the provided addresses.

  • If neither --seed-addr nor --node-addrs are passed, the command will read the redpanda config file and use the node IP configured there.

If the node you want to scrape uses TLS, you can provide the TLS flags (--tls-key, --tls-cert, and --tls-truststore). The command will generate the required tls_config section in the scrape configuration.

Additionally, you have the option to define labels for the target in the static-config section by using the --labels flag. You can specify the desired metric that the label should target, either internal (/metrics) or public (/public_metrics).

For example:

--job-name test --labels "public:group=one,internal:group=two"

This will result in two separate configs for the test job, each with a different label:

- job_name: test
  static_configs:
  - targets: [<targets>]
    labels:
    group: one
    metrics_path: /public_metrics
- job_name: test
  static_configs:
  - targets: [<targets>]
    labels:
    group: two
    metrics_path: /metrics

You can only provide one label per job. By default, if no metric target is specified, the label will be shared across the jobs.

Usage

rpk generate prometheus-config [flags]

Flags

Value Type Description

-h, --help

-

Help for prometheus-config.

--internal-metrics

-

Include scrape config for internal metrics (/metrics).

--job-name

string

The prometheus job name by which to identify the Redpanda nodes (default "redpanda").

--labels

strings

Comma-separated labels and their target metric (int or pub): [metric|labelName:labelValue, …​].

--node-addrs

strings

Comma-separated list of admin API host:ports.

--seed-addr

string

The URL of a Redpanda node with which to discover the rest.

--tls-cert

string

The certificate to be used for TLS authentication with the broker.

--tls-enabled

-

Enable TLS for the Kafka API (not necessary if specifying custom certs).

--tls-key

string

The certificate key to be used for TLS authentication with the broker.

--tls-truststore

string

The CA certificate to be used for TLS communication with the broker.

--config

string

Redpanda or rpk config file; default search paths are /var/lib/redpanda/.config/rpk/rpk.yaml, $PWD/redpanda.yaml, and /etc/redpanda/redpanda.yaml.

-X, --config-opt

stringArray

Override rpk configuration settings. See rpk -X or execute rpk -X help for inline detail or rpk -X list for terser detail.

--profile

string

Profile to use. See rpk profile for more details.

-v, --verbose

-

Enable verbose logging.