fix: fill empty metrics data with zeros
Signed-off-by: huanggze <loganhuang@yunify.com>
This commit is contained in:
@@ -13,6 +13,10 @@ limitations under the License.
|
|||||||
|
|
||||||
package metrics
|
package metrics
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ResultTypeVector = "vector"
|
ResultTypeVector = "vector"
|
||||||
ResultTypeMatrix = "matrix"
|
ResultTypeMatrix = "matrix"
|
||||||
@@ -731,3 +735,11 @@ var RulePromQLTmplMap = MetricMap{
|
|||||||
"prometheus_up_sum": `prometheus:up:sum`,
|
"prometheus_up_sum": `prometheus:up:sum`,
|
||||||
"prometheus_tsdb_head_samples_appended_rate": `prometheus:prometheus_tsdb_head_samples_appended:sum_rate`,
|
"prometheus_tsdb_head_samples_appended_rate": `prometheus:prometheus_tsdb_head_samples_appended:sum_rate`,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
for metric, promql := range RulePromQLTmplMap {
|
||||||
|
|
||||||
|
// Use absent() to fill missing data with zero
|
||||||
|
RulePromQLTmplMap[metric] = fmt.Sprintf("%s or absent(%s)-1", promql, promql)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user