-
Notifications
You must be signed in to change notification settings - Fork 1.9k
feat(kubernetes_logs source) support k8s API based logs #24007
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
Open
titaneric
wants to merge
35
commits into
vectordotdev:master
Choose a base branch
from
titaneric:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+455
−18
Open
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
bd06f70
publish and subscribe the pod info
titaneric 504e5a9
refactor pod subscriber and publisher into its own module
titaneric 2942b5d
implement `fetch_pod_logs` for pod subscriber
titaneric ce3044a
add basic reconciler for running pods
titaneric 0697f40
start reconciler after pod state is not empty
titaneric 18f6472
Run the reconciler once the pod state is initialized
titaneric 43dd5ca
launch LogTailer for container instead of pod level
titaneric bdc90e4
send the logs into channel
titaneric e42a5e4
stream log and record its timestamp
titaneric bceca79
rename symbol
titaneric ea5f81e
simplify key generation used in tracking container logs status
titaneric 96b7111
create new pod watcher for reconcile the logs
titaneric b847618
remove earlier introduced `init_notify` used to block the reconciler
titaneric 7595286
simplify key generation used in tracking container logs status
titaneric 2578ed5
transform the API logs into `Line` and send to out stream
titaneric 2e34730
pass log line by Bytes instead of String
titaneric 8a26708
convert log line in the reconciler
titaneric 3cc048c
tidy up change for easier review
titaneric 598b6f7
reference ContainerInfo in ContainerLogInfo
titaneric 5fdef9b
Merge branch 'vectordotdev:master' into master
titaneric 9cfd21a
update file_id used in API logs's reconciler
titaneric 8a1174c
fix clippy error
titaneric 8faaaf8
replace api_log with log_collection_strategy enum
titaneric 0483a77
execute file server or logs reconciler according to strategy setting
titaneric ffd36ab
broadcast pod events to reconciler
titaneric 9bcddfd
simplify the trait import
titaneric d9e7c9a
simplify the BroadcastStream
titaneric 8ebba32
push the pod forwarder into reflectors to abort if needed
titaneric 0667bcd
add batched log TODO
titaneric e0e51cd
Merge branch 'master' into master
titaneric 1ae2332
refactor the reconciler's pod state handling
titaneric 255bf93
use destructured `log_collection_strategy`
titaneric cbfb10a
remove dead code an unnecessary clone
titaneric 0f0a38e
take the buffer to avoid unnecessary clone
titaneric 0adfa7a
Merge branch 'vectordotdev:master' into master
titaneric File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use k8s_openapi::api::core::v1::Pod; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
/// Pod information struct that contains essential details for log fetching | ||
#[derive(Clone, Debug, Serialize, Deserialize, Eq, Hash, PartialEq)] | ||
pub struct PodInfo { | ||
/// Pod name | ||
pub name: String, | ||
/// Pod namespace | ||
pub namespace: String, | ||
/// Pod phase (Running, Pending, etc.) | ||
pub phase: Option<String>, | ||
/// Container names within the pod | ||
pub containers: Vec<String>, | ||
} | ||
|
||
impl From<&Pod> for PodInfo { | ||
fn from(pod: &Pod) -> Self { | ||
let metadata = &pod.metadata; | ||
|
||
let name = metadata.name.as_ref().cloned().unwrap_or_default(); | ||
|
||
let namespace = metadata.namespace.as_ref().cloned().unwrap_or_default(); | ||
|
||
let phase = pod.status.as_ref().and_then(|status| status.phase.clone()); | ||
|
||
let containers = pod | ||
.spec | ||
.as_ref() | ||
.map(|spec| { | ||
spec.containers | ||
.iter() | ||
.map(|container| container.name.clone()) | ||
.collect() | ||
}) | ||
.unwrap_or_default(); | ||
|
||
PodInfo { | ||
name, | ||
namespace, | ||
phase, | ||
containers, | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
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 know this is a ugly workaround. For more reasonable PR review size, I dropped the implementation of
FunctionTransform
trait forApi
here (which is very similar to how Cri handle the logs).