retrieval

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2018 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProjectIDLabel             = "_stackdriver_project_id"
	KubernetesLocationLabel    = "_kubernetes_location"
	KubernetesClusterNameLabel = "_kubernetes_cluster_name"
	GenericNamespaceLabel      = "_generic_namespace"
	GenericLocationLabel       = "_generic_location"
)

Variables

View Source
var EC2ResourceMap = ResourceMap{
	Type: "aws_ec2_instance",
	LabelMap: map[string]labelTranslation{
		ProjectIDLabel:           constValue("project_id"),
		"__meta_ec2_instance_id": constValue("instance_id"),
		"__meta_ec2_availability_zone": labelTranslation{
			// contains filtered or unexported fields
		},
		"__meta_ec2_owner_id": constValue("aws_account"),
	},
}
View Source
var GCEResourceMap = ResourceMap{
	Type: "gce_instance",
	LabelMap: map[string]labelTranslation{
		"__meta_gce_project":     constValue("project_id"),
		"__meta_gce_instance_id": constValue("instance_id"),
		"__meta_gce_zone": labelTranslation{
			// contains filtered or unexported fields
		},
	},
}
View Source
var GKEResourceMap = ResourceMap{
	Type: "gke_container",
	LabelMap: map[string]labelTranslation{
		ProjectIDLabel:                         constValue("project_id"),
		KubernetesLocationLabel:                constValue("zone"),
		KubernetesClusterNameLabel:             constValue("cluster_name"),
		"__meta_kubernetes_namespace":          constValue("namespace_id"),
		"__meta_kubernetes_node_name":          constValue("instance_id"),
		"__meta_kubernetes_pod_name":           constValue("pod_id"),
		"__meta_kubernetes_pod_container_name": constValue("container_name"),
	},
}
View Source
var ResourceMappings = []ResourceMap{
	{
		Type: "k8s_container",
		LabelMap: map[string]labelTranslation{
			ProjectIDLabel:                         constValue("project_id"),
			KubernetesLocationLabel:                constValue("location"),
			KubernetesClusterNameLabel:             constValue("cluster_name"),
			"__meta_kubernetes_namespace":          constValue("namespace_name"),
			"__meta_kubernetes_pod_name":           constValue("pod_name"),
			"__meta_kubernetes_pod_container_name": constValue("container_name"),
		},
	},
	{
		Type: "k8s_pod",
		LabelMap: map[string]labelTranslation{
			ProjectIDLabel:                constValue("project_id"),
			KubernetesLocationLabel:       constValue("location"),
			KubernetesClusterNameLabel:    constValue("cluster_name"),
			"__meta_kubernetes_namespace": constValue("namespace_name"),
			"__meta_kubernetes_pod_name":  constValue("pod_name"),
		},
	},
	{
		Type: "k8s_node",
		LabelMap: map[string]labelTranslation{
			ProjectIDLabel:                constValue("project_id"),
			KubernetesLocationLabel:       constValue("location"),
			KubernetesClusterNameLabel:    constValue("cluster_name"),
			"__meta_kubernetes_node_name": constValue("node_name"),
		},
	},
	EC2ResourceMap,
	GCEResourceMap,
	{
		Type: "generic_task",
		LabelMap: map[string]labelTranslation{
			ProjectIDLabel:        constValue("project_id"),
			GenericLocationLabel:  constValue("location"),
			GenericNamespaceLabel: constValue("namespace"),
			"job":                 constValue("job"),
			"instance":            constValue("task_id"),
		},
	},
}

TODO(jkohen): ensure these are sorted from more specific to less specific.

Functions

func ReadProgressFile

func ReadProgressFile(dir string) (offset int, err error)

ReadPRogressFile reads the progress file in the given directory and returns the saved offset.

func SaveProgressFile

func SaveProgressFile(dir string, offset int) error

SaveProgressFile saves a progress file with the given offset in directory.

Types

type Appender

type Appender interface {
	Append(hash uint64, s *monitoring_pb.TimeSeries) error
}

Appender appends a time series with exactly one data point. A hash for the series (but not the data point) must be provided. The client may cache the computed hash more easily, which is why its part of the call and not done by the Appender's implementation.

type MetadataGetter

type MetadataGetter interface {
	Get(ctx context.Context, job, instance, metric string) (*scrape.MetricMetadata, error)
}

type PrometheusReader

type PrometheusReader struct {
	// contains filtered or unexported fields
}

func NewPrometheusReader

func NewPrometheusReader(
	logger log.Logger,
	walDirectory string,
	tailer *tail.Tailer,
	filters []*labels.Matcher,
	metricRenames map[string]string,
	targetGetter TargetGetter,
	metadataGetter MetadataGetter,
	appender Appender,
	metricsPrefix string,
	useGkeResource bool,
) *PrometheusReader

NewPrometheusReader is the PrometheusReader constructor

func (*PrometheusReader) Run

func (r *PrometheusReader) Run(ctx context.Context, startOffset int) error

type ResourceMap

type ResourceMap struct {
	// The name of the Stackdriver MonitoredResource.
	Type string
	// Mapping from Prometheus to Stackdriver labels
	LabelMap map[string]labelTranslation
}

func (*ResourceMap) BestEffortTranslate added in v0.2.0

func (m *ResourceMap) BestEffortTranslate(discovered, final labels.Labels) map[string]string

BestEffortTranslate translates labels to resource with best effort. If the resource label cannot be filled, use empty string instead.

func (*ResourceMap) Translate

func (m *ResourceMap) Translate(discovered, final labels.Labels) map[string]string

type TargetGetter

type TargetGetter interface {
	Get(ctx context.Context, lset labels.Labels) (*targets.Target, error)
}

func TargetsWithDiscoveredLabels

func TargetsWithDiscoveredLabels(tg TargetGetter, lset labels.Labels) TargetGetter

TargetsWithDiscoveredLabels wraps a TargetGetter and adds a static set of labels to the discovered labels of all targets retrieved from it.

Jump to

Keyboard shortcuts

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