Documentation ¶
Index ¶
- Constants
- Variables
- func ReadProgressFile(dir string) (offset int, err error)
- func SaveProgressFile(dir string, offset int) error
- type Appender
- type CounterAggregator
- type CounterAggregatorConfig
- type CounterAggregatorMetricConfig
- type MetadataGetter
- type PrometheusReader
- type ResourceMap
- type ResourceMapList
- type TargetGetter
Constants ¶
const ( ProjectIDLabel = "_stackdriver_project_id" KubernetesLocationLabel = "_kubernetes_location" KubernetesClusterNameLabel = "_kubernetes_cluster_name" GenericNamespaceLabel = "_generic_namespace" GenericLocationLabel = "_generic_location" )
Variables ¶
var AnthosL4LBMap = ResourceMap{ Type: "anthos_l4lb", MatchLabel: "__meta_kubernetes_service_annotation_gke_googleapis_com_anthos_l4lb_type", LabelMap: map[string]labelTranslation{ ProjectIDLabel: constValue("project_id"), KubernetesLocationLabel: constValue("location"), "__meta_kubernetes_service_annotation_gke_googleapis_com_anthos_l4lb_kind": constValue("kind"), "__meta_kubernetes_service_annotation_gke_googleapis_com_anthos_l4lb_group_name": constValue("group_name"), "__meta_kubernetes_service_annotation_gke_googleapis_com_anthos_l4lb_hostname": constValue("hostname"), }, }
var ConnectionResourceMap = ResourceMap{ Type: "connectors.googleapis.com/Connection", MatchLabel: "__meta_kubernetes_pod_label_type_connection", LabelMap: map[string]labelTranslation{ ProjectIDLabel: constValue("resource_container"), KubernetesLocationLabel: constValue("location"), "connection": constValue("connection"), }, }
var DevappResourceMap = ResourceMap{ Type: "apigee.googleapis.com/Devapp", MatchLabel: "__meta_kubernetes_pod_label_type_devapp", LabelMap: map[string]labelTranslation{ ProjectIDLabel: constValue("resource_container"), KubernetesLocationLabel: constValue("location"), "__meta_kubernetes_pod_label_org": constValue("org"), "__meta_kubernetes_pod_label_env": constValue("env"), "api_product_name": constValue("api_product_name"), "__meta_kubernetes_pod_name": constValue("host"), }, }
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"), }, }
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 }, }, }
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"), }, }
var ProxyResourceMap = ResourceMap{ Type: "apigee.googleapis.com/Proxy", MatchLabel: "__meta_kubernetes_pod_label_type_proxy", LabelMap: map[string]labelTranslation{ ProjectIDLabel: constValue("resource_container"), KubernetesLocationLabel: constValue("location"), "__meta_kubernetes_pod_label_org": constValue("org"), "__meta_kubernetes_pod_label_env": constValue("env"), "proxy_name": constValue("proxy_name"), "revision": constValue("revision"), "__meta_kubernetes_pod_name": constValue("host"), }, }
var ProxyV2ResourceMap = ResourceMap{ Type: "apigee.googleapis.com/ProxyV2", MatchLabel: "__meta_kubernetes_pod_label_type_proxy_v2", LabelMap: map[string]labelTranslation{ ProjectIDLabel: constValue("resource_container"), KubernetesLocationLabel: constValue("location"), "org": constValue("org"), "env": constValue("env"), "proxy_name": constValue("proxy_name"), "runtime_version": constValue("runtime_version"), "instance_id": constValue("instance_id"), }, }
var ResourceMappings = ResourceMapList{ AnthosL4LBMap, ConnectionResourceMap, TargetV2ResourceMap, ProxyV2ResourceMap, ProxyResourceMap, DevappResourceMap, { 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"), }, }, }
When you add new elements, you also probably want to update TestResourceMappingsOrder.
var TargetV2ResourceMap = ResourceMap{ Type: "apigee.googleapis.com/TargetV2", MatchLabel: "__meta_kubernetes_pod_label_type_target_v2", LabelMap: map[string]labelTranslation{ ProjectIDLabel: constValue("resource_container"), KubernetesLocationLabel: constValue("location"), "org": constValue("org"), "env": constValue("env"), "proxy_name": constValue("proxy_name"), "type": constValue("type"), "endpoint": constValue("endpoint"), "runtime_version": constValue("runtime_version"), "instance_id": constValue("instance_id"), }, }
Functions ¶
func ReadProgressFile ¶
ReadPRogressFile reads the progress file in the given directory and returns the saved offset.
func SaveProgressFile ¶
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 CounterAggregator ¶
type CounterAggregator struct {
// contains filtered or unexported fields
}
CounterAggregator provides the 'aggregated counters' feature of the sidecar. It can be used to export a sum of multiple counters from Prometheus to Stackdriver as a single cumulative metric. Each aggregated counter is associated with a single OpenCensus counter that can then be exported to Stackdriver (as a CUMULATIVE metric) or exposed to Prometheus via the standard `/metrics` endpoint. Regular flushing of counter values is implemented by OpenCensus.
func NewCounterAggregator ¶
func NewCounterAggregator(logger log.Logger, config *CounterAggregatorConfig) (*CounterAggregator, error)
NewCounterAggregator creates a counter aggregator.
func (*CounterAggregator) Close ¶
func (c *CounterAggregator) Close()
Close must be called when CounterAggregator is no longer needed.
type CounterAggregatorConfig ¶
type CounterAggregatorConfig map[string]*CounterAggregatorMetricConfig
CounterAggregatorConfig contains configuration for CounterAggregator. Keys of the map are metric names that will be exported by counter aggregator.
type CounterAggregatorMetricConfig ¶
type CounterAggregatorMetricConfig struct { Matchers [][]*promlabels.Matcher Help string }
CounterAggregatorMetricConfig provides configuration of a single aggregated counter. Matchers specify what Prometheus metrics (which are expected to be counter metrics) will be re-aggregated. Help provides a description for the exported metric.
func (CounterAggregatorMetricConfig) Equal ¶
func (a CounterAggregatorMetricConfig) Equal(b CounterAggregatorMetricConfig) bool
type MetadataGetter ¶
type PrometheusReader ¶
type PrometheusReader struct {
// contains filtered or unexported fields
}
func NewPrometheusReader ¶
func NewPrometheusReader( logger log.Logger, walDirectory string, tailer *tail.Tailer, filtersets [][]*labels.Matcher, metricRenames map[string]string, targetGetter TargetGetter, metadataGetter MetadataGetter, appender Appender, metricsPrefix string, useGkeResource bool, counterAggregator *CounterAggregator, ) *PrometheusReader
NewPrometheusReader is the PrometheusReader constructor
type ResourceMap ¶
type ResourceMap struct { // The name of the Stackdriver MonitoredResource. Type string // MatchLabel must exist in the set of Prometheus labels in order for this map to match. Ignored if empty. MatchLabel string // Mapping from Prometheus to Stackdriver labels LabelMap map[string]labelTranslation }
func (*ResourceMap) BestEffortTranslate ¶
func (m *ResourceMap) BestEffortTranslate(discovered, entryLabels labels.Labels) (map[string]string, labels.Labels)
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, entryLabels labels.Labels) (map[string]string, labels.Labels)
Translate translates labels to a monitored resource and entry labels, if possible. Returns the resource and the modified entry labels.
The labels in `discovered` and `entryLabels` are used as input. If a label exists in both sets, the one in `entryLabels` takes precedence. Whenever a label from `entryLabels` is used, it is removed from the set that is returned.
type ResourceMapList ¶
type ResourceMapList []ResourceMap
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.