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
|
## The namespace for the metric descriptor
|
||||||
namespace = "telegraf"
|
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
|
## Custom resource type
|
||||||
# resource_type = "generic_node"
|
# resource_type = "generic_node"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,10 @@
|
||||||
## The namespace for the metric descriptor
|
## The namespace for the metric descriptor
|
||||||
namespace = "telegraf"
|
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
|
## Custom resource type
|
||||||
# resource_type = "generic_node"
|
# resource_type = "generic_node"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,11 +27,12 @@ var sampleConfig string
|
||||||
|
|
||||||
// Stackdriver is the Google Stackdriver config info.
|
// Stackdriver is the Google Stackdriver config info.
|
||||||
type Stackdriver struct {
|
type Stackdriver struct {
|
||||||
Project string `toml:"project"`
|
Project string `toml:"project"`
|
||||||
Namespace string `toml:"namespace"`
|
Namespace string `toml:"namespace"`
|
||||||
ResourceType string `toml:"resource_type"`
|
ResourceType string `toml:"resource_type"`
|
||||||
ResourceLabels map[string]string `toml:"resource_labels"`
|
ResourceLabels map[string]string `toml:"resource_labels"`
|
||||||
Log telegraf.Logger `toml:"-"`
|
MetricTypePrefix string `toml:"metric_type_prefix"`
|
||||||
|
Log telegraf.Logger `toml:"-"`
|
||||||
|
|
||||||
client *monitoring.MetricClient
|
client *monitoring.MetricClient
|
||||||
counterCache *counterCache
|
counterCache *counterCache
|
||||||
|
|
@ -56,6 +57,14 @@ const (
|
||||||
errStringPointsTooFrequent = "one or more points were written more frequently than the maximum sampling period configured for the metric"
|
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 {
|
func (*Stackdriver) SampleConfig() string {
|
||||||
return sampleConfig
|
return sampleConfig
|
||||||
}
|
}
|
||||||
|
|
@ -199,7 +208,7 @@ func (s *Stackdriver) sendBatch(batch []telegraf.Metric) error {
|
||||||
// Prepare time series.
|
// Prepare time series.
|
||||||
timeSeries := &monitoringpb.TimeSeries{
|
timeSeries := &monitoringpb.TimeSeries{
|
||||||
Metric: &metricpb.Metric{
|
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()),
|
Labels: s.getStackdriverLabels(m.TagList()),
|
||||||
},
|
},
|
||||||
MetricKind: metricKind,
|
MetricKind: metricKind,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue