Skip to content

Commit

Permalink
add phase tag label join
Browse files Browse the repository at this point in the history
  • Loading branch information
hkaj committed Nov 21, 2018
1 parent bab268c commit aa4f31e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,12 @@ def _store_labels(self, metric, scraper_config):
if metric.name in scraper_config['label_joins']:
matching_label = scraper_config['label_joins'][metric.name]['label_to_match']
for sample in metric.samples:
# metadata-only metrics that are used for label joins are always equal to 1
# this is required for metrics where all combinations of a state are sent
# but only the active one is set to 1 (others are set to 0)
# example: kube_pod_status_phase in kube-state-metrics
if sample[self.SAMPLE_VALUE] != 1:
continue
labels_list = []
matching_value = None
for label_name, label_value in iteritems(sample[self.SAMPLE_LABELS]):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,10 @@ def _create_kubernetes_state_prometheus_instance(self, instance):
'label_to_match': 'pod',
'labels_to_get': ['node']
},
'kube_pod_status_phase': {
'label_to_match': 'pod',
'labels_to_get': ['phase']
},
'kube_persistentvolume_info': {
'label_to_match': 'persistentvolume',
'labels_to_get': ['storageclass']
Expand Down

0 comments on commit aa4f31e

Please sign in to comment.