From 60bb0f0dd5fff3c9317b6790fe4a035f99dc0642 Mon Sep 17 00:00:00 2001 From: "Lee E. Hinman" Date: Thu, 15 Jun 2023 16:23:46 -0500 Subject: [PATCH] update status command - change to list format for human output - change human to only report top level status if all components and units are healthy - change human to report full status for component if any unit or component itself is not healthy - add `human_full` which always displays full status - sort components and units so order will always be the same Closes #2107 Closes #2829 --- go.mod | 3 + go.sum | 9 ++ internal/pkg/agent/cmd/status.go | 129 +++++++++++---- internal/pkg/agent/cmd/status_test.go | 150 ++++++++++++++++++ .../agent/cmd/testdata/status/human_degraded | 10 ++ .../cmd/testdata/status/human_full_degraded | 24 +++ .../cmd/testdata/status/human_full_healthy | 24 +++ .../agent/cmd/testdata/status/human_healthy | 4 + pkg/testing/tools/artifacts_api.go | 4 + pkg/testing/tools/artifacts_api_test.go | 4 + testing/fleetservertest/checkin.go | 4 + testing/fleetservertest/fleetserver.go | 4 + testing/fleetservertest/fleetserver_test.go | 4 + testing/fleetservertest/handlers.go | 4 + testing/fleetservertest/models.go | 4 + testing/fleetservertest/server.go | 4 + 16 files changed, 350 insertions(+), 35 deletions(-) create mode 100644 internal/pkg/agent/cmd/status_test.go create mode 100644 internal/pkg/agent/cmd/testdata/status/human_degraded create mode 100644 internal/pkg/agent/cmd/testdata/status/human_full_degraded create mode 100644 internal/pkg/agent/cmd/testdata/status/human_full_healthy create mode 100644 internal/pkg/agent/cmd/testdata/status/human_healthy diff --git a/go.mod b/go.mod index bc7aa2cf751..d8ddd0a30a6 100644 --- a/go.mod +++ b/go.mod @@ -29,6 +29,7 @@ require ( github.com/gorilla/mux v1.8.0 github.com/hashicorp/go-multierror v1.1.1 github.com/hectane/go-acl v0.0.0-20190604041725-da78bae5fc95 + github.com/jedib0t/go-pretty/v6 v6.4.6 github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 github.com/josephspurrier/goversioninfo v0.0.0-20190209210621-63e6d1acd3dd github.com/kardianos/service v1.2.1-0.20210728001519-a323c3813bc7 @@ -108,6 +109,7 @@ require ( github.com/markbates/pkger v0.17.0 // indirect github.com/mattn/go-colorable v0.1.12 // indirect github.com/mattn/go-isatty v0.0.16 // indirect + github.com/mattn/go-runewidth v0.0.13 // indirect github.com/mitchellh/iochan v1.0.0 // indirect github.com/moby/spdystream v0.2.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -118,6 +120,7 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect github.com/prometheus/procfs v0.9.0 // indirect + github.com/rivo/uniseg v0.2.0 // indirect github.com/rogpeppe/go-internal v1.8.1 // indirect github.com/santhosh-tekuri/jsonschema v1.2.4 // indirect github.com/sergi/go-diff v1.1.0 // indirect diff --git a/go.sum b/go.sum index 8cc68c43ee6..fe2f136f04c 100644 --- a/go.sum +++ b/go.sum @@ -768,6 +768,8 @@ github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i github.com/jcchavezs/porto v0.1.0 h1:Xmxxn25zQMmgE7/yHYmh19KcItG81hIwfbEEFnd6w/Q= github.com/jcchavezs/porto v0.1.0/go.mod h1:fESH0gzDHiutHRdX2hv27ojnOVFco37hg1W6E9EZF4A= github.com/jedib0t/go-pretty v4.3.0+incompatible/go.mod h1:XemHduiw8R651AF9Pt4FwCTKeG3oo7hrHJAoznj9nag= +github.com/jedib0t/go-pretty/v6 v6.4.6 h1:v6aG9h6Uby3IusSSEjHaZNXpHFhzqMmjXcPq1Rjl9Jw= +github.com/jedib0t/go-pretty/v6 v6.4.6/go.mod h1:Ndk3ase2CkQbXLLNf5QDHoYb6J9WtVfmHZu9n8rk2xs= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= @@ -890,6 +892,8 @@ github.com/mattn/go-oci8 v0.1.1/go.mod h1:wjDx6Xm9q7dFtHJvIlrI99JytznLw5wQ4R+9mN github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= +github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= +github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-shellwords v1.0.3/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vqg+NOMyg4B2o= github.com/mattn/go-shellwords v1.0.6/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vqg+NOMyg4B2o= github.com/mattn/go-shellwords v1.0.12/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lLtQsUlTZDWQ8Y= @@ -1043,6 +1047,7 @@ github.com/pkg/errors v0.8.1-0.20171018195549-f15c970de5b7/go.mod h1:bwawxfHBFNV github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/profile v1.6.0/go.mod h1:qBsxPvzyUincmltOk6iyRVxHYg4adc0OFOv72ZdLa18= github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -1089,6 +1094,8 @@ github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1 github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= +github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= +github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= @@ -1190,6 +1197,7 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.4/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= @@ -1631,6 +1639,7 @@ golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU= golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= diff --git a/internal/pkg/agent/cmd/status.go b/internal/pkg/agent/cmd/status.go index a4b6b95764a..57642b049c7 100644 --- a/internal/pkg/agent/cmd/status.go +++ b/internal/pkg/agent/cmd/status.go @@ -10,7 +10,7 @@ import ( "fmt" "io" "os" - "text/tabwriter" + "sort" "time" "github.com/elastic/elastic-agent/pkg/control/v2/client" @@ -19,6 +19,8 @@ import ( "github.com/spf13/cobra" + "github.com/jedib0t/go-pretty/v6/list" + "github.com/elastic/elastic-agent/internal/pkg/agent/errors" "github.com/elastic/elastic-agent/internal/pkg/cli" ) @@ -26,9 +28,10 @@ import ( type outputter func(io.Writer, interface{}) error var statusOutputs = map[string]outputter{ - "human": humanStateOutput, - "json": jsonOutput, - "yaml": yamlOutput, + "human": humanOutput, + "human_full": humanFullOutput, + "json": jsonOutput, + "yaml": yamlOutput, } func newStatusCommand(_ []string, streams *cli.IOStreams) *cobra.Command { @@ -44,7 +47,7 @@ func newStatusCommand(_ []string, streams *cli.IOStreams) *cobra.Command { }, } - cmd.Flags().String("output", "human", "Output the status information in either human, json, or yaml (default: human)") + cmd.Flags().String("output", "human", "Output the status information in either 'human', 'human_full', 'json', or 'yaml'. 'human' only shows non-healthy details, others show full details. (default: human)") return cmd } @@ -69,6 +72,10 @@ func statusCmd(streams *cli.IOStreams, cmd *cobra.Command, args []string) error return fmt.Errorf("failed to communicate with Elastic Agent daemon: %w", err) } + sort.SliceStable(state.Components, func(i, j int) bool { return state.Components[i].ID < state.Components[j].ID }) + for _, c := range state.Components { + sort.SliceStable(c.Units, func(i, j int) bool { return c.Units[i].UnitID < c.Units[j].UnitID }) + } err = outputFunc(streams.Out, state) if err != nil { return err @@ -82,43 +89,95 @@ func statusCmd(streams *cli.IOStreams, cmd *cobra.Command, args []string) error return nil } -func humanStateOutput(w io.Writer, obj interface{}) error { +func formatStatus(state client.State, message string) string { + return fmt.Sprintf("status: (%s) %s", state, message) +} + +func listComponentState(l list.Writer, components []client.ComponentState, all bool) { + for _, c := range components { + // see if any unit is not Healthy because component + // can be healthy with failed units + units_healthy := true + for _, u := range c.Units { + if u.State != client.Healthy { + units_healthy = false + break + } + } + if !all && units_healthy && (c.State == client.Healthy) { + continue + } + l.Indent() + l.AppendItem(c.ID) + l.Indent() + l.AppendItem(formatStatus(c.State, c.Message)) + l.UnIndent() + for _, u := range c.Units { + if !all && (u.State == client.Healthy) { + continue + } + l.Indent() + l.AppendItem(u.UnitID) + l.Indent() + l.AppendItem(formatStatus(u.State, u.Message)) + if all { + l.AppendItem(fmt.Sprintf("type: %s", u.UnitType)) + } + l.UnIndent() + l.UnIndent() + } + l.UnIndent() + l.UnIndent() + } +} + +func listAgentState(l list.Writer, state *client.AgentState, all bool) { + l.AppendItem("elastic-agent") + l.Indent() + l.AppendItem(formatStatus(state.State, state.Message)) + if all { + l.AppendItem("info") + l.Indent() + l.AppendItem("id: " + state.Info.ID) + l.AppendItem("version: " + state.Info.Version) + l.AppendItem("commit: " + state.Info.Commit) + l.UnIndent() + } + l.UnIndent() + listComponentState(l, state.Components, all) +} + +func listFleetState(l list.Writer, state *client.AgentState, all bool) { + l.AppendItem("fleet") + l.Indent() + l.AppendItem(formatStatus(state.FleetState, state.FleetMessage)) + l.UnIndent() +} + +func humanListOutput(w io.Writer, state *client.AgentState, all bool) error { + l := list.NewWriter() + l.SetStyle(list.StyleConnectedLight) + l.SetOutputMirror(w) + listFleetState(l, state, all) + listAgentState(l, state, all) + _ = l.Render() + return nil +} + +func humanFullOutput(w io.Writer, obj interface{}) error { status, ok := obj.(*client.AgentState) if !ok { return fmt.Errorf("unable to cast %T as *client.AgentStatus", obj) } - return outputState(w, status) + return humanListOutput(w, status, true) } -func outputState(w io.Writer, state *client.AgentState) error { - fmt.Fprintf(w, "State: %s\n", state.State) - if state.Message == "" { - fmt.Fprint(w, "Message: (no message)\n") - } else { - fmt.Fprintf(w, "Message: %s\n", state.Message) - } - fmt.Fprintf(w, "Fleet State: %s\n", state.FleetState) - if state.FleetMessage == "" { - fmt.Fprint(w, "Fleet Message: (no message)\n") - } else { - fmt.Fprintf(w, "Fleet Message: %s\n", state.FleetMessage) - } - if len(state.Components) == 0 { - fmt.Fprint(w, "Components: (none)\n") - } else { - fmt.Fprint(w, "Components:\n") - tw := tabwriter.NewWriter(w, 4, 1, 2, ' ', 0) - for _, comp := range state.Components { - fmt.Fprintf(tw, " * %s\t(%s)\n", comp.Name, comp.State) - if comp.Message == "" { - fmt.Fprint(tw, "\t(no message)\n") - } else { - fmt.Fprintf(tw, "\t%s\n", comp.Message) - } - } - tw.Flush() +func humanOutput(w io.Writer, obj interface{}) error { + status, ok := obj.(*client.AgentState) + if !ok { + return fmt.Errorf("unable to cast %T as *client.AgentStatus", obj) } - return nil + return humanListOutput(w, status, false) } func jsonOutput(w io.Writer, out interface{}) error { diff --git a/internal/pkg/agent/cmd/status_test.go b/internal/pkg/agent/cmd/status_test.go new file mode 100644 index 00000000000..6809d771126 --- /dev/null +++ b/internal/pkg/agent/cmd/status_test.go @@ -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; +// you may not use this file except in compliance with the Elastic License. + +package cmd + +import ( + "bytes" + "os" + "path/filepath" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/elastic/elastic-agent/pkg/control/v2/client" +) + +func TestHumanOutput(t *testing.T) { + var b bytes.Buffer + stateDegraded := &client.AgentState{ + Info: client.AgentStateInfo{ + ID: "9a4921cc-36d4-4b5a-9395-9ec2d204862e", + Version: "8.8.0", + Commit: "adf44ef2c6dfc56b5e60400ecdfbf46ceda5a6f4", + BuildTime: "2023-05-24 00:01:09 +0000 UTC", + Snapshot: false, + }, + State: client.Degraded, + Message: "1 or more components/units in a failed state", + FleetState: client.Healthy, + FleetMessage: "Connected", + Components: []client.ComponentState{ + { + ID: "log-default", + Name: "log", + State: client.Healthy, + Message: "Healthy: communicating with pid '1813'", + Units: []client.ComponentUnitState{ + { + UnitID: "log-default-logfile-system-7bc17120-0951-11ee-bd02-734625f2144c", + UnitType: client.UnitTypeInput, + State: client.Healthy, + Message: "Healthy", + }, + { + UnitID: "log-default", + UnitType: client.UnitTypeOutput, + State: client.Healthy, + Message: "Healthy", + }, + }, + }, + { + ID: "httpjson-default", + Name: "httpjson", + State: client.Healthy, + Message: "Healthy communicating with pid '2875'", + Units: []client.ComponentUnitState{ + { + UnitID: "httpjson-default-httpjson-generic-ca7fa460-0bab-11ee-8598-c3f64dd59b06", + UnitType: client.UnitTypeInput, + State: client.Failed, + Message: "[failed to reloading inputs: 1 error: Error creating runner from config: required 'object', but found 'string' in field 'processors.6']", + }, + { + UnitID: "httpjson-default", + UnitType: client.UnitTypeOutput, + State: client.Failed, + Message: "[failed to reloading inputs: 1 error: Error creating runner from config: required 'object', but found 'string' in field 'processors.6']", + }, + }, + }, + }, + } + stateHealthy := &client.AgentState{ + Info: client.AgentStateInfo{ + ID: "9a4921cc-36d4-4b5a-9395-9ec2d204862e", + Version: "8.8.0", + Commit: "adf44ef2c6dfc56b5e60400ecdfbf46ceda5a6f4", + BuildTime: "2023-05-24 00:01:09 +0000 UTC", + Snapshot: false, + }, + State: client.Healthy, + Message: "Running", + FleetState: client.Healthy, + FleetMessage: "Connected", + Components: []client.ComponentState{ + { + ID: "log-default", + Name: "log", + State: client.Healthy, + Message: "Healthy: communicating with pid '1813'", + Units: []client.ComponentUnitState{ + { + UnitID: "log-default-logfile-system-7bc17120-0951-11ee-bd02-734625f2144c", + UnitType: client.UnitTypeInput, + State: client.Healthy, + Message: "Healthy", + }, + { + UnitID: "log-default", + UnitType: client.UnitTypeOutput, + State: client.Healthy, + Message: "Healthy", + }, + }, + }, + { + ID: "system/metrics-default", + Name: "system/metrics", + State: client.Healthy, + Message: "Healthy communicating with pid '1825'", + Units: []client.ComponentUnitState{ + { + UnitID: "system/metrics-default-system/metrics-system-7bc17120-0951-11ee-bd02-734625f2144c", + UnitType: client.UnitTypeInput, + State: client.Healthy, + Message: "Healthy", + }, + { + UnitID: "system/metrics-default", + UnitType: client.UnitTypeOutput, + State: client.Healthy, + Message: "Healthy", + }, + }, + }, + }, + } + tests := []struct { + state *client.AgentState + state_name string + output string + }{ + {output: "human", state_name: "degraded", state: stateDegraded}, + {output: "human", state_name: "healthy", state: stateHealthy}, + {output: "human_full", state_name: "healthy", state: stateHealthy}, + {output: "human_full", state_name: "degraded", state: stateDegraded}, + } + for _, test := range tests { + b.Reset() + expected, err := os.ReadFile(filepath.Join("testdata/status", test.output+"_"+test.state_name)) + require.NoErrorf(t, err, "error reading testdata for output: %s state: %s", test.output, test.state_name) + outputFunc, ok := statusOutputs[test.output] + require.Truef(t, ok, "Could not find output %s", test.output) + err = outputFunc(&b, test.state) + require.NoErrorf(t, err, "error applying output function: %s with state: %s", test.output, test.state_name) + require.Equalf(t, string(expected), b.String(), "unexpected input with output: %s, state: %s", test.output, test.state_name) + } +} diff --git a/internal/pkg/agent/cmd/testdata/status/human_degraded b/internal/pkg/agent/cmd/testdata/status/human_degraded new file mode 100644 index 00000000000..1ef06045cfb --- /dev/null +++ b/internal/pkg/agent/cmd/testdata/status/human_degraded @@ -0,0 +1,10 @@ +┌─ fleet +│ └─ status: (HEALTHY) Connected +└─ elastic-agent + ├─ status: (DEGRADED) 1 or more components/units in a failed state + └─ httpjson-default + ├─ status: (HEALTHY) Healthy communicating with pid '2875' + ├─ httpjson-default-httpjson-generic-ca7fa460-0bab-11ee-8598-c3f64dd59b06 + │ └─ status: (FAILED) [failed to reloading inputs: 1 error: Error creating runner from config: required 'object', but found 'string' in field 'processors.6'] + └─ httpjson-default + └─ status: (FAILED) [failed to reloading inputs: 1 error: Error creating runner from config: required 'object', but found 'string' in field 'processors.6'] diff --git a/internal/pkg/agent/cmd/testdata/status/human_full_degraded b/internal/pkg/agent/cmd/testdata/status/human_full_degraded new file mode 100644 index 00000000000..c9bf57b6cc5 --- /dev/null +++ b/internal/pkg/agent/cmd/testdata/status/human_full_degraded @@ -0,0 +1,24 @@ +┌─ fleet +│ └─ status: (HEALTHY) Connected +└─ elastic-agent + ├─ status: (DEGRADED) 1 or more components/units in a failed state + ├─ info + │ ├─ id: 9a4921cc-36d4-4b5a-9395-9ec2d204862e + │ ├─ version: 8.8.0 + │ └─ commit: adf44ef2c6dfc56b5e60400ecdfbf46ceda5a6f4 + ├─ log-default + │ ├─ status: (HEALTHY) Healthy: communicating with pid '1813' + │ ├─ log-default-logfile-system-7bc17120-0951-11ee-bd02-734625f2144c + │ │ ├─ status: (HEALTHY) Healthy + │ │ └─ type: INPUT + │ └─ log-default + │ ├─ status: (HEALTHY) Healthy + │ └─ type: OUTPUT + └─ httpjson-default + ├─ status: (HEALTHY) Healthy communicating with pid '2875' + ├─ httpjson-default-httpjson-generic-ca7fa460-0bab-11ee-8598-c3f64dd59b06 + │ ├─ status: (FAILED) [failed to reloading inputs: 1 error: Error creating runner from config: required 'object', but found 'string' in field 'processors.6'] + │ └─ type: INPUT + └─ httpjson-default + ├─ status: (FAILED) [failed to reloading inputs: 1 error: Error creating runner from config: required 'object', but found 'string' in field 'processors.6'] + └─ type: OUTPUT diff --git a/internal/pkg/agent/cmd/testdata/status/human_full_healthy b/internal/pkg/agent/cmd/testdata/status/human_full_healthy new file mode 100644 index 00000000000..23565d2eb3c --- /dev/null +++ b/internal/pkg/agent/cmd/testdata/status/human_full_healthy @@ -0,0 +1,24 @@ +┌─ fleet +│ └─ status: (HEALTHY) Connected +└─ elastic-agent + ├─ status: (HEALTHY) Running + ├─ info + │ ├─ id: 9a4921cc-36d4-4b5a-9395-9ec2d204862e + │ ├─ version: 8.8.0 + │ └─ commit: adf44ef2c6dfc56b5e60400ecdfbf46ceda5a6f4 + ├─ log-default + │ ├─ status: (HEALTHY) Healthy: communicating with pid '1813' + │ ├─ log-default-logfile-system-7bc17120-0951-11ee-bd02-734625f2144c + │ │ ├─ status: (HEALTHY) Healthy + │ │ └─ type: INPUT + │ └─ log-default + │ ├─ status: (HEALTHY) Healthy + │ └─ type: OUTPUT + └─ system/metrics-default + ├─ status: (HEALTHY) Healthy communicating with pid '1825' + ├─ system/metrics-default-system/metrics-system-7bc17120-0951-11ee-bd02-734625f2144c + │ ├─ status: (HEALTHY) Healthy + │ └─ type: INPUT + └─ system/metrics-default + ├─ status: (HEALTHY) Healthy + └─ type: OUTPUT diff --git a/internal/pkg/agent/cmd/testdata/status/human_healthy b/internal/pkg/agent/cmd/testdata/status/human_healthy new file mode 100644 index 00000000000..0bf793e1a9f --- /dev/null +++ b/internal/pkg/agent/cmd/testdata/status/human_healthy @@ -0,0 +1,4 @@ +┌─ fleet +│ └─ status: (HEALTHY) Connected +└─ elastic-agent + └─ status: (HEALTHY) Running diff --git a/pkg/testing/tools/artifacts_api.go b/pkg/testing/tools/artifacts_api.go index 7b528e59e46..fd4a03910a5 100644 --- a/pkg/testing/tools/artifacts_api.go +++ b/pkg/testing/tools/artifacts_api.go @@ -1,3 +1,7 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + package tools import ( diff --git a/pkg/testing/tools/artifacts_api_test.go b/pkg/testing/tools/artifacts_api_test.go index aee7d860df6..808d72a630b 100644 --- a/pkg/testing/tools/artifacts_api_test.go +++ b/pkg/testing/tools/artifacts_api_test.go @@ -1,3 +1,7 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + package tools import ( diff --git a/testing/fleetservertest/checkin.go b/testing/fleetservertest/checkin.go index af144b40219..4de1d4ec87c 100644 --- a/testing/fleetservertest/checkin.go +++ b/testing/fleetservertest/checkin.go @@ -1,3 +1,7 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + package fleetservertest const ( diff --git a/testing/fleetservertest/fleetserver.go b/testing/fleetservertest/fleetserver.go index ea336bfad6b..a4a7d1c038c 100644 --- a/testing/fleetservertest/fleetserver.go +++ b/testing/fleetservertest/fleetserver.go @@ -1,3 +1,7 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + package fleetservertest import ( diff --git a/testing/fleetservertest/fleetserver_test.go b/testing/fleetservertest/fleetserver_test.go index 622b2cd86ee..e11008a515f 100644 --- a/testing/fleetservertest/fleetserver_test.go +++ b/testing/fleetservertest/fleetserver_test.go @@ -1,3 +1,7 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + package fleetservertest import ( diff --git a/testing/fleetservertest/handlers.go b/testing/fleetservertest/handlers.go index 0a24e1a42ae..1edabc7c88b 100644 --- a/testing/fleetservertest/handlers.go +++ b/testing/fleetservertest/handlers.go @@ -1,3 +1,7 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + package fleetservertest import ( diff --git a/testing/fleetservertest/models.go b/testing/fleetservertest/models.go index 498582c9efe..d5dc5c514e8 100644 --- a/testing/fleetservertest/models.go +++ b/testing/fleetservertest/models.go @@ -1,3 +1,7 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + package fleetservertest // ============================================================================= diff --git a/testing/fleetservertest/server.go b/testing/fleetservertest/server.go index 2c65a0f0770..e7e8c7c5ac0 100644 --- a/testing/fleetservertest/server.go +++ b/testing/fleetservertest/server.go @@ -1,3 +1,7 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + package fleetservertest import (