Add patch API #4
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adding new API:
/api/v1/alerting/rules | PATCH
/api/v1/alerting/rules/ruleId | PATCH
update user defined alert:
RULE_ID="TestSinglePatch/15a2940d8cdb3cfd51c81261ad11636094c959259469d41ddce1dd3581531bb3" && curl -s -X PATCH "http://localhost:9001/api/v1/alerting/rules/$RULE_ID" -H "Content-Type: application/json" -d '{"alertingRule":{"alert":"TestSinglePatch","expr":"cpu > 85","for":"5m","labels":{"severity":"critical","team":"frontend","environment":"production"},"annotations":{"summary":"Critical CPU usage","description":"CPU usage is above 85% for 5 minutes"}}}' | jq '.'
bulk update user defined alerts:
RULE1_ID="BulkTestAlert1/cde519b0d13ed1705006250e84025cf7817e9d0b9b93be59788d0039ed4c2ac3" && RULE2_ID="BulkTestAlert2/78d297397da44f293ab542b16268d0e83138f60cf8f02628df0a7c28fb416ea7" && curl -s -X PATCH "http://localhost:9001/api/v1/alerting/rules" -H "Content-Type: application/json" -d "{"ruleIds":["$RULE1_ID","$RULE2_ID"],"labels":{"severity":"critical","team":"sre","environment":"production"}}" | jq '.'
update platform alert:
RULE_ID="TestPlatformPatchSingle;73e926c75ad7f21249d72be4052f714aae009e9c430c15a5f49483760eaf8d8f" && curl -s -X PATCH "http://localhost:9001/api/v1/alerting/rules/$RULE_ID" -H "Content-Type: application/json" -d '{"alertingRule":{"alert":"TestPlatformPatchSingle","expr":"up == 0","for":"2m","labels":{"severity":"critical","team":"platform","environment":"production"},"annotations":{"summary":"Testing single patch for platform alerts","description":"This is a test alert for platform single patch"}}}' | jq '.'
{
"id": "TestPlatformPatchSingle;73e926c75ad7f21249d72be4052f714aae009e9c430c15a5f49483760eaf8d8f",
"status_code": 204
}
kubectl get alertrelabelconfig alertmanagement-testplatformpatchsingle-73e926c75ad7f21249d72be4052f714aae009e9c430c15a5f49483760eaf8d8f -n openshift-monitoring -o yaml | grep -A 30 "spec:"
bulk update platform alert:
RULE1_ID="TestPlatformBulkNew1;58eb54715dc0ea0d1da4cae0aa7a556c7281dd662500635ee3e49c9d0a25920d" && RULE2_ID="TestPlatformBulkNew2;e43e9eabc0467e3912b96c3854fbc79ce7face00037f4e94b0e3feb4337baf83" && curl -s -X PATCH "http://localhost:9001/api/v1/alerting/rules" -H "Content-Type: application/json" -d "{"ruleIds":["$RULE1_ID","$RULE2_ID"],"labels":{"severity":"critical","team":"platform",
"environment":"production"}}" | jq '.'
kubectl get alertrelabelconfig -n openshift-monitoring -o json | jq -r '.items[] | select(.metadata.name | contains("testplatformbulknew")) | {name: .metadata.name, namespace: .metadata.namespace, configs: .spec.configs}' | head -50