Skip to content

Commit

Permalink
doc: generate metrics should include metrics
Browse files Browse the repository at this point in the history
Created by builtin plugins: Aggregator, Max, and MetricAgent

fix: resource_headroom templates should use `api` prefixed query
  • Loading branch information
cgrinds committed Oct 11, 2023
1 parent 13cf745 commit b5ea965
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 31 deletions.
4 changes: 2 additions & 2 deletions cmd/tools/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,13 @@ func flattenCounters(n *y3.Node, metrics *[]Metric, parents []string) {
flattenCounters(c, metrics, parents)
}
case "!!str":
*metrics = append(*metrics, newZapiMetric(n, parents))
*metrics = append(*metrics, newMetric(n, parents))
}
}

var sigilReplacer = strings.NewReplacer("^", "", "- ", "")

func newZapiMetric(n *y3.Node, parents []string) Metric {
func newMetric(n *y3.Node, parents []string) Metric {
// separate left and right and remove all sigils
text := n.Value
noSigils := sigilReplacer.Replace(text)
Expand Down
8 changes: 8 additions & 0 deletions cmd/tools/template/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,14 @@ func (m Metric) pathString() string {
return strings.Join(m.parents, "/") + "/" + m.left
}

func TestQueryPrefix(t *testing.T) {
visitTemplates(t, func(path string, model Model) {
if !strings.HasPrefix(model.Query, "api/") {
t.Errorf("query should be prefixed with api/, got=%s path=[%s]", model.Query, shortPath(path))
}
}, []string{"rest", "restperf"}...)
}

// Tests that keys and metrics are sorted in the following order:
// - double hats (alphabetically)
// - single hats (alphabetically)
Expand Down
2 changes: 1 addition & 1 deletion conf/restperf/9.12.0/resource_headroom_aggr.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: HeadroomAggr
query: /api/cluster/counter/tables/headroom_aggregate
query: api/cluster/counter/tables/headroom_aggregate
object: headroom_aggr

counters:
Expand Down
2 changes: 1 addition & 1 deletion conf/restperf/9.12.0/resource_headroom_cpu.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: HeadroomCPU
query: /api/cluster/counter/tables/headroom_cpu
query: api/cluster/counter/tables/headroom_cpu
object: headroom_cpu

counters:
Expand Down
Loading

0 comments on commit b5ea965

Please sign in to comment.