Skip to content
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

Enable beats stack monitoring configuration #5878

Merged
merged 69 commits into from
Sep 26, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
c6b7287
Add stack monitoring for Beats
naemono Jun 22, 2022
165decd
When calling GetAssociations, also add the monitoring objects.
naemono Jun 29, 2022
c31c29d
Only access info after chedcking error
naemono Jun 30, 2022
de1cddc
Add debugging
naemono Jun 30, 2022
e14849d
Removing debugging logging statements
naemono Jul 11, 2022
23de080
Handling external, and internal monitoring refs the same.
naemono Jul 12, 2022
ec13b90
Fix unit test.
naemono Jul 15, 2022
a21aa92
Fix some issues with errorf formatting
naemono Jul 15, 2022
6101d4c
Merge branch 'main' into 5563-enable-beats-monitoring
naemono Jul 15, 2022
8991412
Add missing '/v2' to association package.
naemono Jul 18, 2022
02b0489
Optimize ssl/ca bits when creating monitoring configuration
naemono Jul 18, 2022
e517733
Add copyright to beat/common/monitoring.go
naemono Jul 18, 2022
42829d9
remove duplicative checks in beat e2e test
naemono Jul 18, 2022
94ebcf3
remove unused monitoringAssociationConnectionInfo
naemono Jul 18, 2022
77a205e
re-running generation, since wording changed in crds
naemono Jul 18, 2022
0ea5dfd
Avoid extra var in range in pkg/controller/beat/common/pod_test.go
naemono Jul 26, 2022
9831c38
Use new func in existing checks package to return beats monitoring st…
naemono Jul 26, 2022
b155d9d
Enabling webhook validation for beats stack monitoring.
naemono Jul 27, 2022
25702b7
Add unit tests for beat validation.
naemono Jul 27, 2022
2779620
Minor change in pod_test.go.
naemono Jul 27, 2022
2994d5f
Removing unneeded BeatsStep function.
naemono Jul 29, 2022
2c19f81
Moving to utilizing sidecars for beat monitoring instead of internal …
naemono Aug 2, 2022
4ae5d27
revert config/recipes changes
naemono Aug 2, 2022
06a3396
Fix early return in beats validation so that invalid monitoring refs …
naemono Aug 3, 2022
a175029
Ensure that beats http.port setting finds it's way all the way to the…
naemono Aug 3, 2022
ccf1323
Add missing metricbeat template yaml file.
naemono Aug 3, 2022
b9a0c6a
Adding missing header to new file.
naemono Aug 3, 2022
f21ff9c
running make generate crds
naemono Aug 4, 2022
7dc4bc9
Updating api docs
naemono Aug 4, 2022
d14893a
Update CRD documentation
naemono Aug 12, 2022
d901228
Correcting spelling
naemono Aug 15, 2022
3ae14e4
Add UUID to stack monitoring *beat configuration.
naemono Aug 15, 2022
268944b
Ensure metricbeat sidecar for beat has cluster_uuid.
naemono Aug 16, 2022
d5bb9b8
Add beats stackmon tests
naemono Aug 16, 2022
b57902e
Add newlines to yaml files
naemono Aug 16, 2022
c86c85e
Update beats stackmon validation to use same common validation
naemono Aug 16, 2022
025a30f
Update public docs.
naemono Aug 16, 2022
97125e5
Update api docs
naemono Aug 16, 2022
9bf98fe
Fix naming of static error.
naemono Aug 16, 2022
710575d
fixing ghost changes causing ci failures
naemono Aug 16, 2022
6840e41
Add changed yaml files vi automation thatss breaking ci
naemono Aug 16, 2022
734130d
adjust all-crds in opeartor chart
naemono Aug 16, 2022
1da13e0
Merge branch 'main' into 5563-enable-beats-monitoring
naemono Aug 17, 2022
0b5581f
Apply https://github.com/elastic/cloud-on-k8s/pull/5955 to try and ge…
naemono Aug 17, 2022
aea3d88
Add missing context to beat buildPodTemplate test.
naemono Aug 17, 2022
c710cd5
Revert change to deployer/runner/gke.go as it was merged.
naemono Aug 17, 2022
3a85f16
Merge branch 'main' into 5563-enable-beats-monitoring
naemono Aug 17, 2022
45fc97a
Move Monitoring objects to commonv1.
naemono Aug 22, 2022
23ae156
Add Keyed field to struct to pass linter.
naemono Aug 23, 2022
c646180
Merge branch 'main' into 5563-enable-beats-monitoring
naemono Aug 23, 2022
2975684
Fix moved struct from esv1 -> commonv1 in stackmon tests
naemono Aug 23, 2022
2182d40
Update api docs
naemono Aug 23, 2022
ca26311
Update test for new ssl verification mode for beats
naemono Aug 23, 2022
0e37cbb
wip
naemono Aug 27, 2022
fe83cee
Use unix sockets for beat metrics gather when stack monitoring is ena…
naemono Sep 1, 2022
d4ebba2
Merge branch 'main' into 5563-enable-beats-monitoring
naemono Sep 1, 2022
44a3d1e
Regenerate api docs
naemono Sep 1, 2022
8864c1c
Docs and CRD wording updates
naemono Sep 6, 2022
42535c0
Attempt remove specific path in filebeat.
naemono Sep 12, 2022
53e7dd1
Always uppercase stack monitoring in docs.
naemono Sep 12, 2022
a14eb20
running make docs, and go vet
naemono Sep 12, 2022
e3f965d
Do not log when ES cluster UUID isn't yet available, just emit event.
naemono Sep 14, 2022
ed04231
add shared volume for filebeat logs consumption
naemono Sep 15, 2022
0f99ccb
correct spelling in beat/*/stackmon.go
naemono Sep 15, 2022
f3bf6af
Ensure Beat doesn't contain '-e' startup option when log stack monito…
naemono Sep 15, 2022
bebdf6e
Fix beat configuration test for stackmon being enabled.
naemono Sep 19, 2022
52cd829
Ensure "-e" argument to *beat is removed if provided in podtemplate c…
naemono Sep 21, 2022
0cd89e2
Add documentation for the '-e' filebeat option being automatically re…
naemono Sep 21, 2022
0658e37
uppercase Filebeat
naemono Sep 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions test/e2e/test/beat/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,25 @@ func (b Builder) GetMetricsIndexPattern() string {
return ".monitoring-beat-*"
}

func (b Builder) Name() string {
return b.Beat.Name
}

func (b Builder) Namespace() string {
return b.Beat.Namespace
}

func (b Builder) GetMetricsCluster() *types.NamespacedName {
if len(b.Beat.Spec.Monitoring.ElasticsearchRefs) == 0 {
return nil
}
metricsCluster := b.Beat.Spec.Monitoring.ElasticsearchRefs[0].NamespacedName()
return &metricsCluster
}

// GetLogsCluster does not return a logs cluster, as Beats stack monitoring is slightly
// different that both Elasticsearch, and Kibana stack monitoring, as it uses internal
// beat collectors to send only metrics data, not logs data.
func (b Builder) GetLogsCluster() *types.NamespacedName {
return nil
}
37 changes: 0 additions & 37 deletions test/e2e/test/beat/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ import (
"fmt"
"io/ioutil"
"net/http"
"strconv"

beatcommon "github.com/elastic/cloud-on-k8s/v2/pkg/controller/beat/common"
"github.com/elastic/cloud-on-k8s/v2/pkg/controller/elasticsearch/client"
"github.com/elastic/cloud-on-k8s/v2/test/e2e/test/checks"
)

func HasEventFromBeat(name beatcommon.Type) ValidationFunc {
Expand Down Expand Up @@ -89,38 +87,3 @@ func checkEvent(url string, check func(int) error) ValidationFunc {
return check(len(results.Hits.Hits))
}
}

func containsDocuments(esClient client.Client, indexPattern string) error {
req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("/_cat/indices/%s?format=json", indexPattern), nil) //nolint:noctx
if err != nil {
return err
}
resp, err := esClient.Request(context.Background(), req)
if err != nil {
return err
}
defer resp.Body.Close()
resultBytes, err := ioutil.ReadAll(resp.Body)
if err != nil {
return err
}
var indices []checks.Index
err = json.Unmarshal(resultBytes, &indices)
if err != nil {
return err
}

// 1 index must exist
if len(indices) != 1 {
return fmt.Errorf("expected [%d] index [%s], found [%d]", 1, indexPattern, len(indices))
}
docsCount, err := strconv.Atoi(indices[0].DocsCount)
if err != nil {
return err
}
// with at least 1 doc
if docsCount <= 0 {
return fmt.Errorf("index [%s] empty", indexPattern)
}
return nil
}
31 changes: 2 additions & 29 deletions test/e2e/test/beat/steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/elastic/cloud-on-k8s/v2/pkg/utils/pointer"
"github.com/elastic/cloud-on-k8s/v2/test/e2e/cmd/run"
"github.com/elastic/cloud-on-k8s/v2/test/e2e/test"
"github.com/elastic/cloud-on-k8s/v2/test/e2e/test/checks"
"github.com/elastic/cloud-on-k8s/v2/test/e2e/test/elasticsearch"
"github.com/elastic/cloud-on-k8s/v2/test/e2e/test/generation"
)
Expand Down Expand Up @@ -184,7 +185,7 @@ func (b Builder) CheckStackTestSteps(k *test.K8sClient) test.StepList {
return nil
}),
},
b.CheckMonitoringMetricsIndex(k),
checks.BeatsMonitoredStep(&b, k),
}
}

Expand Down Expand Up @@ -253,31 +254,3 @@ func (b Builder) MutationTestSteps(k *test.K8sClient) test.StepList {
WithSteps(b.CheckStackTestSteps(k)).
WithStep(generation.CompareObjectGenerationsStep(&b.Beat, k, isMutated, beatGenerationBeforeMutation, beatObservedGenerationBeforeMutation))
}

func (b Builder) CheckMonitoringMetricsIndex(k *test.K8sClient) test.Step {
indexPattern := b.GetMetricsIndexPattern()
return test.Step{
Name: fmt.Sprintf("Check that documents are indexed in index %s", indexPattern),
Test: test.Eventually(func() error {
if b.GetMetricsCluster() == nil {
return nil
}
esMetricsRef := *b.GetMetricsCluster()
// Get Elasticsearch
esMetrics := esv1.Elasticsearch{}
if err := k.Client.Get(context.Background(), esMetricsRef, &esMetrics); err != nil {
return err
}
// Create a new Elasticsearch client
client, err := elasticsearch.NewElasticsearchClient(esMetrics, k)
if err != nil {
return err
}
// Check that there is at least one document
err = containsDocuments(client, indexPattern)
if err != nil {
return err
}
return nil
})}
}
11 changes: 11 additions & 0 deletions test/e2e/test/checks/monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ func MonitoredSteps(monitored Monitored, k8sClient *test.K8sClient) test.StepLis
}.Steps()
}

func BeatsMonitoredStep(monitored Monitored, k8sClient *test.K8sClient) test.Step {
return stackMonitoringChecks{
monitored: monitored,
k8sClient: k8sClient,
}.BeatsStep()
}

// stackMonitoringChecks tests that the monitored resource pods have 3 containers ready and that there are documents indexed in the beat indexes
// of the monitoring Elasticsearch clusters.
type stackMonitoringChecks struct {
Expand All @@ -51,6 +58,10 @@ func (c stackMonitoringChecks) Steps() test.StepList {
}
}

func (c stackMonitoringChecks) BeatsStep() test.Step {
return c.CheckMonitoringMetricsIndex()
naemono marked this conversation as resolved.
Show resolved Hide resolved
}

func (c stackMonitoringChecks) CheckBeatSidecars() test.Step {
return test.Step{
Name: "Check that beat sidecars are running",
Expand Down