Support creating/updating prometheus rules#5228
Support creating/updating prometheus rules#5228lezzago wants to merge 4 commits intoopensearch-project:mainfrom
Conversation
Signed-off-by: Ashish Agrawal <ashisagr@amazon.com>
PR Reviewer Guide 🔍(Review updated until commit b5480e9)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to b5480e9 Explore these optional code suggestions:
Previous suggestionsSuggestions up to commit c047583
Suggestions up to commit 3a17d23
Suggestions up to commit 98d6a33
|
Signed-off-by: Ashish Agrawal <ashisagr@amazon.com>
|
Persistent review updated to latest commit 3a17d23 |
Signed-off-by: Ashish Agrawal <ashisagr@amazon.com>
|
Persistent review updated to latest commit c047583 |
Signed-off-by: Ashish Agrawal <ashisagr@amazon.com>
|
Persistent review updated to latest commit b5480e9 |
Description
Add CRUD support for the Prometheus/Cortex/AMP Ruler API through the Direct Query resources framework. This enables creating, reading, updating, and deleting recording and alerting rule groups via the OpenSearch
SQL plugin.
New capabilities:
Response normalization: The Ruler API returns different formats depending on the backend (Prometheus JSON, Cortex/Thanos YAML map, AMP JSON). A new normalizeRulesResponse() layer handles all three and returns a
consistent {"groups":[...]} structure.
Configurable Ruler URI: A new prometheus.ruler.uri datasource property allows configuring a separate base URL for Ruler operations. This is needed for Cortex where the Ruler API lives at a different path than the
query API (e.g., http://host:9009 vs http://host:9009/api/prom). Defaults to prometheus.uri when not set.
Behavioral change to getRules(): The existing getRules() method was updated to use the same response normalization. Previously it only handled Prometheus JSON ({"status":"success","data":{...}}); now it also
handles Cortex/Thanos YAML responses. The return shape is unchanged ({"groups":[...]}), and a resource leak (unclosed HTTP response) was fixed with try-with-resources. Error messages now use a different format
("Ruler request failed with code: ..." instead of the generic readResponse() error).
Related Issues
N/A
Check List
--signoffor-s.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.