diff --git a/kubernetes_state/datadog_checks/kubernetes_state/kubernetes_state.py b/kubernetes_state/datadog_checks/kubernetes_state/kubernetes_state.py index 1e922038029e3..addfcfd06533b 100644 --- a/kubernetes_state/datadog_checks/kubernetes_state/kubernetes_state.py +++ b/kubernetes_state/datadog_checks/kubernetes_state/kubernetes_state.py @@ -431,6 +431,8 @@ def _create_kubernetes_state_prometheus_instance(self, instance): ksm_instance['label_to_hostname'] = 'node' clustername = get_clustername() if clustername != "": + # some cluster names are not valid RFC1123, but as we use them as a hostAlias we want them to be valid. + clustername = clustername.replace("_", "-") ksm_instance['label_to_hostname_suffix'] = "-" + clustername if 'labels_mapper' in ksm_instance and not isinstance(ksm_instance['labels_mapper'], dict):