Skip to content

Commit

Permalink
Add collectd information for collectd datapoints (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
swahba authored Sep 30, 2024
1 parent e51069e commit 38ce0be
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions logkey/logkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,6 @@ var (
ListenFrom = log.Key("listen_from")
// WavefrontLine is a direct line received from wavefront protocol
WavefrontLine = log.Key("wavefront_line")
// Collectd is a string indicating that incoming data is from collectd
Collectd = log.Key("collectd")
)
7 changes: 6 additions & 1 deletion protocol/collectd/collectd.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/signalfx/golib/v3/datapoint"
"github.com/signalfx/golib/v3/event"
"github.com/signalfx/ingest-protocols/logkey"
collectdformat "github.com/signalfx/ingest-protocols/protocol/collectd/format"
)

Expand Down Expand Up @@ -54,6 +55,10 @@ func NewDatapoint(point *JSONWriteFormat, index uint, defaultDimensions map[stri
metricType := metricTypeFromDsType(dstype)
metricName, usedDsName := getReasonableMetricName(point, index, dimensions)

meta := map[interface{}]interface{}{
logkey.Protocol: logkey.Collectd,
}

addIfNotNullOrEmpty(dimensions, "plugin", true, point.Plugin)

parseDimensionsOut(dimensions, point.PluginInstance, point.Host)
Expand All @@ -67,7 +72,7 @@ func NewDatapoint(point *JSONWriteFormat, index uint, defaultDimensions map[stri
} else {
value = datapoint.NewFloatValue(*val)
}
return datapoint.New(metricName, dimensions, value, metricType, timestamp)
return datapoint.NewWithMeta(metricName, dimensions, meta, value, metricType, timestamp)
}

func addIfNotNullOrEmpty(dimensions map[string]string, key string, cond bool, val *string) {
Expand Down

0 comments on commit 38ce0be

Please sign in to comment.