mirror of
https://github.com/grafana/tempo.git
synced 2025-03-14 03:06:42 +00:00
* add host info processor implementation Signed-off-by: Robbie Lankford <robert.lankford@grafana.com> * fix lint * remove gauge custom expiration logic * make generate-manifest * add config validation; remove stale duration crud * refactor and clean up --------- Signed-off-by: Robbie Lankford <robert.lankford@grafana.com>
38 lines
947 B
Go
38 lines
947 B
Go
package hostinfo
|
|
|
|
import (
|
|
"errors"
|
|
"flag"
|
|
|
|
"github.com/prometheus/common/model"
|
|
)
|
|
|
|
const (
|
|
defaultHostInfoMetric = "traces_host_info"
|
|
)
|
|
|
|
type Config struct {
|
|
// HostIdentifiers defines the list of resource attributes used to derive
|
|
// a unique `grafana.host.id` value. In most cases, this should be [ "host.id" ]
|
|
HostIdentifiers []string `yaml:"host_identifiers"`
|
|
// MetricName defines the name of the metric that will be generated
|
|
MetricName string `yaml:"metric_name"`
|
|
}
|
|
|
|
func (cfg *Config) RegisterFlagsAndApplyDefaults(string, *flag.FlagSet) {
|
|
cfg.HostIdentifiers = []string{"k8s.node.name", "host.id"}
|
|
cfg.MetricName = defaultHostInfoMetric
|
|
}
|
|
|
|
func (cfg *Config) Validate() error {
|
|
if len(cfg.HostIdentifiers) == 0 {
|
|
return errors.New("at least one value must be provided in host_identifiers")
|
|
}
|
|
|
|
if !model.IsValidMetricName(model.LabelValue(cfg.MetricName)) {
|
|
return errors.New("metric_name is invalid")
|
|
}
|
|
|
|
return nil
|
|
}
|