Would tooling for PromQL formatting/manipulation be useful and where should it live?

已查看 63 次
跳至第一个未读帖子

Rob Skillington

未读,
2022年10月4日 16:58:462022/10/4
收件人 Prometheus Developers
Hey Prometheus team,

Have noticed asks for tooling around reformatting/manipulating and generally refactoring sets of queries and rule definitions (where there is a high number of defined queries). Use cases include such cases as "I want to duplicate a set of alerts to target different environments with different label combinations and also conditions".

I opened a PR to add some basic commands given I had seen this earlier PR mention that there was intention for the PromQL AST pretty print formatting to be useable from promtool:
https://github.com/prometheus/prometheus/pull/10544

I now realize it may have been better perhaps to raise the question of if/where it should live here before opening the PR. What would be the reception of housing these commands in promtool and/or if not there then where a good recommended place would be for these to live do people think?

PR in question:
https://github.com/prometheus/prometheus/pull/11411

Best,
Rob



David Leadbeater

未读,
2022年10月5日 05:13:042022/10/5
收件人 Rob Skillington、Prometheus Developers
Hi Rob,

I wonder if PromQL related things fit in promtool given the use for
PromQL is wider than just Prometheus. I can imagine something like a
"promqltool", which might actually be backed by the promql language
server (so people can get similar things in editors too).

However that's clearly a larger discussion, I don't see an issue with
adding some promql subcommands to promtool for now, particularly as
the formatting one exercises the code in Prometheus and is useful for
developers anyway.

I do think it's important to get the interface right, while we don't
guarantee complete stability in promtool, it is difficult to change
without breaking people. To that end I'm thinking of adding a top
level "--experimental" flag in promtool, which can then enable the
promql subcommands. (We do have feature flags in promtool, but that
feels wrong here, as feature flags are currently shared with
prometheus.)

David
> --
> You received this message because you are subscribed to the Google Groups "Prometheus Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-devel...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-developers/CABakzZa5NKzVY5yaY-NKbuqeULx8zhOHkuTKo_QiWCpFG%2BDnxQ%40mail.gmail.com.

Julius Volz

未读,
2022年10月5日 05:22:262022/10/5
收件人 David Leadbeater、Rob Skillington、Prometheus Developers
I do feel that formatting entire rule files would be in scope for promtool, but more specialized formatting and manipulations of individual PromQL queries (while cool) should likely live in a separate tool. I see the scope of promtool to be mostly a tool to interact with both the Prometheus server, its immediately configuration files, and its TSDB directory.

Julien Pivotto

未读,
2022年10月5日 05:25:582022/10/5
收件人 Julius Volz、David Leadbeater、Rob Skillington、Prometheus Developers
I think the opposite - Prometheus contains PromQL, it's same codebase,
same version. It makes sense to have those tools in promtool as well, so
it is shipped to everyone, and has a known version.
> > https://groups.google.com/d/msgid/prometheus-developers/CAP9KPhDebQUp3jMHjHgK4QzDuMd9Q6d1i2aXUkpBJQBRYKUrWg%40mail.gmail.com
> > .
> >
>
> --
> You received this message because you are subscribed to the Google Groups "Prometheus Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-devel...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-developers/CA%2BT6Yoy6q16DUOTW0Tt8aCL6J4SV%2BfeKpqapz%2BsYgTRqAMemMQ%40mail.gmail.com.

--
Julien Pivotto
@roidelapluie

Julius Volz

未读,
2022年10月5日 05:55:582022/10/5
收件人 Julius Volz、David Leadbeater、Rob Skillington、Prometheus Developers
The versioning aspect is a good point, I hadn't thought of that.

If we make promtool's scope broader than what I proposed, it's IMO still a question of where we draw the line in terms of niche specialized use cases. The proposes features in https://github.com/prometheus/prometheus/pull/11411 are kind of borderline to me in that regard, but I also wouldn't be unhappy if they went into promtool.

r...@chronosphere.io

未读,
2022年10月5日 12:06:142022/10/5
收件人 Prometheus Developers
Yes I realized that to manipulate the AST (and the AST will of course change as new functions and features are added) much like codemirror-promql moved into the Prometheus repository to get updates as they come to PromQL that somewhere in the Prometheus repo itself would be a good starting point.

How would you all feel of adding the commands under a "--experimental" flag as David suggested? I'd be happy to make the "--experimental" flag addition too David if you like, also happy to wait too until that's available if that's preferential.

Matthias Rampke

未读,
2022年10月5日 12:45:582022/10/5
收件人 r...@chronosphere.io、Prometheus Developers
Re: drawing the line – I often feel like "specialized" tools that try to solve all advanced use cases end up with very complex and hard to use configuration (looking at you, relabeling). I often find it more pleasant to express what I want to do as code. What would an API look like that you or others could use to build their own tools for their specific needs, without making it part of any particular CLI?

In general, is there a mock-up or reference of the interface you propose?

/MR

Frederic Branczyk

未读,
2022年10月5日 12:50:012022/10/5
收件人 Matthias Rampke、Prometheus Developers、r...@chronosphere.io
I’m not sure your use cases match, but I’ve always wanted something like prepared statements where something like a “?” operator could be an expression placeholder, possibly even restricted to something like a label matcher, or just a label-value, etc.

I think there might be overlap in the use cases but if not then sorry for the noise.

Julien Pivotto

未读,
2022年10月5日 16:46:222022/10/5
收件人 r...@chronosphere.io、Prometheus Developers
Promtool check metrics is an example that also does not call an API on
Prometheus side.

I think a subcommand Promtool promql would be acceptable to me.
> To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-developers/41dc988f-b46c-49d0-aa2c-e09865d883c5n%40googlegroups.com.


--
Julien Pivotto
@roidelapluie

Julius Volz

未读,
2022年10月6日 12:09:572022/10/6
收件人 r...@chronosphere.io、Prometheus Developers
Ok, let's do it then, preferably with some --experimental flag for now.



--
Julius Volz
PromLabs - promlabs.com
回复全部
回复作者
转发
0 个新帖子