@ -1317,8 +1317,8 @@ func (api *API) serveFlags(_ *http.Request) apiFuncResult {
return apiFuncResult { api . flagsMap , nil , nil , nil }
}
// s tat holds the information about individual cardinality.
type s tat struct {
// TSDBS tat holds the information about individual cardinality.
type TSDBS tat struct {
Name string ` json:"name" `
Value uint64 ` json:"value" `
}
@ -1332,26 +1332,27 @@ type HeadStats struct {
MaxTime int64 ` json:"maxTime" `
}
// tsdb Status has information of cardinality statistics from postings.
type tsdb Status struct {
HeadStats HeadStats ` json:"headStats" `
SeriesCountByMetricName [ ] stat ` json:"seriesCountByMetricName" `
LabelValueCountByLabelName [ ] stat ` json:"labelValueCountByLabelName" `
MemoryInBytesByLabelName [ ] stat ` json:"memoryInBytesByLabelName" `
SeriesCountByLabelValuePair [ ] stat ` json:"seriesCountByLabelValuePair" `
// TSDB Status has information of cardinality statistics from postings.
type TSDB Status struct {
HeadStats HeadStats ` json:"headStats" `
SeriesCountByMetricName [ ] TSDBStat ` json:"seriesCountByMetricName" `
LabelValueCountByLabelName [ ] TSDBStat ` json:"labelValueCountByLabelName" `
MemoryInBytesByLabelName [ ] TSDBStat ` json:"memoryInBytesByLabelName" `
SeriesCountByLabelValuePair [ ] TSDBStat ` json:"seriesCountByLabelValuePair" `
}
func convertStats ( stats [ ] index . Stat ) [ ] stat {
result := make ( [ ] stat , 0 , len ( stats ) )
// TSDBStatsFromIndexStats converts a index.Stat slice to a TSDBStat slice.
func TSDBStatsFromIndexStats ( stats [ ] index . Stat ) [ ] TSDBStat {
result := make ( [ ] TSDBStat , 0 , len ( stats ) )
for _ , item := range stats {
item := s tat{ Name : item . Name , Value : item . Count }
item := TSDBS tat{ Name : item . Name , Value : item . Count }
result = append ( result , item )
}
return result
}
func ( api * API ) serveTSDBStatus ( * http . Request ) apiFuncResult {
s , err := api . db . Stats ( "__name__" )
s , err := api . db . Stats ( labels . MetricName )
if err != nil {
return apiFuncResult { nil , & apiError { errorInternal , err } , nil , nil }
}
@ -1369,7 +1370,7 @@ func (api *API) serveTSDBStatus(*http.Request) apiFuncResult {
}
}
}
return apiFuncResult { tsdb Status{
return apiFuncResult { TSDB Status{
HeadStats : HeadStats {
NumSeries : s . NumSeries ,
ChunkCount : chunkCount ,
@ -1377,10 +1378,10 @@ func (api *API) serveTSDBStatus(*http.Request) apiFuncResult {
MaxTime : s . MaxTime ,
NumLabelPairs : s . IndexPostingStats . NumLabelPairs ,
} ,
SeriesCountByMetricName : convert Stats( s . IndexPostingStats . CardinalityMetricsStats ) ,
LabelValueCountByLabelName : convert Stats( s . IndexPostingStats . CardinalityLabelStats ) ,
MemoryInBytesByLabelName : convert Stats( s . IndexPostingStats . LabelValueStats ) ,
SeriesCountByLabelValuePair : convert Stats( s . IndexPostingStats . LabelValuePairsStats ) ,
SeriesCountByMetricName : TSDBStatsFromIndex Stats( s . IndexPostingStats . CardinalityMetricsStats ) ,
LabelValueCountByLabelName : TSDBStatsFromIndex Stats( s . IndexPostingStats . CardinalityLabelStats ) ,
MemoryInBytesByLabelName : TSDBStatsFromIndex Stats( s . IndexPostingStats . LabelValueStats ) ,
SeriesCountByLabelValuePair : TSDBStatsFromIndex Stats( s . IndexPostingStats . LabelValuePairsStats ) ,
} , nil , nil , nil }
}