Documentation ¶
Overview ¶
Package ddprom offers the contract of Datadog tags and metrics storage in Prometheus, as well as special labels handling. In this context, a "tag" is always a Datadog tag (there are no tags in Prometheus) and a "label" is always a Prometheus label, as there are no labels in Datadog.
Index ¶
- Variables
- func AllHostTagsPrompbLabel(in []string) prompb.Label
- func FromAllHostTagsLabelValue(value string) []string
- func IsInternalLabel(name string) bool
- func IsInternalMetricName(name string) bool
- func IsUnnamedTagLabelName(name string) bool
- func MakeInternalLabelName(label string) string
- func MakeInternalMetricName(name string) string
- func MetricToProm(name string) string
- func UnescapeLabelName(val string) string
- type Labels
- type Tag
Constants ¶
This section is empty.
Variables ¶
var ( DDTypeLabel = MakeInternalLabelName("dd_type") HostLabelName = MakeInternalLabelName("host") AllHostTagsLabelName = MakeInternalLabelName("all_host_tags") HostTagsMetricName = MakeInternalMetricName("hosttags") )
Functions ¶
func AllHostTagsPrompbLabel ¶
AllHostTagsPrompbLabel just creates an AllHostTags prompb.Label value in the format that FromAllHostTagsLabelValue method understands It lowercases the input and replaces invalid characters by underscores before storing them, but it doesn't do any other kind of assumption on the underlying data.
func FromAllHostTagsLabelValue ¶
FromAllHostTagsLabelValue parses the value of the AllHostTagsLabel returning the tags originally stored in it.
func IsInternalLabel ¶
func IsInternalMetricName ¶
IsInternalMetricName returns true for metric names created using MakeInternalMetricName
func IsUnnamedTagLabelName ¶
IsUnnamedTagLabelName returns true if label name corresponds to an unnamed tag
func MakeInternalLabelName ¶
MakeInternalLabelName transforms a string into an internal label name that will not collide with customer-defined labels.
func MakeInternalMetricName ¶
MakeInternalMetricName transforms a string into an internal metric name that will not collide with customer-defined metrics.
func MetricToProm ¶
MetricToProm translates DataDog metric names into valid Prometheus metrics, previously removing any invalid for DataDog characters.
func UnescapeLabelName ¶
UnescapeLabelName provides the original (except for invalid chars) name of the tag stored in a Prometheus label name.
Types ¶
type Labels ¶
type Labels map[string]*label
Labels represents a set of prometheus labels Build one of these using make(Labels), add tags to it using the methods.
func (Labels) LabelAdapters ¶
func (ls Labels) LabelAdapters() []mimirpb.LabelAdapter
func (Labels) PrompbLabels ¶
func (Labels) SetTagIfNotPresent ¶
SetTagIfNotPresent adds a tag with desired name and value if there's no tag with that name present already This method accepts user-friendly unescaped name and value.
type Tag ¶
type Tag struct {
// contains filtered or unexported fields
}
Tag represents a Datadog Tag and it's used to avoid splitting the tag to understand its underlying nature again and again.
func ExtractMetricTags ¶
ExtractMetricTags extracts all the tags stored in a Prometheus model.Metric
func ExtractTagsFromLabel ¶
ExtractTagsFromLabel extracts the tags that a label provides This method assumes that the label provides is not an internal one, i.e., IsInternalLabel(name) == false
func NewTag ¶
NewTag creates a new Tag model from a single Tag string, it provides access to information like the tag name and whether it's unnamed or not
func NewTagFromKeyValue ¶
NewTagFromKeyValue builds a tag from a know key:value pair
func (Tag) IsUnnamed ¶
IsUnnamed returns true if the tag is unnamed, i.e., when it doesn't have any colons, i.e., it is not a `key:value` tag
func (Tag) Key ¶
Key refers to the entire tag identifier when tag doesn't have any colon, when tag has a colon, the key is the part until the first colon, like `key:value`
func (Tag) LabelName ¶
LabelName provides the prometheus label name for this tag It calculates the value on the fly and doesn't cache it, so try to avoid calling it multiple times when possible.
func (Tag) LabelValue ¶
LabelValue provides the prometheus label value for this tag, This doesn't include the harness for multi-value encoding within a single label. It calculates the value on the fly and doesn't cache it, so try to avoid calling it multiple times when possible.
func (Tag) LabelValueForQuery ¶
LabelValueForQuery is like LabelValue but it also allows the wildcard character