lib/protoparser/datadogv2: take into account source_type_name field, since it contains useful value such as kubernetes, docker, system, etc.

This commit is contained in:
Aliaksandr Valialkin 2023-12-21 23:05:41 +02:00
parent b4ba8d0d76
commit 7575f5c501
No known key found for this signature in database
GPG Key ID: 52C003EE2BCDB9EB
4 changed files with 16 additions and 4 deletions

View File

@ -58,6 +58,12 @@ func insertRows(at *auth.Token, series []datadogv2.Series, extraLabels []prompbm
Value: rs.Name,
})
}
if ss.SourceTypeName != "" {
labels = append(labels, prompbmarshal.Label{
Name: "source_type_name",
Value: ss.SourceTypeName,
})
}
for _, tag := range ss.Tags {
name, value := datadogutils.SplitTag(tag)
if name == "host" {

View File

@ -59,6 +59,9 @@ func insertRows(series []datadogv2.Series, extraLabels []prompbmarshal.Label) er
}
ctx.AddLabel(name, value)
}
if ss.SourceTypeName != "" {
ctx.AddLabel("source_type_name", ss.SourceTypeName)
}
for j := range extraLabels {
label := &extraLabels[j]
ctx.AddLabel(label.Name, label.Value)

View File

@ -76,11 +76,10 @@ type Series struct {
Metric string `json:"metric"`
// Points points for the given metric
Points []Point `json:"points"`
Resources []Resource `json:"resources"`
Points []Point `json:"points"`
// Do not decode SourceTypeName, since it isn't used by VictoriaMetrics
// SourceTypeName string `json:"source_type_name"`
Resources []Resource `json:"resources"`
SourceTypeName string `json:"source_type_name"`
Tags []string
@ -106,6 +105,8 @@ func (s *Series) reset() {
}
s.Resources = resources[:0]
s.SourceTypeName = ""
tags := s.Tags
for i := range tags {
tags[i] = ""

View File

@ -50,6 +50,7 @@ func TestRequestUnmarshalJSONSuccess(t *testing.T) {
"type": "host"
}
],
"source_type_name": "kubernetes",
"tags": ["environment:test"]
}
]
@ -69,6 +70,7 @@ func TestRequestUnmarshalJSONSuccess(t *testing.T) {
Type: "host",
},
},
SourceTypeName: "kubernetes",
Tags: []string{
"environment:test",
},