@@ -115,6 +115,7 @@ const (
115115 paramPriority = "priority"
116116 paramCompat = "compat"
117117 paramYL , paramYH = "yl" , "yh" // Y scale range
118+ paramFull = "full"
118119
119120 Version1 = "1"
120121 Version2 = "2"
@@ -287,7 +288,9 @@ type (
287288 }
288289
289290 metricShortInfo struct {
290- Name string `json:"name"`
291+ Name string `json:"name"`
292+ MetricID int32 `json:"metric_id,omitempty"` // we set to 0 to remove from JSON
293+ Disable bool `json:"disable,omitempty"` // we set to "false" to remove from JSON
291294 }
292295
293296 dashboardShortInfo struct {
@@ -1185,18 +1188,30 @@ func (h *Handler) HandleStatic(w http.ResponseWriter, r *http.Request) {
11851188}
11861189
11871190func HandleGetMetricsList (h * httpRequestHandler ) {
1191+ full := h .FormValue (paramFull ) == "1"
1192+
11881193 resp := & GetMetricsListResp {
11891194 Metrics : []metricShortInfo {},
11901195 }
1191- for _ , m := range format .BuiltinMetrics {
1192- if ! h .showInvisible && m .Disable { // we have invisible builtin metrics
1196+ for _ , v := range format .BuiltinMetrics {
1197+ if ! h .showInvisible && v .Disable && ! full { // we have invisible builtin metrics
11931198 continue
11941199 }
1195- resp .Metrics = append (resp .Metrics , metricShortInfo {Name : m .Name })
1200+ info := metricShortInfo {Name : v .Name }
1201+ if full {
1202+ info .MetricID = v .MetricID
1203+ info .Disable = v .Disable
1204+ }
1205+ resp .Metrics = append (resp .Metrics , info )
11961206 }
1197- for _ , v := range h .metricsStorage .GetMetaMetricList (h .showInvisible ) {
1207+ for _ , v := range h .metricsStorage .GetMetaMetricList (h .showInvisible || full ) {
11981208 if h .accessInfo .CanViewMetric (* v ) {
1199- resp .Metrics = append (resp .Metrics , metricShortInfo {Name : v .Name })
1209+ info := metricShortInfo {Name : v .Name }
1210+ if full {
1211+ info .MetricID = v .MetricID
1212+ info .Disable = v .Disable
1213+ }
1214+ resp .Metrics = append (resp .Metrics , info )
12001215 }
12011216 }
12021217 sort .Slice (resp .Metrics , func (i int , j int ) bool { return resp .Metrics [i ].Name < resp .Metrics [j ].Name })
0 commit comments