mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-21 17:21:09 +01:00
feat: added metric service
This commit is contained in:
@@ -157,4 +157,24 @@ func CreateIndexesV2() {
|
||||
Options: (&options.IndexOptions{}).SetExpireAfterSeconds(60 * 60 * 24),
|
||||
},
|
||||
})
|
||||
|
||||
// metrics
|
||||
mongo.GetMongoCol(service.GetCollectionNameByInstance(models.MetricV2{})).MustCreateIndexes([]mongo2.IndexModel{
|
||||
{
|
||||
Keys: bson.D{
|
||||
{"created_ts", -1},
|
||||
},
|
||||
Options: (&options.IndexOptions{}).SetExpireAfterSeconds(60 * 60 * 24 * 30),
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{"node_id", 1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{"type", 1},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
23
core/models/models/metric_v2.go
Normal file
23
core/models/models/metric_v2.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package models
|
||||
|
||||
import "go.mongodb.org/mongo-driver/bson/primitive"
|
||||
|
||||
type MetricV2 struct {
|
||||
any `collection:"metrics"`
|
||||
BaseModelV2[MetricV2] `bson:",inline"`
|
||||
Type string `json:"type" bson:"type"`
|
||||
NodeId primitive.ObjectID `json:"node_id" bson:"node_id"`
|
||||
CpuUsagePercent float32 `json:"cpu_usage_percent" bson:"cpu_usage_percent"`
|
||||
TotalMemory uint64 `json:"total_memory" bson:"total_memory"`
|
||||
AvailableMemory uint64 `json:"available_memory" bson:"available_memory"`
|
||||
UsedMemory uint64 `json:"used_memory" bson:"used_memory"`
|
||||
UsedMemoryPercent float32 `json:"used_memory_percent" bson:"used_memory_percent"`
|
||||
TotalDisk uint64 `json:"total_disk" bson:"total_disk"`
|
||||
AvailableDisk uint64 `json:"available_disk" bson:"available_disk"`
|
||||
UsedDisk uint64 `json:"used_disk" bson:"used_disk"`
|
||||
UsedDiskPercent float32 `json:"used_disk_percent" bson:"used_disk_percent"`
|
||||
DiskReadBytesRate float32 `json:"disk_read_bytes_rate" bson:"disk_read_bytes_rate"`
|
||||
DiskWriteBytesRate float32 `json:"disk_write_bytes_rate" bson:"disk_write_bytes_rate"`
|
||||
NetworkBytesSentRate float32 `json:"network_bytes_sent_rate" bson:"network_bytes_sent_rate"`
|
||||
NetworkBytesRecvRate float32 `json:"network_bytes_recv_rate" bson:"network_bytes_recv_rate"`
|
||||
}
|
||||
Reference in New Issue
Block a user