Skip to content

Commit 970bbb0

Browse files
authored
Remove invalid host tags (#17549)
* remove invalid host tags * Improve validation * Add changelog * Update test after merge
1 parent be583e3 commit 970bbb0

File tree

7 files changed

+15
-51
lines changed

7 files changed

+15
-51
lines changed

esxi/assets/configuration/spec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ files:
147147
description: |
148148
Use this option to send a subset of host tags as metric tags.
149149
The ESXi integration collects tags for every ESXi host or VM in your environment.
150-
Those tags can be `esxi_url`, esxi_type`, `esxi_host`, `esxi_folder`, `esxi_cluster`
151-
`esxi_compute`, `esxi_datacenter`, `esxi_datastore` and are attached to the ESXi metrics by default.
150+
Those tags can be `esxi_url`, esxi_type`, `esxi_host`, and `esxi_datastore`
151+
and are attached to the ESXi metrics by default.
152152
By default these tags are submitted as host tags, but you can submit them as metric tags instead by using
153153
this configuration option, see: https://docs.datadoghq.com/tagging/using_tags/
154154
You will lose the ability to filter your hosts on the tags you specify but they will appear faster

esxi/changelog.d/17549.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove invalid host tags

esxi/datadog_checks/esxi/check.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ def _validate_excluded_host_tags(self, excluded_host_tags):
6363
if excluded_host_tag not in AVAILABLE_HOST_TAGS:
6464
self.log.warning(
6565
"Unknown host tag `%s` cannot be excluded. Available host tags are: "
66-
"`esxi_url`, `esxi_type`, `esxi_host`, `esxi_folder`, `esxi_cluster` "
67-
"`esxi_compute`, `esxi_datacenter`, and `esxi_datastore`",
66+
"`esxi_url`, `esxi_type`, `esxi_host`, `esxi_compute`, and `esxi_datastore`",
6867
excluded_host_tag,
6968
)
7069
else:
@@ -423,17 +422,12 @@ def check(self, _):
423422
runtime_hostname = to_string(runtime_host_props.get("name", "unknown"))
424423
tags.append('esxi_host:{}'.format(runtime_hostname))
425424

426-
if runtime_host is not None:
427-
tags.extend(
428-
get_tags_recursively(
429-
runtime_host,
430-
resource_map,
431-
include_only=['esxi_cluster'],
432-
)
433-
)
434-
435425
if parent is not None:
436-
tags.extend(get_tags_recursively(parent, resource_map))
426+
tags.extend(
427+
get_tags_recursively(
428+
parent, resource_map, include_only=["esxi_compute", "esxi_host", "esxi_datastore"]
429+
)
430+
)
437431

438432
tags.append('esxi_type:{}'.format(resource_type_name))
439433

esxi/datadog_checks/esxi/constants.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,7 @@
6161
"esxi_url",
6262
"esxi_type",
6363
"esxi_host",
64-
"esxi_folder",
65-
"esxi_cluster",
6664
"esxi_compute",
67-
"esxi_datacenter",
6865
"esxi_datastore",
6966
]
7067

esxi/datadog_checks/esxi/data/conf.yaml.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ instances:
108108
## @param excluded_host_tags - list of strings - optional - default: []
109109
## Use this option to send a subset of host tags as metric tags.
110110
## The ESXi integration collects tags for every ESXi host or VM in your environment.
111-
## Those tags can be `esxi_url`, esxi_type`, `esxi_host`, `esxi_folder`, `esxi_cluster`
112-
## `esxi_compute`, `esxi_datacenter`, `esxi_datastore` and are attached to the ESXi metrics by default.
111+
## Those tags can be `esxi_url`, esxi_type`, `esxi_host`, and `esxi_datastore`
112+
## and are attached to the ESXi metrics by default.
113113
## By default these tags are submitted as host tags, but you can submit them as metric tags instead by using
114114
## this configuration option, see: https://docs.datadoghq.com/tagging/using_tags/
115115
## You will lose the ability to filter your hosts on the tags you specify but they will appear faster

esxi/tests/test_integration.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,6 @@ def test_vcsim_external_host_tags(vcsim_instance, datadog_agent, dd_run_check):
8585
{
8686
'esxi': [
8787
'esxi_compute:localhost.localdomain',
88-
'esxi_datacenter:ha-datacenter',
89-
'esxi_folder:ha-folder-root',
90-
'esxi_folder:host',
9188
'esxi_type:host',
9289
'esxi_url:127.0.0.1:8989',
9390
]
@@ -97,9 +94,6 @@ def test_vcsim_external_host_tags(vcsim_instance, datadog_agent, dd_run_check):
9794
'ha-host_VM0',
9895
{
9996
'esxi': [
100-
'esxi_datacenter:ha-datacenter',
101-
'esxi_folder:ha-folder-root',
102-
'esxi_folder:vm',
10397
'esxi_type:vm',
10498
'esxi_host:localhost.localdomain',
10599
'esxi_url:127.0.0.1:8989',
@@ -110,9 +104,6 @@ def test_vcsim_external_host_tags(vcsim_instance, datadog_agent, dd_run_check):
110104
'ha-host_VM1',
111105
{
112106
'esxi': [
113-
'esxi_datacenter:ha-datacenter',
114-
'esxi_folder:ha-folder-root',
115-
'esxi_folder:vm',
116107
'esxi_type:vm',
117108
'esxi_host:localhost.localdomain',
118109
'esxi_url:127.0.0.1:8989',
@@ -129,16 +120,10 @@ def test_esxi_resource_count_metrics(vcsim_instance, dd_run_check, aggregator):
129120

130121
host_tags = [
131122
'esxi_compute:localhost.localdomain',
132-
'esxi_datacenter:ha-datacenter',
133-
'esxi_folder:ha-folder-root',
134-
'esxi_folder:host',
135123
'esxi_type:host',
136124
'esxi_url:127.0.0.1:8989',
137125
]
138126
vm_tags = [
139-
'esxi_datacenter:ha-datacenter',
140-
'esxi_folder:ha-folder-root',
141-
'esxi_folder:vm',
142127
'esxi_type:vm',
143128
'esxi_host:localhost.localdomain',
144129
'esxi_url:127.0.0.1:8989',

esxi/tests/test_unit.py

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,6 @@ def test_external_host_tags(vcsim_instance, datadog_agent, dd_run_check):
154154
'localhost.localdomain',
155155
{
156156
'esxi': [
157-
'esxi_datacenter:dc2',
158-
'esxi_folder:folder_1',
159157
'esxi_type:host',
160158
'esxi_url:127.0.0.1:8989',
161159
]
@@ -165,8 +163,6 @@ def test_external_host_tags(vcsim_instance, datadog_agent, dd_run_check):
165163
'vm1',
166164
{
167165
'esxi': [
168-
'esxi_datacenter:dc2',
169-
'esxi_folder:folder_1',
170166
'esxi_type:vm',
171167
'esxi_host:localhost.localdomain',
172168
'esxi_url:127.0.0.1:8989',
@@ -177,7 +173,6 @@ def test_external_host_tags(vcsim_instance, datadog_agent, dd_run_check):
177173
'vm2',
178174
{
179175
'esxi': [
180-
'esxi_cluster:c1',
181176
'esxi_compute:c1',
182177
'esxi_type:vm',
183178
'esxi_url:127.0.0.1:8989',
@@ -275,10 +270,8 @@ def test_external_host_tags_all_resources(vcsim_instance, datadog_agent, dd_run_
275270
'hostname',
276271
{
277272
'esxi': [
278-
'esxi_cluster:c1',
279273
'esxi_compute:c1',
280274
'esxi_datastore:ds1',
281-
'esxi_datastore_cluster:pod1',
282275
'esxi_type:host',
283276
'esxi_url:127.0.0.1:8989',
284277
]
@@ -289,7 +282,6 @@ def test_external_host_tags_all_resources(vcsim_instance, datadog_agent, dd_run_
289282
{
290283
'esxi': [
291284
'esxi_type:vm',
292-
'esxi_cluster:c1',
293285
'esxi_host:hostname',
294286
'esxi_url:127.0.0.1:8989',
295287
]
@@ -544,13 +536,13 @@ def test_invalid_instance_filters(dd_run_check, vcsim_instance, caplog):
544536
pytest.param(
545537
['test'],
546538
"Unknown host tag `test` cannot be excluded. Available host tags are: `esxi_url`, `esxi_type`, "
547-
"`esxi_host`, `esxi_folder`, `esxi_cluster` `esxi_compute`, `esxi_datacenter`, and `esxi_datastore`",
539+
"`esxi_host`, `esxi_compute`, and `esxi_datastore`",
548540
id="unknown tag",
549541
),
550542
pytest.param(
551-
['esxi_type', 'esxi_cluster', 'hello'],
543+
['esxi_type', 'hello'],
552544
"Unknown host tag `hello` cannot be excluded. Available host tags are: `esxi_url`, `esxi_type`, "
553-
"`esxi_host`, `esxi_folder`, `esxi_cluster` `esxi_compute`, `esxi_datacenter`, and `esxi_datastore`",
545+
"`esxi_host`, `esxi_compute`, and `esxi_datastore`",
554546
id="known and unknown tags together",
555547
),
556548
],
@@ -568,16 +560,13 @@ def test_excluded_host_tags(
568560
if expected_warning is not None:
569561
assert expected_warning in caplog.text
570562

571-
host_external_tags = ['esxi_datacenter:dc2', 'esxi_folder:folder_1', 'esxi_type:host', 'esxi_url:127.0.0.1:8989']
563+
host_external_tags = ['esxi_type:host', 'esxi_url:127.0.0.1:8989']
572564
vm_1_external_tags = [
573-
'esxi_datacenter:dc2',
574-
'esxi_folder:folder_1',
575565
'esxi_type:vm',
576566
'esxi_url:127.0.0.1:8989',
577567
'esxi_host:localhost.localdomain',
578568
]
579569
vm_2_external_tags = [
580-
'esxi_cluster:c1',
581570
'esxi_compute:c1',
582571
'esxi_type:vm',
583572
'esxi_url:127.0.0.1:8989',
@@ -1216,8 +1205,6 @@ def test_use_configured_hostname(vcsim_instance, dd_run_check, aggregator, datad
12161205
'127.0.0.1:8989',
12171206
{
12181207
'esxi': [
1219-
'esxi_datacenter:dc2',
1220-
'esxi_folder:folder_1',
12211208
'esxi_type:host',
12221209
'esxi_url:127.0.0.1:8989',
12231210
]

0 commit comments

Comments
 (0)