Skip to content

Commit

Permalink
collectd receiver meta to dimension
Browse files Browse the repository at this point in the history
  • Loading branch information
mfyuce committed Jan 18, 2024
1 parent 2b89f5f commit 5e91126
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions receiver/collectdreceiver/collectd.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ import (
)

type collectDRecord struct {
Dsnames []*string `json:"dsnames"`
Dstypes []*string `json:"dstypes"`
Host *string `json:"host"`
Interval *float64 `json:"interval"`
Plugin *string `json:"plugin"`
PluginInstance *string `json:"plugin_instance"`
Time *float64 `json:"time"`
TypeS *string `json:"type"`
TypeInstance *string `json:"type_instance"`
Values []*json.Number `json:"values"`
Message *string `json:"message"`
Meta map[string]any `json:"meta"`
Severity *string `json:"severity"`
Dsnames []*string `json:"dsnames"`
Dstypes []*string `json:"dstypes"`
Host *string `json:"host"`
Interval *float64 `json:"interval"`
Plugin *string `json:"plugin"`
PluginInstance *string `json:"plugin_instance"`
Time *float64 `json:"time"`
TypeS *string `json:"type"`
TypeInstance *string `json:"type_instance"`
Values []*json.Number `json:"values"`
Message *string `json:"message"`
Meta map[string]string `json:"meta"`
Severity *string `json:"severity"`
}

type createMetricInfo struct {
Expand Down Expand Up @@ -69,7 +69,9 @@ func (cdr *collectDRecord) appendToMetrics(logger *zap.Logger, scopeMetrics pmet
for k, v := range defaultLabels {
labels[k] = v
}

for k, v := range cdr.Meta {
labels[k] = v
}
for i := range cdr.Dsnames {
if i < len(cdr.Dstypes) && i < len(cdr.Values) && cdr.Values[i] != nil {
dsType, dsName, val := cdr.Dstypes[i], cdr.Dsnames[i], cdr.Values[i]
Expand Down

0 comments on commit 5e91126

Please sign in to comment.