Autodiscover provider for Nomad#14954
Merged
jsoriano merged 91 commits intoelastic:masterfrom Jan 7, 2021
Merged
Conversation
Add a test for the basic hint features
Add tests for the emition of events
Add tests for the emition of events
…autodiscovery-nomad
…llocations Add local constants to track the possible status of the allocations
On older nomad versions (0.8.4) the `NodeName` attribute of the allocation is empty. This means that sometimes we cannot assign a proper `host` to the event. As a workaround we use the `NodeID` to get the the name from the actual client node.
This is a workaround for Nomad v0.8 that doesn't provide the NodeName directly in the allocation object. We use the NodeID to fetch it from the API.
Remove debug statement
- WIP emit only one task metadata event. - Rename the matchers/indexers of the add_nomad_metadata processor to match the Nomad lingo.
- Rename `meta.meta` to `meta.tasks` and fix the tests. - Add the main import to the nomad provider in the cmd tool.
WIP patch for the unchanged allocations and avoids triggering new harvesters for those allocations that were previously discovered.
- Rename `uuid` field to `alloc_id`. - Use WatchOptions.RefreshInterval (SyncInterval on the config) for the sync interval of the watcher
Member
|
jenkins run the tests please |
jsoriano
approved these changes
Jan 5, 2021
Contributor
Author
|
@jsoriano I cherry-picked the changes from your branch, but I'm ok if we merge from any side. Thanks for taking care of fixing those issues (especially the Windows test). Changes look great! I was planning on jumping into this after the holidays but glad that you were faster! |
Member
|
@jorgelbg could you please update the branch with master? Failing tests were fixed yesterday. |
Member
|
jenkins run the tests please |
Member
|
Merged, thanks a lot @jorgelbg! |
4 tasks
jsoriano
added a commit
to jsoriano/beats
that referenced
this pull request
Jan 7, 2021
Initial features to support logs collection from applications deployed in Nomad. Add a new `nomad` autodiscover provider (based on the Kubernetes provider). With this new provider, it is possible to start new harvesters by looking at the jobs allocated on each node. With this, filebeat can be run as a system job on each node and each filebeat instance is responsible for enriching and shipping the local logs. This autodiscover provider supports hints-based autodiscover. Add a new `add_nomad_metadata` processor that matches events to specific allocations and adds the metadata. Co-authored-by: Jaime Soriano Pastor <jaime.soriano@elastic.co> (cherry picked from commit 24397d8)
Contributor
|
Thank you all for working on this! |
jsoriano
added a commit
that referenced
this pull request
Jan 7, 2021
Initial features to support logs collection from applications deployed in Nomad. Add a new `nomad` autodiscover provider (based on the Kubernetes provider). With this new provider, it is possible to start new harvesters by looking at the jobs allocated on each node. With this, filebeat can be run as a system job on each node and each filebeat instance is responsible for enriching and shipping the local logs. This autodiscover provider supports hints-based autodiscover. Add a new `add_nomad_metadata` processor that matches events to specific allocations and adds the metadata. (cherry picked from commit 24397d8) Co-authored-by: Jaime Soriano Pastor <jaime.soriano@elastic.co> Co-authored-by: Jorge Luis Betancourt <jorge-luis.betancourt@trivago.com>
This was referenced Jun 28, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
At trivago we run an internal cloud using Nomad from Hashicorp. Our logging solution is based on ELK and we use Filebeat to ship the logs from our client nodes into Kafka where it is later on ingested into Elasticsearch using Logstash. Previously we used the and input looking for new jobs in a defined
path, but the logs lacked a lot of context/metadata from the Job definition/allocation.This PR adds a new discover module (architecture based on the Kubernetes module). With this new provider, it is possible to start new harvesters by looking at the jobs allocated on each node. We currently run filebeat as a system job on each node and each filebeat instance is responsible for enriching and shipping the local logs.
Example of the configuration for the new provider:
By using the autodiscover module it is possible to define custom processors using the
metastanza on the Nomad job (similar to how it is defined using labels on Kubernetes). For instance:This example defines a custom
dissecttokenizer for the logs of this specific task that adds thedissectfield with a content similar to:By default the following fields are added from the Nomad job/allocation:
jobnamespacestatustype(job type: system/service/batch)task.*(information about the task and custom metadata defined in the job/group/task using themetastanza)datacentersregionThe PR also includes an
add_nomad_metadataprocessor that matches events to specific allocations and adds the metadata.We've been running this in our production clusters for a few weeks now.
TODO:
How to test locally
nomad agent -dev).