feat: added performance monitoring for database

This commit is contained in:
Marvin Zhang
2024-10-05 14:46:38 +08:00
parent 5f3ccfb84e
commit 3173c8fae8
4 changed files with 188 additions and 2 deletions

View File

@@ -202,4 +202,33 @@ func CreateIndexesV2() {
},
},
})
// databases
mongo.GetMongoCol(service.GetCollectionNameByInstance(models2.DatabaseV2{})).MustCreateIndexes([]mongo2.IndexModel{
{
Keys: bson.D{
{"data_source_id", 1},
},
},
})
// database metrics
mongo.GetMongoCol(service.GetCollectionNameByInstance(models2.DatabaseMetricV2{})).MustCreateIndexes([]mongo2.IndexModel{
{
Keys: bson.D{
{"created_ts", -1},
},
Options: (&options.IndexOptions{}).SetExpireAfterSeconds(60 * 60 * 24 * 30),
},
{
Keys: bson.D{
{"database_id", 1},
},
},
{
Keys: bson.D{
{"type", 1},
},
},
})
}