Prometheus metric label value is overridden by pod label

%3CLINGO-SUB%20id%3D%22lingo-sub-2942278%22%20slang%3D%22en-US%22%3EPrometheus%20metric%20label%20value%20is%20overridden%20by%20pod%20label%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2942278%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%26nbsp%3BI%20have%20configured%20scraping%20of%20Prometheus%20metrics%20with%20Container%20insights%20using%20this%20instruction%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-monitor%2Fcontainers%2Fcontainer-insights-prometheus-integration%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-monitor%2Fcontainers%2Fcontainer-insights-prometheus-integration%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20noticed%20that%20labels%20are%20stored%20into%20InsightsMetrics.Tags%20field%2C%20in%20my%20case%20I%20have%20a%20metric%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ekong_latency_bucket%3CSPAN%3E%7B%3C%2FSPAN%3E%3CSPAN%3Etype%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22kong%22%3C%2FSPAN%3E%2Cservice%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22google%22%3C%2FSPAN%3E%2Croute%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22google.route-1%22%3C%2FSPAN%3E%2Cle%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%2200001.0%22%3C%2FSPAN%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%201%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20means%20that%20in%20the%20InsightsMetrics.Tags%20I%20should%20have%20the%20following%20fields%3A%20type%2C%20service%2C%20route%20and%20le.%3C%2FP%3E%3CP%3EI%20noticed%20that%20if%20my%20pod%20has%20%E2%80%9Cservice%E2%80%9D%20label%20then%20the%20value%20of%20the%20pod%20is%20stored%20in%20InsightsMetrics.Tags.service%20field%20instead%20of%20the%20metric%20value%20and%20now%20I%E2%80%99m%20losing%20information%20about%20metric%20value.%20Is%20there%20a%20way%20to%20specify%20a%20prefix%20for%20Prometheus%20metric%20labels%20in%20InsightsMetrics.Tags%20field%20or%20anything%20that%20allows%20me%20to%20have%20correct%20value%20in%20service%20field%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2942278%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EContainer%20Insights%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ELog%20Analytics%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2957369%22%20slang%3D%22en-US%22%3ERe%3A%20Prometheus%20metric%20label%20value%20is%20overridden%20by%20pod%20label%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2957369%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1212364%22%20target%3D%22_blank%22%3E%40adamlepkowski%3C%2FA%3E%26nbsp%3BCan%20you%20explain%20a%20bit%20more.%20Did%20you%20mean%20to%20say%20that%20the%20tag%20'service'%20has%20pod%20name%20instead%20of%20having%20the%20label's%20actual%20value%20(google%20in%20your%20example%20below)%20%3F%20Whats%20the%20scraping%20mechanism%20you%20are%20using%20%3F%20If%20you%20can%20share%20the%20config%20map%20snippet%20it%20would%20be%20great.%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

Hi, I have configured scraping of Prometheus metrics with Container insights using this instruction: https://docs.microsoft.com/en-us/azure/azure-monitor/containers/container-insights-prometheus-integr...

 

I noticed that labels are stored into InsightsMetrics.Tags field, in my case I have a metric:

 

kong_latency_bucket{type="kong",service="google",route="google.route-1",le="00001.0"} 1

 

It means that in the InsightsMetrics.Tags I should have the following fields: type, service, route and le.

I noticed that if my pod has “service” label then the value of the pod is stored in InsightsMetrics.Tags.service field instead of the metric value and now I’m losing information about metric value. Is there a way to specify a prefix for Prometheus metric labels in InsightsMetrics.Tags field or anything that allows me to have correct value in service field?

3 Replies

@adamlepkowski Can you explain a bit more. Did you mean to say that the tag 'service' has pod name instead of having the label's actual value (google in your example below) ? Whats the scraping mechanism you are using ? If you can share the config map snippet it would be great.

@vishiy Tags.service has value of pod label instead of value from prometheus metric. Below configuration:

 

POD yaml defintion:

apiVersion: v1
kind: Pod
metadata:
  name: pkad
  labels:
    service: 'value that will be put into Tags'
spec:
  containers:
.......

Prometheus metric:

kong_latency_bucket{type="kong",service="google",route="google.route-1",le="00001.0"} 1

 

In my tags.service I should have value "google" but I have "value that will be put into Tags"

 

Config map:

kind: ConfigMap
apiVersion: v1
data:
  schema-version:
    #string.used by agent to parse config. supported versions are {v1}. Configs with other schema versions will be rejected by the agent.
    v1
  config-version:
    #string.used by customer to keep track of this config file's version in their source control/repository (max allowed 10 chars, other chars will be truncated)
    ver1
  log-data-collection-settings:
    [log_collection_settings]
       [log_collection_settings.stdout]
          enabled = true
          exclude_namespaces = ["kube-system"]

       [log_collection_settings.stderr]
          enabled = true
          exclude_namespaces = ["kube-system"]

       [log_collection_settings.env_var]
          enabled = true
       [log_collection_settings.enrich_container_logs]
          enabled = false
       [log_collection_settings.collect_all_kube_events]
          enabled = false
    
  prometheus-data-collection-settings:
    [prometheus_data_collection_settings.cluster]
        interval = "1m"

        monitor_kubernetes_pods = true

       [prometheus_data_collection_settings.node]
        interval = "1m"

  alertable-metrics-configuration-settings: 
    [alertable_metrics_configuration_settings.container_resource_utilization_thresholds]
        container_cpu_threshold_percentage = 95.0
        container_memory_rss_threshold_percentage = 95.0
        container_memory_working_set_threshold_percentage = 95.0
metadata:
  name: container-azm-ms-agentconfig
  namespace: kube-system

 

This is a Telegraf issue, which is a OSS component we use. I will track and fix this
Since its also adding pod labels as dimensions for the metrics, collisions are resolved in a undesired way (i would prefer use actual metric labels as opposed to pod labels for colliding time-series).

Can you work this around by any one of the options below, until we resolve this ?
1) Instead of scraping thru pod annotations, can you scrape a k8s service endpoints if possible ?
2) Can you update/patch the pod labels for your deployments may be ?

 

Thank you for bringing this to our attention, @adamlepkowski