forked from knyar/prometheus-remote-backfill
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
promdump: Add support for filtering metrics collection by node / inst…
…ance Implements yugabyte/yb-tools#74. Added two mutually exclusive flags --instances and --nodes that permit users to specify a list of instances (full instance names as shown in the exported_instance label) or a list of node numbers (e.g. 1,3-7,12) to limit metrics collection to only the specified nodes. Added a func buildInstanceLabelString that converts the --instances or --nodes flag value into PromQL exported_instance labels. Currently, the list of instances in --instances is converted directly to PromQL without any additional validation or processing. For --nodes, the func converts numeric ranges of the form a-c into a list of nodes, concatenated with any individual node specifiers, and the resulting list of nodes is converted to a RegEx non-capturing group and concatenated to the node_prefix value to form the PromQL exported_instance label. This label is returned to the caller. The up metric and several others related to scraping do not have exported_instance labels, so the PromQL includes an extra | in the RegEx that forces a match against an empty or missing exported_instance label. Added some simple validation to enforce the mutual exclusivity of the --instances and --nodes flags. Specifying an instance or node filter disables automatic collection of platform metrics. The typical use case for this type of filtering is to split collection up into groups of nodes to reduce file sizes and processing time. We do not want to include the platform metrics in every group, and so we disable collection of platform metrics in this case. Platform metrics can be re-enabled using the --platform flag as normal. Made PromQL statement generation a little more modular. The various label specifiers are now generated and appended to a slice strings, then wrapped in {} at the end instead. This is perhaps a little harder to read but is more flexible if we need to add additional labels later. A future refactor should consider perhaps converting this logic to use a map instead of a slice of strings since labels are always of the form key="value". Added some clarifying comments after having to expend mental cycles remembering how this section of the code works. Reduced the chattiness of the logs by putting some of the more detailed log statements behind the --debug flag. Changed -metric to --metric in the help output for the --out flag to be consistent with other outputs. Tidied up several output and log lines for consistency of format and phrasing. Known Issues: Currently, the --node_prefix flag is still required even when specifying a --instances flag. This can be improved later as part of the fix for yugabyte/yb-tools#93.
- Loading branch information
1 parent
28b088b
commit ee8d6f0
Showing
1 changed file
with
146 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters