@@ -72,14 +72,16 @@ local prometheus = grafonnet.query.prometheus;
72
72
* @param title The title of the timeseries panel.
73
73
* @param metric The metric to be observed.
74
74
* @param component The component to be measured (or excluded).
75
+ * Optional if `multi=true`, in which case it is an exclusion, otherwise required.
76
+ * @param multi (default `false`) If true, do a multi-component chart instead of single-component.
77
+ * The chart will have a legend table for each component.
75
78
*/
76
- componentResourcePanel(title, metric, component)::
79
+ componentResourcePanel(title, metric, component, multi, namespace )::
77
80
ts.new(title)
78
81
// show legend as a table with current, avg, max values
79
82
//legend_hideZero=true,
80
83
// legend_values is required for any of the above to work
81
84
//legend_values=true,
82
- //min=0,
83
85
+ ts.options.legend.withDisplayMode('table' )
84
86
+ ts.options.legend.withCalcs(['min' , 'mean' , 'max' ])
85
87
+ ts.queryOptions.withTargets([
@@ -94,11 +96,15 @@ local prometheus = grafonnet.query.prometheus;
94
96
||| ,
95
97
[
96
98
metric,
97
- self .onComponentLabel(component, cmp='!=' , group_left='container, label_component' ),
99
+ self .onComponentLabel(
100
+ component,
101
+ cmp=if multi then '!=' else '=' , group_left='container, label_component' ,
102
+ namespace=namespace,
103
+ ),
98
104
],
99
105
)
100
106
)
101
- + prometheus.withLegendFormat('{{ label_component }}' ),
107
+ + prometheus.withLegendFormat(if multi then '{{ label_component }}' else title ),
102
108
]),
103
109
104
110
/**
@@ -108,11 +114,16 @@ local prometheus = grafonnet.query.prometheus;
108
114
*
109
115
* @param name The name of the resource. Used to create the title.
110
116
* @param component The component to be measured (or excluded).
117
+ * Optional if `multi=true`, in which case it is an exclusion, otherwise required.
118
+ * @param multi (default `false`) If true, do a multi-component chart instead of single-component.
119
+ * The chart will have a legend table for each component.
111
120
*/
112
- memoryPanel(name, component)::
121
+ memoryPanel(name, component, multi=false, namespace='$hub' )::
113
122
self .componentResourcePanel(
114
123
std.format ('%s Memory (Working Set)' , [name]),
115
124
component=component,
125
+ multi=multi,
126
+ namespace=namespace,
116
127
metric=|||
117
128
# exclude name="" because the same container can be reported
118
129
# with both no name and `name=k8s_...`,
@@ -130,11 +141,16 @@ local prometheus = grafonnet.query.prometheus;
130
141
*
131
142
* @param name The name of the resource. Used to create the title.
132
143
* @param component The component to be measured (or excluded).
144
+ * Optional if `multi=true`, in which case it is an exclusion, otherwise required.
145
+ * @param multi (default `false`) If true, do a multi-component chart instead of single-component.
146
+ * The chart will have a legend table for each component.
133
147
*/
134
- cpuPanel(name, component)::
148
+ cpuPanel(name, component, multi=false, namespace='$hub' )::
135
149
self .componentResourcePanel(
136
150
std.format ('%s CPU' , [name]),
137
151
component=component,
152
+ multi=multi,
153
+ namespace=namespace,
138
154
metric=|||
139
155
# exclude name="" because the same container can be reported
140
156
# with both no name and `name=k8s_...`,
0 commit comments