Skip to content

Commit

Permalink
add logic for processing limits
Browse files Browse the repository at this point in the history
  • Loading branch information
lucian-ioan committed Nov 24, 2023
1 parent 38b7b5f commit d5344b0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion x-pack/metricbeat/module/awsfargate/task_stats/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type memoryStats struct {
TotalRss uint64
TotalRssP float64
Usage uint64
UsageP float64
// UsageP float64
//Raw stats from the cgroup subsystem
Stats map[string]uint64
//Windows-only memory stats
Expand Down
12 changes: 11 additions & 1 deletion x-pack/metricbeat/module/awsfargate/task_stats/task_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ type TaskMetadata struct {
DesiredStatus string `json:"DesiredStatus"`
KnownStatus string `json:"KnownStatus"`
Containers []*container `json:"Containers"`
Limits Limits `json:"Limits"`
}

// Limits is a struct that represents the memory and CPU limits from ${ECS_CONTAINER_METADATA_URI_V4}/task
type Limits struct {
CPU int64 `json:"CPU"`
Memory int64 `json:"Memory"`
}

// New creates a new instance of the MetricSet. New is responsible for unpacking
Expand Down Expand Up @@ -182,7 +189,7 @@ func getTask(taskResp *http.Response) (TaskMetadata, error) {
return taskOutput, nil
}

func getStatsList(taskStatsOutput map[string]types.StatsJSON, taskOutput TaskMetadata) []Stats {
func getStatsList(taskStatsOutput map[string]types.StatsJSON, taskOutput TaskMetadata, memoryLimit int64) []Stats {
containersInfo := map[string]container{}

taskInfo := TaskInfo{
Expand Down Expand Up @@ -214,6 +221,9 @@ func getStatsList(taskStatsOutput map[string]types.StatsJSON, taskOutput TaskMet
memoryStats: getMemoryStats(taskStats),
networkStats: getNetworkStats(taskStats),
blkioStats: getBlkioStats(taskStats.BlkioStats),
Limits: Limits{
Memory: memoryLimit,
},
}

formattedStats = append(formattedStats, statsPerContainer)
Expand Down

0 comments on commit d5344b0

Please sign in to comment.