Environment
- YugabyteDB Anywhere - 2.20 and older
- YugabyteDB Anywhere - 2024.1
- YugabyteDB Anywhere - 2024.2
Issue
Occasionally, the support or development teams may request a dump of raw metrics data for a Universe when analyzing an issue. This article describes how to export this data from the YugabyteDB Anywhere (YBA) Prometheus and upload it for analysis by the Yugabyte team.
ConsiderationsFor systems managing large numbers of Universes and / or databases with many tables, a large batch size may cause Prometheus to run out of memory and crash while collecting tserver metrics. For busy systems, reduce the initial batch size. If too much data is returned for a query, promdump will automatically halve the batch size and retry, to a minimum of 1s batches and a maximum of 99,999 output files. If necessary, the Consider suppressing collection of table or tablet metrics with the corresponding |
Resolution
Overview
Yugabyte collects and stores metrics data in an instance of the open source Prometheus monitoring system running on the YugabyteDB Anywhere (YBA) node. The data can be extracted from the Prometheus database via API. The promdump binary described in this article can be used to easily export metrics data into JSON files that can later be imported into a compatible time series database for offline analysis.
You will need the following information:
- Hostname or IP address of the YBA node (default: localhost)
- Port number of the YBA Prometheus instance (default: 9090)
- Any two of (a) start time, (b) end time, and (c) period for which to collect data; if not overridden, the end time defaults to "now" and the period to 7 days
- A YBA API token and the name / UUID of the Universe for which to collect metrics --OR-- the "node prefix" value for the Universe if running promdump in legacy mode (example: yb-prod-appname)
Steps
1. Download the latest promdump binary (https://github.com/yugabyte/prometheus-remote-backfill/releases/latest) from the Yugabyte fork of the prometheus-remote-backfill project (or the attachment to this article), copy it to the YBA node (or another Linux system that can reach the YBA Prometheus instance over the network), extract it, and mark it executable:
gunzip promdump.gz chmod +x promdump
The most recent binary is version 0.8.1 and was last updated on 2025-01-15. If you have a previous version of the binary, please download a fresh copy.
2. Collect information to be used in the promdump command. Examples are given below.
- The URL should be the hostname or IP address of the YBA node followed by a colon and the Prometheus port number.
- The name or UUID of the Universe. A list of available Universes will be printed if promdump is run with the
--list_universesflag and a valid YBA API token. - For legacy mode, the node prefix value can be found on the Nodes tab for the Universe. For example, if there is a node called yb-prod-appname-n1, the correct prefix value for this Universe is yb-prod-appname.
Start or end times must be in RFC3339 format. For example, midnight Eastern Daylight Time on April 3, 2023 could be written as:
2023-04-03T00:00:00-04:00
It is strongly recommended to specify times in UTC. For example, the time above could also be written in UTC as:
2023-04-03T04:00:00Z
- The period and batch values are normally written in hours or minutes. For example, to collect metrics for a single day, use a period of "24h".
3. Run a command similar to the following to dump the Yugabyte metrics:
./promdump --url=http://yba.example.com:9090 \ --yba_api_token=c340006e-0000-0000-0000-58c0000ee580 \ --universe_name=myapp \ --start_time=2023-04-03T04:00:00Z \ --period=24h \ --batch=15m
Be sure to update the parameters in the promdump command to match the information collected in step (2) above. The dumped metrics will be saved to files named node_export.00001, node_export.00002, master_export.00001, master_export.00002, etc. and the resulting files will be bundled into a compressed tar file at the end.
- If the YBA node is using a self-signed TLS certificate, the promdump command will fail with an error similar to "Get https://localhost/api/v1/customers: x509: certificate is not valid". Adding the flag
--skip_yba_host_verificationwill disable certificate verification and allow promdump to connect. WARNING: This flag instructs promdump to accept the YBA node's TLS certificate regardless of validity, which may be a potential security risk. It is strongly recommended to use certificates issued by a certificate authority on production systems. - If the command fails or produces only
platform.*output files, check for typos in the command and confirm that the values of the supplied parameters are correct. The most common issue is an incorrect node_prefix value. Ensure that the system where promdump is running can reach the YBA Prometheus on port 9090. - The "curl" utility can be used to test connectivity from the current host to the YBA API server and / or YBA Prometheus.
The following output shows a successful test connection to the YBA API server:
yugabyte@yba-host:~$ curl https://<yba_hostname> <!doctype html><html><head>...</html>
The following output shows a successful test connection to YBA Prometheus:
yugabyte@yba-host:~$ curl http://<prometheus_server_address>:9090 <a href="/graph">Found</a>.
The following shows an example of a failed test connection:
yugabyte@yba-host:~$ curl http://<prometheus_server_address>:9090 curl: (7) Failed to connect to yba-host port 9090: Connection refused
It is recommended to use the YBA API mode described above where possible. However, for systems with restricted access to YBA, systems with limited YBA permissions, or Kubernetes systems, promdump can be run in "legacy" mode by specifying the --node_prefix value for the target Universe manually. For example:
./promdump --url=http://yba.example.com:9090 \ --node_prefix=yb-prod-myapp \ --start_time=2023-04-03T04:00:00Z \ --period=24h \ --batch=15m
For Kubernetes clusters:
Using the API token can result in API calls failing and it is recommended to use "legacy" mode by specifying --node_prefix when collecting metrics from a Kubernetes cluster.
To retrieve the node prefix, in the YBA UI, under metrics, click on the Prometheus icon on one of the graphs to open the Prometheus UI. The node_prefix value will be visible in the PromQL query.
When the Prometheus UI is not accessible via the metrics UI (due to network restrictions, firewalls, proxy setting, etc.), the node_prefix can be retrieved by running kubectl exec to open a shell on the yugaware pod, then in the prometheus targets directory, grepping the yugabyte json file for the universe. For example:
kubectl exec -it <yugaware pod> -c yugaware -n <namespace> -- bash cd /opt/yugabyte/prometheus/targets grep node_prefix yugabyte.<Universe UUID>.json
If the node_prefix is not in a standard format, you will receive an error when running promdump. The following promdump flag can be used to bypass this check:--node_prefix_validation=false
3a. What to do if your prometheus is password protected
If your prometheus instance is password protected, it is now possible to add the password via a hidden file and an addition to the url. For example:
vi .prompw
export PROMPW="abc123"
(save and quit)
source .prompw
./promdump --url="https://promuser:${PROMPW}@ybahost.example.com:9090" \
--yba_api_token=c340006e-0000-0000-0000-58c0000ee580 \
--universe_name=myapp \
--start_time=2023-04-03T04:00:00Z \
--period=24h \
--batch=15m
rm .prompwThe PROMPW variable will be your password for prometheus - "abc123" is shown here for illustration. Note that the .prompw file should be deleted after use for security reasons.
4. Skip this step unless the Yugabyte support team has asked you to collect a custom metric. To collect a custom metric, use the --metric and --out parameters to specify the custom metric and output file prefix as shown in the example below:
./promdump --url=http://yba.example.com:9090 \
--metric='{saved_name="follower_lag_ms",node_prefix="yb-prod-appname"}' \
--out=custom_export \
--start_time=2023-04-03T04:00:00Z \
--period=24h \
--batch=15mBe sure to update the --metric parameter with the custom metric requested by support. Specifying both the --metric and --universe_nameflags in the promdump command will collect the standard Yugabyte metrics and the custom metric specified in the --metric parameter. For example:
./promdump --url=http://yba.example.com:9090 \
--yba_api_token=c340006e-0000-0000-0000-58c0000ee580 \
--universe_name=myapp \
--metric='{saved_name="follower_lag_ms",node_prefix="yb-prod-appname"}' \
--out=custom_export \
--start_time=2023-04-03T04:00:00Z \
--period=24h \
--batch=15m5. Upload the resulting tar file to your Zendesk ticket.
Comments
0 comments
Please sign in to leave a comment.