mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2025-04-19 03:05:55 +02:00
Add option to normalize units with cc-unit
This commit is contained in:
parent
992b19d354
commit
3b962cd0d6
@ -8,6 +8,7 @@ The CCMetric router sits in between the collectors and the sinks and can be used
|
|||||||
{
|
{
|
||||||
"num_cache_intervals" : 1,
|
"num_cache_intervals" : 1,
|
||||||
"interval_timestamp" : true,
|
"interval_timestamp" : true,
|
||||||
|
"normalize_units": true,
|
||||||
"add_tags" : [
|
"add_tags" : [
|
||||||
{
|
{
|
||||||
"key" : "cluster",
|
"key" : "cluster",
|
||||||
|
@ -12,6 +12,7 @@ import (
|
|||||||
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
||||||
agg "github.com/ClusterCockpit/cc-metric-collector/internal/metricAggregator"
|
agg "github.com/ClusterCockpit/cc-metric-collector/internal/metricAggregator"
|
||||||
mct "github.com/ClusterCockpit/cc-metric-collector/internal/multiChanTicker"
|
mct "github.com/ClusterCockpit/cc-metric-collector/internal/multiChanTicker"
|
||||||
|
units "github.com/ClusterCockpit/cc-units"
|
||||||
)
|
)
|
||||||
|
|
||||||
const ROUTER_MAX_FORWARD = 50
|
const ROUTER_MAX_FORWARD = 50
|
||||||
@ -35,6 +36,7 @@ type metricRouterConfig struct {
|
|||||||
IntervalStamp bool `json:"interval_timestamp"` // Update timestamp periodically by ticker each interval?
|
IntervalStamp bool `json:"interval_timestamp"` // Update timestamp periodically by ticker each interval?
|
||||||
NumCacheIntervals int `json:"num_cache_intervals"` // Number of intervals of cached metrics for evaluation
|
NumCacheIntervals int `json:"num_cache_intervals"` // Number of intervals of cached metrics for evaluation
|
||||||
MaxForward int `json:"max_forward"` // Number of maximal forwarded metrics at one select
|
MaxForward int `json:"max_forward"` // Number of maximal forwarded metrics at one select
|
||||||
|
NormalizeUnits bool `json:"normalize_units"` // Check unit meta flag and normalize it using cc-units
|
||||||
dropMetrics map[string]bool // Internal map for O(1) lookup
|
dropMetrics map[string]bool // Internal map for O(1) lookup
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,6 +255,14 @@ func (r *metricRouter) Start() {
|
|||||||
point.SetName(new)
|
point.SetName(new)
|
||||||
point.AddMeta("oldname", name)
|
point.AddMeta("oldname", name)
|
||||||
}
|
}
|
||||||
|
if r.config.NormalizeUnits {
|
||||||
|
if in_unit, ok := point.GetMeta("unit"); ok {
|
||||||
|
u := units.NewUnit(in_unit)
|
||||||
|
if u.Valid() {
|
||||||
|
point.AddMeta("unit", u.Short())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
r.DoAddTags(point)
|
r.DoAddTags(point)
|
||||||
r.DoDelTags(point)
|
r.DoDelTags(point)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user