Skip to content

Commit

Permalink
migrate alerts with consumer "metrics" to be "infrastructure"
Browse files Browse the repository at this point in the history
  • Loading branch information
gmmorris committed Jun 26, 2020
1 parent 17fba6a commit 611061e
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions x-pack/plugins/alerts/server/saved_objects/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ function changeAlertingConsumer(
): SavedObjectMigrationFn<RawAlert, RawAlert> {
const consumerMigration = new Map<string, string>();
consumerMigration.set('alerting', 'alerts');
consumerMigration.set('metrics', 'infrastructure');

return encryptedSavedObjects.createMigration<RawAlert, RawAlert>(
function shouldBeMigrated(doc): doc is SavedObjectUnsanitizedDoc<RawAlert> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,14 @@ export default function createGetTests({ getService }: FtrProviderContext) {
expect(response.status).to.eql(200);
expect(response.body.consumer).to.equal('alerts');
});

it('7.9.0 migrates the `metrics` consumer to be the `infrastructure`', async () => {
const response = await supertest.get(
`${getUrlPrefix(``)}/api/alerts/alert/74f3e6d7-b7bb-477d-ac28-fdf248d5f2a4`
);

expect(response.status).to.eql(200);
expect(response.body.consumer).to.equal('infrastructure');
});
});
}
42 changes: 42 additions & 0 deletions x-pack/test/functional/es_archives/alerts/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,46 @@
"updated_at": "2020-06-17T15:35:39.839Z"
}
}
}

{
"type": "doc",
"value": {
"id": "alert:74f3e6d7-b7bb-477d-ac28-fdf248d5f2a4",
"index": ".kibana_1",
"source": {
"alert": {
"actions": [
],
"alertTypeId": "example.always-firing",
"apiKey": "XHcE1hfSJJCvu2oJrKErgbIbR7iu3XAX+c1kki8jESzWZNyBlD4+6yHhCDEx7rNLlP/Hvbut/V8N1BaQkaSpVpiNsW/UxshiCouqJ+cmQ9LbaYnca9eTTVUuPhbHwwsDjfYkakDPqW3gB8sonwZl6rpzZVacfp4=",
"apiKeyOwner": "elastic",
"consumer": "metrics",
"createdAt": "2020-06-17T15:35:38.497Z",
"createdBy": "elastic",
"enabled": true,
"muteAll": false,
"mutedInstanceIds": [
],
"name": "always-firing-alert",
"params": {
},
"schedule": {
"interval": "1m"
},
"scheduledTaskId": "329798f0-b0b0-11ea-9510-fdf248d5f2a4",
"tags": [
],
"throttle": null,
"updatedBy": "elastic"
},
"migrationVersion": {
"alert": "7.8.0"
},
"references": [
],
"type": "alert",
"updated_at": "2020-06-17T15:35:39.839Z"
}
}
}

0 comments on commit 611061e

Please sign in to comment.