grafana / grafana

The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
https://grafana.com
GNU Affero General Public License v3.0
60.72k stars 11.61k forks source link

Prometheus: Place custom inputs first when using regex filter values in the query builder #87360

Closed NWRichmond closed 1 week ago

NWRichmond commented 2 weeks ago

What is this feature?

This PR updates the Prometheus data source's query builder. Specifically, its handling of filter values when using regex selectors (~=, ~!).

Before

In the <Input /> for filter values, custom input would always appear last in the autocomplete options. When using regex operators, the regex input would appear last and was not focused by default. The text next to the regex input didn't align with the outcome of pressing the enter key.

https://github.com/grafana/grafana/assets/5732000/98661405-ef9f-47b6-8f21-151e9cb0c50f

After

When using regex selectors, custom input appears as the top-most (and focused-by-default) option. Misleading "Hit enter to add" text has been removed to avoid confusion.

https://github.com/grafana/grafana/assets/5732000/bd8a9fef-7ace-4583-9292-da9b3e5556de

Why do we need this feature?

As described in #70635, it's difficult for Prometheus data source users to select filter values when using regex selectors in the query builder. This difficulty comes from two areas:

Who is this feature for?

Prometheus data source users, especially those who use regex for filter values in the query builder.

Which issue(s) does this PR fix?

This PR fixes #70635.

Special notes for your reviewer:

Please check that: