fix(outputs.stackdriver): Allow for custom metric type prefix (#13168)
This commit is contained in:
parent
cf7ec5072d
commit
d12bcec8c4
|
|
@ -38,6 +38,10 @@ See the [CONFIGURATION.md][CONFIGURATION.md] for more details.
|
|||
## The namespace for the metric descriptor
|
||||
namespace = "telegraf"
|
||||
|
||||
## Metric Type Prefix
|
||||
## The DNS name used with the metric type as a prefix.
|
||||
# metric_type_prefix = "custom.googleapis.com"
|
||||
|
||||
## Custom resource type
|
||||
# resource_type = "generic_node"
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,10 @@
|
|||
## The namespace for the metric descriptor
|
||||
namespace = "telegraf"
|
||||
|
||||
## Metric Type Prefix
|
||||
## The DNS name used with the metric type as a prefix.
|
||||
# metric_type_prefix = "custom.googleapis.com"
|
||||
|
||||
## Custom resource type
|
||||
# resource_type = "generic_node"
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ type Stackdriver struct {
|
|||
Namespace string `toml:"namespace"`
|
||||
ResourceType string `toml:"resource_type"`
|
||||
ResourceLabels map[string]string `toml:"resource_labels"`
|
||||
MetricTypePrefix string `toml:"metric_type_prefix"`
|
||||
Log telegraf.Logger `toml:"-"`
|
||||
|
||||
client *monitoring.MetricClient
|
||||
|
|
@ -56,6 +57,14 @@ const (
|
|||
errStringPointsTooFrequent = "one or more points were written more frequently than the maximum sampling period configured for the metric"
|
||||
)
|
||||
|
||||
func (s *Stackdriver) Init() error {
|
||||
if s.MetricTypePrefix == "" {
|
||||
s.MetricTypePrefix = "custom.googleapis.com"
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (*Stackdriver) SampleConfig() string {
|
||||
return sampleConfig
|
||||
}
|
||||
|
|
@ -199,7 +208,7 @@ func (s *Stackdriver) sendBatch(batch []telegraf.Metric) error {
|
|||
// Prepare time series.
|
||||
timeSeries := &monitoringpb.TimeSeries{
|
||||
Metric: &metricpb.Metric{
|
||||
Type: path.Join("custom.googleapis.com", s.Namespace, m.Name(), f.Key),
|
||||
Type: path.Join(s.MetricTypePrefix, s.Namespace, m.Name(), f.Key),
|
||||
Labels: s.getStackdriverLabels(m.TagList()),
|
||||
},
|
||||
MetricKind: metricKind,
|
||||
|
|
|
|||
Loading…
Reference in New Issue