Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT][API] Add GET /stats/cluster endpoint #86

Open
youen opened this issue Mar 31, 2024 · 0 comments
Open

[FEAT][API] Add GET /stats/cluster endpoint #86

youen opened this issue Mar 31, 2024 · 0 comments

Comments

@youen
Copy link
Member

youen commented Mar 31, 2024

Description

Add an endpoint to get insights into the cluster's usage.

Request

Method

GET

URL

/stats/cluster

Request Parameters

None

Result

Result parameters

Parameter Description Required example
n_active_tasks Number of active tasks No 10
available_concurrency Available concurrency No 20
utilization_rate_100 Utilization rate (out of 100) No 50
status_message A message describing the cluster's status No "Cluster is healthy"

Example Curl Request

Request

curl -X GET http://localhost:8080/stats/cluster

Curl Response

{
  "n_active_tasks": 10,
  "available_concurrency": 20,
  "utilization_rate_100": 50,
  "status_message": "Cluster is healthy"
}

Go server

Struct

type ClusterStats struct {
	NActiveTasks          int    `json:"n_active_tasks"`
	AvailableConcurrency  int    `json:"available_concurrency"`
	UtilizationRate100    int    `json:"utilization_rate_100"`
	StatusMessage        string `json:"status_message"`
}

Handler

func (h *Handler) getClusterStats(w http.ResponseWriter, r *http.Request) {
	stats := &ClusterStats{
		NActiveTasks:          h.cluster.NActiveTasks(),
		AvailableConcurrency:  h.cluster.AvailableConcurrency(),
		UtilizationRate100:    h.cluster.UtilizationRate100(),
		StatusMessage:        h.cluster.StatusMessage(),
	}

	respond(w, r, stats, http.StatusOK)
}

Links

Automated Issue Details

Dear visitor,

This issue has been automatically generated from the Octopize project avatar-python to make SIGO compatible. Please vote with a thumbs up or thumbs down to assess the quality of the automatic generation.

Best regards,
The SIGO Team

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant