Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PromQL format and label matcher set/delete commands to promtool #11411

Merged

Conversation

robskillington
Copy link
Contributor

This builds on #10544 which
intended later would be added the ability to format PromQL queries to promtool
to allow formatting of PromQL queries and also setting/deleting label matchers
contained by a PromQL query (useful for programmatic manipulation of query
definitions).

@robskillington
Copy link
Contributor Author

Example usage:

$ ./promtool promql format 'foo{bar="baz"}'
foo{bar="baz"}
$ ./promtool promql format 'foo{bar="baz"}/bar'
foo{bar="baz"} / bar
$ ./promtool promql label-matchers set 'foo{bar="baz"}/bar' 'qux' 'qaz'
foo{bar="baz",qux="qaz"} / bar{qux="qaz"}
$ ./promtool promql label-matchers delete 'foo{bar="baz"}/bar' 'bar'
foo / bar

@robskillington
Copy link
Contributor Author

Realized I should have brought this up directly w/ Prometheus team first, have opened the discussion here:
https://groups.google.com/g/prometheus-developers/c/toAb2wLi6Pg/m/z1_eOyO8BAAJ

@roidelapluie
Copy link
Member

Sounds like there is consensus on the mailing list

@roidelapluie roidelapluie self-assigned this Jul 11, 2023
robskillington and others added 2 commits July 12, 2023 22:33
Signed-off-by: Rob Skillington <rob@chronosphere.io>
Signed-off-by: Julien Pivotto <roidelapluie@o11y.eu>
Signed-off-by: Julien Pivotto <roidelapluie@o11y.eu>
@roidelapluie
Copy link
Member

I have rebased this and added a --experimental flag


### `promtool promql`

PromQL formatting and editing. Requires the --experimental flag.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
PromQL formatting and editing. Requires the --experimental flag.
PromQL formatting and editing. Requires the `--experimental` flag.

@juliusv
Copy link
Member

juliusv commented Jul 12, 2023

👍 otherwise

Signed-off-by: Julien Pivotto <roidelapluie@o11y.eu>
@roidelapluie roidelapluie merged commit 52b1ddc into prometheus:main Jul 15, 2023
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants