-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logging code cleanup related to Nomad auto-discovery #26498
Conversation
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
Trends 🧪💚 Flaky test reportTests succeeded. Expand to view the summary
Test stats 🧪
|
run tests |
enabled: false | ||
type: log | ||
paths: | ||
- /opt/nomad/alloc/${data.nomad.allocation.id}/alloc/logs/${data.nomad.task.name}.* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a semi-related note about this path template (sorry if slightly off-topic)- when testing out this feature I noticed that the task.name
data was only being published on the meta.nomad
field of the event, not the nomad
field used in this example. Here's the relevant code:
beats/x-pack/libbeat/autodiscover/providers/nomad/nomad.go
Lines 197 to 210 in 076e0a6
event := bus.Event{ | |
"provider": p.uuid, | |
"id": fmt.Sprintf("%s-%s", obj.ID, task["name"]), | |
flag: true, | |
"host": nodeName, | |
"nomad": allocMeta, | |
"meta": common.MapStr{ | |
"nomad": common.MapStrUnion(allocMeta, common.MapStr{ | |
"task": task, | |
}), | |
}, | |
} | |
p.publish(event) |
In my tests,
${data.nomad.task.name}
gave an invalid template reference error, but ${data.meta.nomad.task.name}
resolved properly. Does this sound correct and if so, should all the documentation examples be updated to reflect this working usage? Or does a separate PR to fix the existing examples make more sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When testing I noted that there was a lot of duplicate information in the autodiscover events that get published by that code. But I wasn't sure what the expected behavior was. And now that you bring it up, I see that there are docs for what should be in the events at https://www.elastic.co/guide/en/beats/filebeat/current/configuration-autodiscover.html#_nomad. So based on those docs I think I could change this and fix the missing nomad.task
fields. Can you open a separate issue please?
Here's a sample document taken from the updated debug logs I added.
{
"autodiscover.event": {
"provider": "d4bc811c-9039-44a5-be01-fd60b08c1a6a",
"meta": {
"nomad": {
"namespace": "default",
"allocation": {
"name": "hello-world.servers[0]",
"id": "64782844-aedc-4acb-b72d-30dfe7f7939d",
"status": "running"
},
"datacenter": [
"va"
],
"task": {
"name": "hello-world"
},
"region": "global",
"job": {
"name": "hello-world",
"type": "service"
}
}
},
"host": "compute01",
"start": true,
"id": "64782844-aedc-4acb-b72d-30dfe7f7939d-hello-world",
"nomad": {
"namespace": "default",
"allocation": {
"name": "hello-world.servers[0]",
"id": "64782844-aedc-4acb-b72d-30dfe7f7939d",
"status": "running"
},
"datacenter": [
"va"
],
"region": "global",
"job": {
"name": "hello-world",
"type": "service"
}
},
"config": []
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you open a separate issue please?
Opened #26538.
But I wasn't sure what the expected behavior was.
It turns out there was some discussion around the need for this duplicate information in the original PR- see #14954 (comment).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great find. So based on that comment it sounds like we need to keep both meta
and nomad
. But we can make sure all the documented keys are present under the nomad.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
I think only the nomad
fields need to be available for config templates. The meta fields are used for enrichment, but shouldn't be necessarily available for templates. We probably messed something up in the original PR, I remember going back and forth on this 😬
We also have to double-check that hints based configs have the same fields available.
Note to self, two other things to fix:
|
61a53e0
to
ea6ba46
Compare
Pinging @elastic/integrations (Team:Integrations) |
run tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Glad to see some activity around nomad 🙂
* Logging and code cleanup related to Nomad auto-discover * Fix a few doc nits * Update heartbeat log line assertion * Add complete example with discovery and add_nomad_metadata * Fix secret_id and document minimal ACL policy Closes #26456 (cherry picked from commit b061836) Co-authored-by: Andrew Kroh <andrew.kroh@elastic.co>
…arwin-arm64 * upstream/master: (295 commits) Update urllib to 1.26.5. (elastic#26380) Update golang.org/x/crypto (elastic#26448) [Filebeat] Update Fortinet Ingest Pipeline (elastic#24816) Move parsers outside of filestream input so others can use them as well (elastic#26541) [Filebeat] Fix `threatintel.indicator.url.full` field not populating (elastic#26508) [Filebeat] Add network direction processor to Zeek and Suricata modules (elastic#24620) Logging code cleanup related to Nomad auto-discovery (elastic#26498) [Metricbeat] Add Couchbase's Sync Gateway module (elastic#25599) Refactor add_cloud_metadata to handle ECS fields easier (elastic#26438) [Elastic Agent] Improper casting of int64 (elastic#26520) [Elastic Agent] Enable configuring monitoring namespace (elastic#26439) [Heartbeat] configure permissions for synthetics config (elastic#26393) Osquerybeat: set the raw index name to supress the timestamp suffix (elastic#26545) [Heartbeat] add screenshots config to synthetics (elastic#26455) [Elastic Agent] Use http2 to connect to Fleet Server. (elastic#26474) Remove all docs about Beats central management (elastic#26399) update data.json for gcp billing (elastic#26506) Skip x-pack metricbeat tests (elastic#26537) [Elastic Agent] Fix issue with FLEET_CA not being used with Fleet Server in container (elastic#26529) Add changelog entry for elastic#26224 (elastic#26531) ...
* master: (25 commits) fix: Force PLATFORMS environment variable when we build Elastic Agent dependencies on arm64 (elastic#26415) macos for metricbeat to run in the extended meta-stage (elastic#26573) Packaging: add arm7 platform in the main pipeline (elastic#26575) [Heartbeat] Skip flakey timer queue test (elastic#26592) Update to "read_pipeline" permission (elastic#26465) (elastic#26580) API keys do not reflect the need for read_pipeline (elastic#26466) (elastic#26582) Add Fleet agent.id to Agent monitoring data (elastic#26548) Add kinesis metricset (elastic#25989) Refactor of system/memory metricset (elastic#26334) Introduce httpcommon package in libbeat (add support for Proxy) (elastic#25219) [Filebeat] change multiline configuration in awss3 input to parsers (elastic#25873) docs: Hint for the error "Error extracting container id" (elastic#25824) [Docs] Fixed metricbeat redis exported field CPU descriptions (elastic#25846) (elastic#26496) Update urllib to 1.26.5. (elastic#26380) Update golang.org/x/crypto (elastic#26448) [Filebeat] Update Fortinet Ingest Pipeline (elastic#24816) Move parsers outside of filestream input so others can use them as well (elastic#26541) [Filebeat] Fix `threatintel.indicator.url.full` field not populating (elastic#26508) [Filebeat] Add network direction processor to Zeek and Suricata modules (elastic#24620) Logging code cleanup related to Nomad auto-discovery (elastic#26498) ...
What does this PR do?
This does some minor clean up of the logging code and docs related to Nomad. I removed some statements that were providing duplicate information and switched a few over to using the structured logger to improve log readability.
A log message about
enabled
not being parsed was always being logged despite no actual error.The doc examples were trying to start a Filebeat input with
type: nomad
.Fixed some typos in code comments.
Why is it important?
This make debugging a little more enjoyable 😆 .
Checklist
- [ ] I have commented my code, particularly in hard-to-understand areas- [ ] I have made corresponding change to the default configuration files- [ ] I have added tests that prove my fix is effective or that my feature works- [ ] I have added an entry inCHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Related issues