github.com/muhammadn/cortex@v1.9.1-0.20220510110439-46bb7000d03d/pkg/distributor/http_server.go (about) 1 package distributor 2 3 import ( 4 "net/http" 5 6 "github.com/cortexproject/cortex/pkg/util" 7 ) 8 9 // UserStats models ingestion statistics for one user. 10 type UserStats struct { 11 IngestionRate float64 `json:"ingestionRate"` 12 NumSeries uint64 `json:"numSeries"` 13 APIIngestionRate float64 `json:"APIIngestionRate"` 14 RuleIngestionRate float64 `json:"RuleIngestionRate"` 15 } 16 17 // UserStatsHandler handles user stats to the Distributor. 18 func (d *Distributor) UserStatsHandler(w http.ResponseWriter, r *http.Request) { 19 stats, err := d.UserStats(r.Context()) 20 if err != nil { 21 http.Error(w, err.Error(), http.StatusInternalServerError) 22 return 23 } 24 25 util.WriteJSONResponse(w, stats) 26 }