Skip to content

Commit

Permalink
support high cardinality tag extraction with + prefix, update conf ex…
Browse files Browse the repository at this point in the history
…ample
  • Loading branch information
xvello authored and hush-hush committed Sep 20, 2017
1 parent 0435d8a commit 907bf08
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
11 changes: 8 additions & 3 deletions pkg/collector/dist/datadog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,14 @@ metadata_collectors:
# log_level: info
# log_file: /var/log/datadog/agent.log

# Docker
# Docker tag extraction
#
# We can extract container label or environment variables
# as metric tags. If you prefix your tag name with +, it
# will only be added to high cardinality metrics (docker check)
#
# docker_labels_as_tags:
# - label_name
# label_name: tag_name
# high_cardinality_label: +tag_name
# docker_env_as_tags:
# - ENVVAR_NAME
# ENVVAR_NAME: tag_name
12 changes: 10 additions & 2 deletions pkg/tagger/collectors/docker_extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ func (c *DockerCollector) extractFromInspect(co types.ContainerJSON) ([]string,
if len(c.labelsAsTags) > 0 {
for label_name, label_value := range co.Config.Labels {
if tag_name, found := c.labelsAsTags[strings.ToLower(label_name)]; found {
low = append(low, fmt.Sprintf("%s:%s", tag_name, label_value))
if tag_name[0] == '+' {
high = append(high, fmt.Sprintf("%s:%s", tag_name[1:], label_value))
} else {
low = append(low, fmt.Sprintf("%s:%s", tag_name, label_value))
}
}
}
}
Expand All @@ -53,7 +57,11 @@ func (c *DockerCollector) extractFromInspect(co types.ContainerJSON) ([]string,
continue
}
if tag_name, found := c.envAsTags[strings.ToLower(parts[0])]; found {
low = append(low, fmt.Sprintf("%s:%s", tag_name, parts[1]))
if tag_name[0] == '+' {
high = append(high, fmt.Sprintf("%s:%s", tag_name[1:], parts[1]))
} else {
low = append(low, fmt.Sprintf("%s:%s", tag_name, parts[1]))
}
}
}
}
Expand Down

0 comments on commit 907bf08

Please sign in to comment.