-
Notifications
You must be signed in to change notification settings - Fork 197
[8.18](backport #7995) Enable Filebeat's Journald input in some docker image variants #8482
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
766b71d
Enable Filebeat's Journald input in some docker image variants (#7995)
belimawr 698f3ce
Fix merge conflicts
belimawr d071150
Update env var usage
belimawr 2113ef9
Merge branch '8.18' of github.com:elastic/elastic-agent into mergify/…
belimawr 9a16de2
Only install jounralctl in the complete variant
belimawr 37a4769
Merge branch '8.18' into mergify/bp/8.18/pr-7995
pkoutsovasilis 4d4c251
remove basic variant from TestKubernetesJournaldInput
pkoutsovasilis 968f123
remove TestKubernetesJournaldInputOtel as edot collector variant is n…
pkoutsovasilis 5eb1ddb
Update changelog/fragments/1745609163-journalctl-on-all-docker-varian…
belimawr 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
35 changes: 35 additions & 0 deletions
35
changelog/fragments/1745609163-journalctl-on-all-docker-variants.yaml
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,35 @@ | ||
# Kind can be one of: | ||
# - breaking-change: a change to previously-documented behavior | ||
# - deprecation: functionality that is being removed in a later release | ||
# - bug-fix: fixes a problem in a previous version | ||
# - enhancement: extends functionality but does not break or fix existing behavior | ||
# - feature: new functionality | ||
# - known-issue: problems that we are aware of in a given version | ||
# - security: impacts on the security of a product or a user’s deployment. | ||
# - upgrade: important information for someone upgrading from a prior version | ||
# - other: does not fit into any of the other categories | ||
kind: bug-fix | ||
|
||
# Change summary; a 80ish characters long description of the change. | ||
summary: | | ||
Ship journalctl in the elastic-agent, elastic-agent-complete, and | ||
elastic-otel-collector Docker images to enable reading journald | ||
logs. Journalctl is not present on *-slim and all Wolfi images. | ||
|
||
# Long description; in case the summary is not enough to describe the change | ||
# this field accommodate a description without length limits. | ||
# NOTE: This field will be rendered only for breaking-change and known-issue kinds at the moment. | ||
#description: | ||
|
||
# Affected component; usually one of "elastic-agent", "fleet-server", "filebeat", "metricbeat", "auditbeat", "all", etc. | ||
component: elastic-agent | ||
|
||
# PR URL; optional; the PR number that added the changeset. | ||
# If not present is automatically filled by the tooling finding the PR where this changelog fragment has been added. | ||
# NOTE: the tooling supports backports, so it's able to fill the original PR number instead of the backport PR number. | ||
# Please provide it if you are adding a fragment for a different PR. | ||
pr: https://github.com/elastic/elastic-agent/pull/7995 | ||
|
||
# Issue URL; optional; the GitHub issue related to this changeset (either closes or is part of). | ||
# If not present is automatically filled by the tooling with the issue linked to the PR number. | ||
issue: https://github.com/elastic/beats/issues/44040 |
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,150 @@ | ||
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
// or more contributor license agreements. Licensed under the Elastic License 2.0; | ||
// you may not use this file except in compliance with the Elastic License 2.0. | ||
|
||
//go:build integration | ||
|
||
package integration | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
corev1 "k8s.io/api/core/v1" | ||
"sigs.k8s.io/e2e-framework/klient/k8s" | ||
|
||
"github.com/elastic/elastic-agent-libs/testing/estools" | ||
"github.com/elastic/elastic-agent/pkg/testing/define" | ||
"github.com/elastic/go-elasticsearch/v8" | ||
) | ||
|
||
func TestKubernetesJournaldInput(t *testing.T) { | ||
info := define.Require(t, define.Requirements{ | ||
Stack: &define.Stack{}, | ||
Local: false, | ||
Sudo: false, | ||
OS: []define.OS{ | ||
{Type: define.Kubernetes, DockerVariant: "complete"}, | ||
}, | ||
Group: define.Kubernetes, | ||
}) | ||
|
||
agentConfigYAML, err := os.ReadFile(filepath.Join("testdata", "journald-input.yml")) | ||
require.NoError(t, err, "failed to read journald input template") | ||
|
||
ctx := context.Background() | ||
kCtx := k8sGetContext(t, info) | ||
|
||
schedulableNodeCount, err := k8sSchedulableNodeCount(ctx, kCtx) | ||
require.NoError(t, err, "error at getting schedulable node count") | ||
require.NotZero(t, schedulableNodeCount, "no schedulable Kubernetes nodes found") | ||
|
||
namespace := kCtx.getNamespace(t) | ||
hostPathType := corev1.HostPathDirectory | ||
|
||
steps := []k8sTestStep{ | ||
k8sStepCreateNamespace(), | ||
k8sStepDeployKustomize( | ||
agentK8SKustomize, | ||
"elastic-agent-standalone", | ||
k8sKustomizeOverrides{ | ||
agentContainerExtraEnv: []corev1.EnvVar{ | ||
{ | ||
Name: "ELASTICSEARCH_USERNAME", | ||
Value: os.Getenv("ELASTICSEARCH_USERNAME"), | ||
}, | ||
{ | ||
Name: "ELASTICSEARCH_PASSWORD", | ||
Value: os.Getenv("ELASTICSEARCH_PASSWORD"), | ||
}, | ||
{ | ||
Name: "EA_POLICY_NAMESPACE", | ||
Value: namespace, | ||
}, | ||
}, | ||
agentContainerVolumeMounts: []corev1.VolumeMount{ | ||
{ | ||
Name: "journald-mount", | ||
MountPath: "/opt/journald", | ||
ReadOnly: true, | ||
}, | ||
}, | ||
agentPodVolumes: []corev1.Volume{ | ||
{ | ||
Name: "journald-mount", | ||
VolumeSource: corev1.VolumeSource{ | ||
HostPath: &corev1.HostPathVolumeSource{ | ||
Path: "/run/log/journal", | ||
Type: &hostPathType, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
func(obj k8s.Object) { | ||
// update the configmap to use the journald input | ||
switch objWithType := obj.(type) { | ||
case *corev1.ConfigMap: | ||
_, ok := objWithType.Data["agent.yml"] | ||
if ok { | ||
objWithType.Data["agent.yml"] = string(agentConfigYAML) | ||
} | ||
} | ||
|
||
}), | ||
k8sStepCheckAgentStatus( | ||
"app=elastic-agent-standalone", | ||
schedulableNodeCount, | ||
"elastic-agent-standalone", | ||
map[string]bool{ | ||
"journald": true, | ||
}), | ||
} | ||
|
||
journaldTest( | ||
t, | ||
info.ESClient, | ||
kCtx, | ||
steps, | ||
fmt.Sprintf("logs-generic-%s", namespace), | ||
"input.type", | ||
"journald") | ||
} | ||
|
||
func journaldTest( | ||
t *testing.T, | ||
esClient *elasticsearch.Client, | ||
kCtx k8sContext, | ||
steps []k8sTestStep, | ||
index, field, value string) { | ||
t.Helper() | ||
|
||
ctx := context.Background() | ||
testNamespace := kCtx.getNamespace(t) | ||
|
||
for _, step := range steps { | ||
step(t, ctx, kCtx, testNamespace) | ||
} | ||
|
||
// Check if the context was cancelled or timed out | ||
if ctx.Err() != nil { | ||
t.Errorf("context error: %v", ctx.Err()) | ||
} | ||
|
||
// Query the index and filter by the input type | ||
docs := findESDocs(t, func() (estools.Documents, error) { | ||
return estools.GetLogsForIndexWithContext( | ||
ctx, | ||
esClient, | ||
index, | ||
map[string]any{ | ||
field: value, | ||
}, | ||
) | ||
}) | ||
require.NotEmpty(t, docs, "expected logs to be found in Elasticsearch") | ||
} |
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,22 @@ | ||
outputs: | ||
default: | ||
type: elasticsearch | ||
hosts: | ||
- ${ES_HOST} | ||
username: ${ELASTICSEARCH_USERNAME} | ||
password: ${ELASTICSEARCH_PASSWORD} | ||
|
||
agent: | ||
monitoring: | ||
enabled: false | ||
|
||
inputs: | ||
- id: journald | ||
log_level: debug | ||
type: journald | ||
data_stream: | ||
namespace: ${env.EA_POLICY_NAMESPACE} | ||
streams: | ||
- id: journald-input-id | ||
paths: | ||
- "/opt/journald/*/*" |
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.