Add tag consul_node to consul service check consul.check from ConsulCheck.Node
What does this PR do?
Resolves #12609
Implements the tag consul_node with data from ConsulCheck["Node"] from response data consul_request('/v1/health/state/any') for Service Check consul.check (health check).
Motivation
See #12609
Additional Notes
I was unsuccessful at getting a tox test env setup with ddev after 1-hour spent trying.
I recommend that y'all quickly run the test ddev test consul to ensure that I copied the right node names such as consul_node:node-1 vs. consul_node:node-2 between the tests and mocks.
Review checklist (to be filled by reviewers)
- [ ] Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
- [ ] PR title must be written as a CHANGELOG entry (see why)
- [ ] Files changes must correspond to the primary purpose of the PR as described in the title (small unrelated changes should have their own PR)
- [ ] PR must have
changelog/andintegration/labels attached
Codecov Report
Merging #12675 (9c06d44) into master (dd899d7) will decrease coverage by
0.00%. The diff coverage is80.00%.
:exclamation: Current head 9c06d44 differs from pull request most recent head 5380e8a. Consider uploading reports for the commit 5380e8a to get more accurate results
| Flag | Coverage Δ | |
|---|---|---|
| consul | 91.64% <80.00%> (-0.11%) |
:arrow_down: |
Flags with carried forward coverage won't be shown. Click here to find out more.
@fanny-jiang Do you know where this auto-generated value consul_node:2ef5b089c318 comes from?
ServiceCheckStub(check_id=u'consul:fb2999b3507f3789', name=u'consul.check', status=0, tags=[u'check:serfHealth', u'consul_datacenter:dc1', u'consul_node:2ef5b089c318'], hostname=u'fv-az76-522', message=u'')
I spent about an hour trying to track down how the def test_e2e(dd_agent_check, [...] is called or how dd_agent_check (the aggregator) is built, but I was unsuccessful.
Places I looked:
-
consul/ -
ddev ci setupand code -
.azure-pipelines/
@fanny-jiang Do you know where this auto-generated value
consul_node:2ef5b089c318comes from?
@hjkatz I've taken a look and it seems that the value is coming from the first Node value returned from this health/state request: https://github.com/DataDog/integrations-core/blob/da0178e8e830b4f8ffb2b3809250cb5aaafa3c7c/consul/datadog_checks/consul/consul.py#L356
You should be able to get the value like so:
check = ConsulCheck('consul', {}, [instance_single_node_install])
node_id = check.consul_request('/v1/health/state/any')[0]['Node']
Those lines can go here, right above aggregator.
@fanny-jiang Ok, so I took your comment and dug a bit further. I found out that the auto-generated node name comes from Consul and its agent by default when the cluster comes online. So I fiddled around with the consul/tests/compose/ directory and files within to figure out where to add explicit node names via -node=<name> CLI flag for the consul agent command.
Everything should be passing now.