Skip to content
This repository has been archived by the owner on Dec 1, 2018. It is now read-only.

delete pod_namespace && decrease influxdb labels #1659

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions metrics/core/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ var (
Key: "pod_name",
Description: "The name of the pod",
}
// Deprecated label
LabelPodNamespace = LabelDescriptor{
Key: "pod_namespace",
Description: "The namespace of the pod",
}
LabelNamespaceName = LabelDescriptor{
Key: "namespace_name",
Description: "The name of the namespace",
Expand Down Expand Up @@ -114,7 +109,6 @@ var containerLabels = []LabelDescriptor{
var podLabels = []LabelDescriptor{
LabelPodName,
LabelPodId,
LabelPodNamespace,
LabelPodNamespaceUID,
LabelLabels,
}
Expand Down
1 change: 0 additions & 1 deletion metrics/processors/pod_aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
var LabelsToPopulate = []core.LabelDescriptor{
core.LabelPodId,
core.LabelPodName,
core.LabelPodNamespace,
core.LabelNamespaceName,
core.LabelPodNamespaceUID,
core.LabelHostname,
Expand Down
2 changes: 0 additions & 2 deletions metrics/processors/pod_based_enricher.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ func addContainerInfo(key string, containerMs *core.MetricSet, pod *kube_api.Pod
Labels: map[string]string{
core.LabelMetricSetType.Key: core.MetricSetTypePod,
core.LabelNamespaceName.Key: namespace,
core.LabelPodNamespace.Key: namespace,
core.LabelPodName.Key: podName,
core.LabelNodename.Key: containerMs.Labels[core.LabelNodename.Key],
core.LabelHostname.Key: containerMs.Labels[core.LabelHostname.Key],
Expand Down Expand Up @@ -133,7 +132,6 @@ func addPodInfo(key string, podMs *core.MetricSet, pod *kube_api.Pod, batch *cor
Labels: map[string]string{
core.LabelMetricSetType.Key: core.MetricSetTypePodContainer,
core.LabelNamespaceName.Key: pod.Namespace,
core.LabelPodNamespace.Key: pod.Namespace,
core.LabelPodName.Key: pod.Name,
core.LabelContainerName.Key: container.Name,
core.LabelContainerBaseImage.Key: container.Image,
Expand Down
18 changes: 14 additions & 4 deletions metrics/sinks/influxdb/influxdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ type influxdbSink struct {
dbExists bool
}

var influxdbBlacklistLabels = map[string]struct{}{
core.LabelPodNamespaceUID.Key: {},
core.LabelPodId.Key: {},
core.LabelHostname.Key: {},
}

const (
// Value Field name
valueField = "value"
Expand Down Expand Up @@ -89,8 +95,10 @@ func (sink *influxdbSink) ExportData(dataBatch *core.DataBatch) {
Time: dataBatch.Timestamp.UTC(),
}
for key, value := range metricSet.Labels {
if value != "" {
point.Tags[key] = value
if _, exists := influxdbBlacklistLabels[key]; !exists {
if value != "" {
point.Tags[key] = value
}
}
}

Expand Down Expand Up @@ -141,8 +149,10 @@ func (sink *influxdbSink) ExportData(dataBatch *core.DataBatch) {
}
}
for key, value := range labeledMetric.Labels {
if value != "" {
point.Tags[key] = value
if _, exists := influxdbBlacklistLabels[key]; !exists {
if value != "" {
point.Tags[key] = value
}
}
}
point.Tags["cluster_name"] = sink.c.ClusterName
Expand Down
6 changes: 0 additions & 6 deletions metrics/sinks/metric/metric_sink_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ func makeBatches(now time.Time, key, otherKey string) (core.DataBatch, core.Data
key: {
Labels: map[string]string{
core.LabelMetricSetType.Key: core.MetricSetTypePod,
core.LabelPodNamespace.Key: "ns1",
},
MetricValues: map[string]core.MetricValue{
"m1": {
Expand All @@ -54,7 +53,6 @@ func makeBatches(now time.Time, key, otherKey string) (core.DataBatch, core.Data
key: {
Labels: map[string]string{
core.LabelMetricSetType.Key: core.MetricSetTypePod,
core.LabelPodNamespace.Key: "ns1",
},
MetricValues: map[string]core.MetricValue{
"m1": {
Expand Down Expand Up @@ -98,7 +96,6 @@ func makeBatches(now time.Time, key, otherKey string) (core.DataBatch, core.Data
key: {
Labels: map[string]string{
core.LabelMetricSetType.Key: core.MetricSetTypePod,
core.LabelPodNamespace.Key: "ns1",
},
MetricValues: map[string]core.MetricValue{
"m1": {
Expand Down Expand Up @@ -136,7 +133,6 @@ func makeBatches(now time.Time, key, otherKey string) (core.DataBatch, core.Data
otherKey: {
Labels: map[string]string{
core.LabelMetricSetType.Key: core.MetricSetTypePod,
core.LabelPodNamespace.Key: "ns1",
},
MetricValues: map[string]core.MetricValue{
"m1": {
Expand Down Expand Up @@ -223,7 +219,6 @@ func TestGetNames(t *testing.T) {
key: {
Labels: map[string]string{
core.LabelMetricSetType.Key: core.MetricSetTypePod,
core.LabelPodNamespace.Key: "ns1",
core.LabelNamespaceName.Key: "ns1",
core.LabelPodName.Key: "pod1",
},
Expand All @@ -243,7 +238,6 @@ func TestGetNames(t *testing.T) {
otherKey: {
Labels: map[string]string{
core.LabelMetricSetType.Key: core.MetricSetTypePod,
core.LabelPodNamespace.Key: "ns2",
core.LabelNamespaceName.Key: "ns2",
core.LabelPodName.Key: "pod2",
},
Expand Down
2 changes: 0 additions & 2 deletions metrics/sources/kubelet/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@ func (this *kubeletMetricsSource) handleKubernetesContainer(cName, ns, podName s
cMetrics.Labels[LabelPodId.Key] = c.Spec.Labels[kubernetesPodUID]
cMetrics.Labels[LabelPodName.Key] = podName
cMetrics.Labels[LabelNamespaceName.Key] = ns
// Needed for backward compatibility
cMetrics.Labels[LabelPodNamespace.Key] = ns
return metricSetKey
}

Expand Down
2 changes: 0 additions & 2 deletions metrics/sources/summary/summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,6 @@ func (this *summaryMetricsSource) decodePodStats(metrics map[string]*MetricSet,
podMetrics.Labels[LabelPodId.Key] = ref.UID
podMetrics.Labels[LabelPodName.Key] = ref.Name
podMetrics.Labels[LabelNamespaceName.Key] = ref.Namespace
// Needed for backward compatibility
podMetrics.Labels[LabelPodNamespace.Key] = ref.Namespace

this.decodeUptime(podMetrics, pod.StartTime.Time)
this.decodeNetworkStats(podMetrics, pod.Network)
Expand Down