ddprom

package
v0.0.0-...-7251252 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 7, 2023 License: AGPL-3.0 Imports: 8 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
var (
	DDTypeLabel          = MakeInternalLabelName("dd_type")
	HostLabelName        = MakeInternalLabelName("host")
	AllHostTagsLabelName = MakeInternalLabelName("all_host_tags")

	HostTagsMetricName = MakeInternalMetricName("hosttags")
)

Functions

func AllHostTagsPrompbLabel

func AllHostTagsPrompbLabel(in []string) prompb.Label

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

func FromAllHostTagsLabelValue(value string) []string

FromAllHostTagsLabelValue parses the value of the AllHostTagsLabel returning the tags originally stored in it.

func IsInternalLabel

func IsInternalLabel(name string) bool

func IsInternalMetricName

func IsInternalMetricName(name string) bool

IsInternalMetricName returns true for metric names created using MakeInternalMetricName

func IsUnnamedTagLabelName

func IsUnnamedTagLabelName(name string) bool

IsUnnamedTagLabelName returns true if label name corresponds to an unnamed tag

func MakeInternalLabelName

func MakeInternalLabelName(label string) string

MakeInternalLabelName transforms a string into an internal label name that will not collide with customer-defined labels.

func MakeInternalMetricName

func MakeInternalMetricName(name string) string

MakeInternalMetricName transforms a string into an internal metric name that will not collide with customer-defined metrics.

func MetricToProm

func MetricToProm(name string) string

MetricToProm translates DataDog metric names into valid Prometheus metrics, previously removing any invalid for DataDog characters.

func UnescapeLabelName

func UnescapeLabelName(val string) string

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 TagsToLabels

func TagsToLabels(tags []string) Labels

TagsToLabels maps a tag slice to Labels

func (Labels) AddTag

func (ls Labels) AddTag(tagValue string)

func (Labels) LabelAdapters

func (ls Labels) LabelAdapters() []mimirpb.LabelAdapter

func (Labels) PrompbLabels

func (ls Labels) PrompbLabels() []prompb.Label

func (Labels) SetTagIfNotPresent

func (ls Labels) SetTagIfNotPresent(tag Tag)

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

func ExtractMetricTags(metric model.Metric) []Tag

ExtractMetricTags extracts all the tags stored in a Prometheus model.Metric

func ExtractTagsFromLabel

func ExtractTagsFromLabel(name, value string) []Tag

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

func NewTag(tag string) Tag

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

func NewTagFromKeyValue(key, value string) Tag

NewTagFromKeyValue builds a tag from a know key:value pair

func (Tag) IsUnnamed

func (t Tag) IsUnnamed() bool

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

func (t Tag) Key() string

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

func (t Tag) LabelName() string

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

func (t Tag) LabelValue() string

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

func (t Tag) LabelValueForQuery() string

LabelValueForQuery is like LabelValue but it also allows the wildcard character

func (Tag) Tag

func (t Tag) Tag() string

Tag is the entire tag indentifier

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL