diff --git a/pkg/services/ngalert/api/api_ruler.go b/pkg/services/ngalert/api/api_ruler.go index ffe8777d2a7..769c2974e52 100644 --- a/pkg/services/ngalert/api/api_ruler.go +++ b/pkg/services/ngalert/api/api_ruler.go @@ -163,7 +163,7 @@ func (srv RulerSrv) RouteGetNamespaceRulesConfig(c *contextmodel.ReqContext, nam for groupKey, rules := range ruleGroups { // nolint:staticcheck - result[namespaceTitle] = append(result[namespaceTitle], toGettableRuleGroupConfig(groupKey.RuleGroup, rules, namespace.ID, provenanceRecords)) + result[namespaceTitle] = append(result[namespaceTitle], toGettableRuleGroupConfig(groupKey.RuleGroup, rules, provenanceRecords)) } return response.JSON(http.StatusAccepted, result) @@ -193,7 +193,7 @@ func (srv RulerSrv) RouteGetRulesGroupConfig(c *contextmodel.ReqContext, namespa result := apimodels.RuleGroupConfigResponse{ // nolint:staticcheck - GettableRuleGroupConfig: toGettableRuleGroupConfig(ruleGroup, rules, namespace.ID, provenanceRecords), + GettableRuleGroupConfig: toGettableRuleGroupConfig(ruleGroup, rules, provenanceRecords), } return response.JSON(http.StatusAccepted, result) } @@ -243,7 +243,7 @@ func (srv RulerSrv) RouteGetRulesConfig(c *contextmodel.ReqContext) response.Res } namespace := folder.Title // nolint:staticcheck - result[namespace] = append(result[namespace], toGettableRuleGroupConfig(groupKey.RuleGroup, rules, folder.ID, provenanceRecords)) + result[namespace] = append(result[namespace], toGettableRuleGroupConfig(groupKey.RuleGroup, rules, provenanceRecords)) } return response.JSON(http.StatusOK, result) } @@ -405,7 +405,7 @@ func changesToResponse(finalChanges *store.GroupDelta) response.Response { return response.JSON(http.StatusAccepted, body) } -func toGettableRuleGroupConfig(groupName string, rules ngmodels.RulesGroup, namespaceID int64, provenanceRecords map[string]ngmodels.Provenance) apimodels.GettableRuleGroupConfig { +func toGettableRuleGroupConfig(groupName string, rules ngmodels.RulesGroup, provenanceRecords map[string]ngmodels.Provenance) apimodels.GettableRuleGroupConfig { rules.SortByGroupIndex() ruleNodes := make([]apimodels.GettableExtendedRuleNode, 0, len(rules)) var interval time.Duration @@ -413,7 +413,7 @@ func toGettableRuleGroupConfig(groupName string, rules ngmodels.RulesGroup, name interval = time.Duration(rules[0].IntervalSeconds) * time.Second } for _, r := range rules { - ruleNodes = append(ruleNodes, toGettableExtendedRuleNode(*r, namespaceID, provenanceRecords)) + ruleNodes = append(ruleNodes, toGettableExtendedRuleNode(*r, provenanceRecords)) } return apimodels.GettableRuleGroupConfig{ Name: groupName, @@ -422,7 +422,7 @@ func toGettableRuleGroupConfig(groupName string, rules ngmodels.RulesGroup, name } } -func toGettableExtendedRuleNode(r ngmodels.AlertRule, namespaceID int64, provenanceRecords map[string]ngmodels.Provenance) apimodels.GettableExtendedRuleNode { +func toGettableExtendedRuleNode(r ngmodels.AlertRule, provenanceRecords map[string]ngmodels.Provenance) apimodels.GettableExtendedRuleNode { provenance := ngmodels.ProvenanceNone if prov, exists := provenanceRecords[r.ResourceID()]; exists { provenance = prov @@ -439,7 +439,6 @@ func toGettableExtendedRuleNode(r ngmodels.AlertRule, namespaceID int64, provena Version: r.Version, UID: r.UID, NamespaceUID: r.NamespaceUID, - NamespaceID: namespaceID, RuleGroup: r.RuleGroup, NoDataState: apimodels.NoDataState(r.NoDataState), ExecErrState: apimodels.ExecutionErrorState(r.ExecErrState), diff --git a/pkg/services/ngalert/api/tooling/api.json b/pkg/services/ngalert/api/tooling/api.json index 0af43588c6f..1242b4f33cb 100644 --- a/pkg/services/ngalert/api/tooling/api.json +++ b/pkg/services/ngalert/api/tooling/api.json @@ -1431,10 +1431,6 @@ "is_paused": { "type": "boolean" }, - "namespace_id": { - "format": "int64", - "type": "integer" - }, "namespace_uid": { "type": "string" }, @@ -4472,7 +4468,6 @@ "type": "array" }, "integration": { - "description": "Integration integration", "properties": { "lastNotifyAttempt": { "description": "A timestamp indicating the last attempt to deliver a notification regardless of the outcome.\nFormat: date-time", diff --git a/pkg/services/ngalert/api/tooling/definitions/cortex-ruler.go b/pkg/services/ngalert/api/tooling/definitions/cortex-ruler.go index a43c94b2c7c..5db0b821f49 100644 --- a/pkg/services/ngalert/api/tooling/definitions/cortex-ruler.go +++ b/pkg/services/ngalert/api/tooling/definitions/cortex-ruler.go @@ -426,7 +426,6 @@ type GettableGrafanaRule struct { Version int64 `json:"version" yaml:"version"` UID string `json:"uid" yaml:"uid"` NamespaceUID string `json:"namespace_uid" yaml:"namespace_uid"` - NamespaceID int64 `json:"namespace_id" yaml:"namespace_id"` RuleGroup string `json:"rule_group" yaml:"rule_group"` NoDataState NoDataState `json:"no_data_state" yaml:"no_data_state"` ExecErrState ExecutionErrorState `json:"exec_err_state" yaml:"exec_err_state"` diff --git a/pkg/services/ngalert/api/tooling/post.json b/pkg/services/ngalert/api/tooling/post.json index f9ddbda7d0f..fd465f7d7eb 100644 --- a/pkg/services/ngalert/api/tooling/post.json +++ b/pkg/services/ngalert/api/tooling/post.json @@ -1431,10 +1431,6 @@ "is_paused": { "type": "boolean" }, - "namespace_id": { - "format": "int64", - "type": "integer" - }, "namespace_uid": { "type": "string" }, @@ -3988,6 +3984,7 @@ "type": "object" }, "URL": { + "description": "The general form represented is:\n\n[scheme:][//[userinfo@]host][/]path[?query][#fragment]\n\nURLs that do not start with a slash after the scheme are interpreted as:\n\nscheme:opaque[?query][#fragment]\n\nNote that the Path field is stored in decoded form: /%47%6f%2f becomes /Go/.\nA consequence is that it is impossible to tell which slashes in the Path were\nslashes in the raw URL and which were %2f. This distinction is rarely important,\nbut when it is, the code should use the EscapedPath method, which preserves\nthe original encoding of Path.\n\nThe RawPath field is an optional field which is only set when the default\nencoding of Path is different from the escaped path. See the EscapedPath method\nfor more details.\n\nURL's String method uses the EscapedPath method to obtain the path.", "properties": { "ForceQuery": { "type": "boolean" @@ -4023,7 +4020,7 @@ "$ref": "#/definitions/Userinfo" } }, - "title": "URL is a custom URL type that allows validation at configuration load time.", + "title": "A URL represents a parsed URL (technically, a URI reference).", "type": "object" }, "UpdateRuleGroupResponse": { @@ -4412,7 +4409,6 @@ "type": "object" }, "gettableAlerts": { - "description": "GettableAlerts gettable alerts", "items": { "$ref": "#/definitions/gettableAlert" }, @@ -4655,7 +4651,6 @@ "type": "object" }, "receiver": { - "description": "Receiver receiver", "properties": { "active": { "description": "active", diff --git a/pkg/services/ngalert/api/tooling/spec.json b/pkg/services/ngalert/api/tooling/spec.json index b4e2499a8e7..f295e6a3397 100644 --- a/pkg/services/ngalert/api/tooling/spec.json +++ b/pkg/services/ngalert/api/tooling/spec.json @@ -4624,10 +4624,6 @@ "is_paused": { "type": "boolean" }, - "namespace_id": { - "type": "integer", - "format": "int64" - }, "namespace_uid": { "type": "string" }, @@ -7181,8 +7177,9 @@ } }, "URL": { + "description": "The general form represented is:\n\n[scheme:][//[userinfo@]host][/]path[?query][#fragment]\n\nURLs that do not start with a slash after the scheme are interpreted as:\n\nscheme:opaque[?query][#fragment]\n\nNote that the Path field is stored in decoded form: /%47%6f%2f becomes /Go/.\nA consequence is that it is impossible to tell which slashes in the Path were\nslashes in the raw URL and which were %2f. This distinction is rarely important,\nbut when it is, the code should use the EscapedPath method, which preserves\nthe original encoding of Path.\n\nThe RawPath field is an optional field which is only set when the default\nencoding of Path is different from the escaped path. See the EscapedPath method\nfor more details.\n\nURL's String method uses the EscapedPath method to obtain the path.", "type": "object", - "title": "URL is a custom URL type that allows validation at configuration load time.", + "title": "A URL represents a parsed URL (technically, a URI reference).", "properties": { "ForceQuery": { "type": "boolean" @@ -7608,7 +7605,6 @@ "$ref": "#/definitions/gettableAlert" }, "gettableAlerts": { - "description": "GettableAlerts gettable alerts", "type": "array", "items": { "$ref": "#/definitions/gettableAlert" @@ -7856,7 +7852,6 @@ "$ref": "#/definitions/postableSilence" }, "receiver": { - "description": "Receiver receiver", "type": "object", "required": [ "active", diff --git a/pkg/services/ngalert/store/alert_rule.go b/pkg/services/ngalert/store/alert_rule.go index 4cdb8dda1df..49161802f28 100644 --- a/pkg/services/ngalert/store/alert_rule.go +++ b/pkg/services/ngalert/store/alert_rule.go @@ -460,7 +460,6 @@ func (st DBstore) GetUserVisibleNamespaces(ctx context.Context, orgID int64, use continue } namespaceMap[hit.UID] = &folder.Folder{ - ID: hit.ID, // nolint:staticcheck UID: hit.UID, Title: hit.Title, } diff --git a/pkg/tests/api/alerting/api_alertmanager_test.go b/pkg/tests/api/alerting/api_alertmanager_test.go index 19af3abe006..2a8e48b2dc6 100644 --- a/pkg/tests/api/alerting/api_alertmanager_test.go +++ b/pkg/tests/api/alerting/api_alertmanager_test.go @@ -772,7 +772,6 @@ func TestIntegrationDeleteFolderWithRules(t *testing.T) { "version": 1, "uid": "", "namespace_uid": %q, - "namespace_id": 1, "rule_group": "arulegroup", "no_data_state": "NoData", "exec_err_state": "Alerting" @@ -1250,7 +1249,6 @@ func TestIntegrationAlertRuleCRUD(t *testing.T) { "version":1, "uid":"uid", "namespace_uid":"nsuid", - "namespace_id":1, "rule_group":"arulegroup", "no_data_state":"NoData", "exec_err_state":"Alerting" @@ -1287,7 +1285,6 @@ func TestIntegrationAlertRuleCRUD(t *testing.T) { "version":1, "uid":"uid", "namespace_uid":"nsuid", - "namespace_id":1, "rule_group":"arulegroup", "no_data_state":"Alerting", "exec_err_state":"Alerting" @@ -1596,7 +1593,6 @@ func TestIntegrationAlertRuleCRUD(t *testing.T) { "version":2, "uid":"uid", "namespace_uid":"nsuid", - "namespace_id":1, "rule_group":"arulegroup", "no_data_state":"Alerting", "exec_err_state":"Alerting" @@ -1706,7 +1702,6 @@ func TestIntegrationAlertRuleCRUD(t *testing.T) { "version":3, "uid":"uid", "namespace_uid":"nsuid", - "namespace_id":1, "rule_group":"arulegroup", "no_data_state":"Alerting", "exec_err_state":"Alerting" @@ -1795,7 +1790,6 @@ func TestIntegrationAlertRuleCRUD(t *testing.T) { "version":3, "uid":"uid", "namespace_uid":"nsuid", - "namespace_id":1, "rule_group":"arulegroup", "no_data_state":"Alerting", "exec_err_state":"Alerting" @@ -2102,7 +2096,6 @@ func TestIntegrationQuota(t *testing.T) { "version":2, "uid":"uid", "namespace_uid":"nsuid", - "namespace_id":1, "rule_group":"arulegroup", "no_data_state":"NoData", "exec_err_state":"Alerting" diff --git a/pkg/tests/api/alerting/api_ruler_test.go b/pkg/tests/api/alerting/api_ruler_test.go index e57eb219211..aa73861b131 100644 --- a/pkg/tests/api/alerting/api_ruler_test.go +++ b/pkg/tests/api/alerting/api_ruler_test.go @@ -136,11 +136,9 @@ func TestIntegrationAlertRulePermissions(t *testing.T) { for _, rule := range allRules["folder1"][0].Rules { assert.Equal(t, "folder1", rule.GrafanaManagedAlert.NamespaceUID) - assert.Equal(t, int64(1), rule.GrafanaManagedAlert.NamespaceID) } for _, rule := range allRules["folder2"][0].Rules { assert.Equal(t, "folder2", rule.GrafanaManagedAlert.NamespaceUID) - assert.Equal(t, int64(2), rule.GrafanaManagedAlert.NamespaceID) } }) @@ -664,7 +662,6 @@ func TestIntegrationRulerRulesFilterByDashboard(t *testing.T) { "version": 1, "uid": "uid", "namespace_uid": "nsuid", - "namespace_id": 1, "rule_group": "anotherrulegroup", "no_data_state": "NoData", "exec_err_state": "Alerting" @@ -698,7 +695,6 @@ func TestIntegrationRulerRulesFilterByDashboard(t *testing.T) { "version": 1, "uid": "uid", "namespace_uid": "nsuid", - "namespace_id": 1, "rule_group": "anotherrulegroup", "no_data_state": "Alerting", "exec_err_state": "Alerting" @@ -744,7 +740,6 @@ func TestIntegrationRulerRulesFilterByDashboard(t *testing.T) { "version": 1, "uid": "uid", "namespace_uid": "nsuid", - "namespace_id": 1, "rule_group": "anotherrulegroup", "no_data_state": "NoData", "exec_err_state": "Alerting" diff --git a/pkg/tests/api/alerting/test-data/rulegroup-1-get.json b/pkg/tests/api/alerting/test-data/rulegroup-1-get.json index 9c3ad4dd979..27474baf8e3 100644 --- a/pkg/tests/api/alerting/test-data/rulegroup-1-get.json +++ b/pkg/tests/api/alerting/test-data/rulegroup-1-get.json @@ -38,7 +38,6 @@ "version": 1, "uid": "", "namespace_uid": "", - "namespace_id": 0, "rule_group": "Group1", "no_data_state": "NoData", "exec_err_state": "Alerting", @@ -81,7 +80,6 @@ "version": 1, "uid": "", "namespace_uid": "", - "namespace_id": 0, "rule_group": "Group1", "no_data_state": "NoData", "exec_err_state": "Alerting", diff --git a/pkg/tests/api/alerting/test-data/rulegroup-2-get.json b/pkg/tests/api/alerting/test-data/rulegroup-2-get.json index 6986c078e4e..dc29a8b2bd2 100644 --- a/pkg/tests/api/alerting/test-data/rulegroup-2-get.json +++ b/pkg/tests/api/alerting/test-data/rulegroup-2-get.json @@ -38,7 +38,6 @@ "version": 1, "uid": "", "namespace_uid": "", - "namespace_id": 0, "rule_group": "Group2", "no_data_state": "NoData", "exec_err_state": "Error", diff --git a/public/api-merged.json b/public/api-merged.json index f0090d41dca..b8f0e72300b 100644 --- a/public/api-merged.json +++ b/public/api-merged.json @@ -14733,10 +14733,6 @@ "is_paused": { "type": "boolean" }, - "namespace_id": { - "type": "integer", - "format": "int64" - }, "namespace_uid": { "type": "string" }, @@ -20962,7 +20958,6 @@ } }, "integration": { - "description": "Integration integration", "type": "object", "required": [ "name", diff --git a/public/app/features/alerting/unified/RuleEditorExisting.test.tsx b/public/app/features/alerting/unified/RuleEditorExisting.test.tsx index a3ecbbfcb6f..f72c42e157d 100644 --- a/public/app/features/alerting/unified/RuleEditorExisting.test.tsx +++ b/public/app/features/alerting/unified/RuleEditorExisting.test.tsx @@ -145,7 +145,6 @@ describe('RuleEditor grafana managed rules', () => { grafana_alert: { uid, namespace_uid: 'abcd', - namespace_id: 1, condition: 'B', data: getDefaultQueries(), exec_err_state: GrafanaAlertStateDecision.Error, diff --git a/public/app/features/alerting/unified/components/export/GrafanaModifyExport.test.tsx b/public/app/features/alerting/unified/components/export/GrafanaModifyExport.test.tsx index 0d01ea8868d..3e6b4069346 100644 --- a/public/app/features/alerting/unified/components/export/GrafanaModifyExport.test.tsx +++ b/public/app/features/alerting/unified/components/export/GrafanaModifyExport.test.tsx @@ -76,7 +76,6 @@ describe('GrafanaModifyExport', () => { uid: 'test-rule-uid', title: 'cpu-usage', namespace_uid: 'folder-test-uid', - namespace_id: 1, data: [ { refId: 'A', diff --git a/public/app/features/alerting/unified/mocks.ts b/public/app/features/alerting/unified/mocks.ts index 5e787d74b5e..1c6f623090f 100644 --- a/public/app/features/alerting/unified/mocks.ts +++ b/public/app/features/alerting/unified/mocks.ts @@ -114,7 +114,6 @@ export const mockRulerGrafanaRule = ( uid: '123', title: 'myalert', namespace_uid: '123', - namespace_id: 1, condition: 'A', no_data_state: GrafanaAlertStateDecision.Alerting, exec_err_state: GrafanaAlertStateDecision.Alerting, @@ -212,7 +211,6 @@ export const mockGrafanaRulerRule = (partial: Partial = { uid: '', title: 'my rule', namespace_uid: 'NAMESPACE_UID', - namespace_id: 0, condition: '', no_data_state: GrafanaAlertStateDecision.NoData, exec_err_state: GrafanaAlertStateDecision.Error, diff --git a/public/app/features/alerting/unified/utils/query.test.ts b/public/app/features/alerting/unified/utils/query.test.ts index 21191b71f88..6632f291f6c 100644 --- a/public/app/features/alerting/unified/utils/query.test.ts +++ b/public/app/features/alerting/unified/utils/query.test.ts @@ -88,7 +88,6 @@ describe('alertRuleToQueries', () => { const grafanaAlert = { condition: 'B', exec_err_state: GrafanaAlertStateDecision.Alerting, - namespace_id: 11, namespace_uid: 'namespaceuid123', no_data_state: GrafanaAlertStateDecision.NoData, title: 'Test alert', diff --git a/public/app/features/alerting/unified/utils/rule-id.test.ts b/public/app/features/alerting/unified/utils/rule-id.test.ts index d862d55475b..508199de2a2 100644 --- a/public/app/features/alerting/unified/utils/rule-id.test.ts +++ b/public/app/features/alerting/unified/utils/rule-id.test.ts @@ -46,7 +46,6 @@ describe('hashRulerRule', () => { const grafanaAlertDefinition: GrafanaRuleDefinition = { uid: RULE_UID, namespace_uid: 'namespace', - namespace_id: 0, title: 'my rule', condition: '', data: [], diff --git a/public/app/features/browse-dashboards/fixtures/alertRules.fixture.ts b/public/app/features/browse-dashboards/fixtures/alertRules.fixture.ts index f3d9d146cbe..ab84c47a59f 100644 --- a/public/app/features/browse-dashboards/fixtures/alertRules.fixture.ts +++ b/public/app/features/browse-dashboards/fixtures/alertRules.fixture.ts @@ -44,7 +44,6 @@ export function getRulerRulesResponse(folderName: string, folderUid: string, see ], uid: random.guid(), namespace_uid: folderUid, - namespace_id: 0, no_data_state: GrafanaAlertStateDecision.NoData, exec_err_state: GrafanaAlertStateDecision.Error, is_paused: false, diff --git a/public/app/types/unified-alerting-dto.ts b/public/app/types/unified-alerting-dto.ts index 16d48d0e1b4..fede7ab2d9c 100644 --- a/public/app/types/unified-alerting-dto.ts +++ b/public/app/types/unified-alerting-dto.ts @@ -210,7 +210,6 @@ export interface GrafanaRuleDefinition extends PostableGrafanaRuleDefinition { id?: string; uid: string; namespace_uid: string; - namespace_id: number; provenance?: string; } diff --git a/public/openapi3.json b/public/openapi3.json index ea9d6eeab0a..f8d3e443373 100644 --- a/public/openapi3.json +++ b/public/openapi3.json @@ -5625,10 +5625,6 @@ "is_paused": { "type": "boolean" }, - "namespace_id": { - "format": "int64", - "type": "integer" - }, "namespace_uid": { "type": "string" }, @@ -11853,7 +11849,6 @@ "type": "array" }, "integration": { - "description": "Integration integration", "properties": { "lastNotifyAttempt": { "description": "A timestamp indicating the last attempt to deliver a notification regardless of the outcome.\nFormat: date-time",