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

update status command #2890

Merged
merged 3 commits into from Jun 20, 2023
Merged

Conversation

leehinman
Copy link
Contributor

@leehinman leehinman commented Jun 16, 2023

What does this PR do?

This PR changes the default output (called human) of the status command and adds a second option to the status command called full. Changes include:

  • 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 full which always displays full status
  • sort components and units so order will always be the same

Why is it important?

Previously the status command could show the overall agent state as DEGRADED but individual components would show HEALTHY, because the units were not shown.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
    - [ ] I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in ./changelog/fragments using the changelog tool
    - [ ] I have added an integration test or an E2E test

Author's Checklist

  • Review the files in internal/pkg/agent/cmd/testdata/status these are examples of the status output under various conditions

How to test this PR locally

Unit test

cd internal/pkg/agent/cmd
go test -run TestHumanOutput -count 1

System test

  1. Install elastic-agent
  2. run elastic-agent status

Related issues

Screenshots

Healthy Fleet & Agent

sudo elastic-agent status
┌─ fleet
│  └─ status: (HEALTHY) Connected
└─ elastic-agent
   └─ status: (HEALTHY) Running

Starting

sudo elastic-agent status
┌─ fleet
│  └─ status: (STARTING)
└─ elastic-agent
   ├─ status: (HEALTHY) Running
   ├─ beat/metrics-monitoring
   │  ├─ status: (STARTING) Starting: spawned pid '17837'
   │  ├─ beat/metrics-monitoring
   │  │  └─ status: (STARTING) Starting: spawned pid '17837'
   │  └─ beat/metrics-monitoring-metrics-monitoring-beats
   │     └─ status: (STARTING) Starting: spawned pid '17837'
   ├─ filestream-monitoring
   │  ├─ status: (STARTING) Starting: spawned pid '17823'
   │  ├─ filestream-monitoring
   │  │  └─ status: (STARTING) Starting: spawned pid '17823'
   │  └─ filestream-monitoring-filestream-monitoring-agent
   │     └─ status: (STARTING) Starting: spawned pid '17823'
   ├─ http/metrics-monitoring
   │  ├─ status: (STARTING) Starting: spawned pid '17848'
   │  ├─ http/metrics-monitoring
   │  │  └─ status: (STARTING) Starting: spawned pid '17848'
   │  └─ http/metrics-monitoring-metrics-monitoring-agent
   │     └─ status: (STARTING) Starting: spawned pid '17848'
   ├─ log-default
   │  ├─ status: (STARTING) Starting: spawned pid '17812'
   │  ├─ log-default
   │  │  └─ status: (STARTING) Starting: spawned pid '17812'
   │  └─ log-default-logfile-system-7bc17120-0951-11ee-bd02-734625f2144c
   │     └─ status: (STARTING) Starting: spawned pid '17812'
   └─ system/metrics-default
      ├─ status: (STARTING) Starting: spawned pid '17800'
      ├─ system/metrics-default
      │  └─ status: (STARTING) Starting: spawned pid '17800'
      └─ system/metrics-default-system/metrics-system-7bc17120-0951-11ee-bd02-734625f2144c
         └─ status: (STARTING) Starting: spawned pid '17800'

Full output Healthy

sudo elastic-agent status --output full
┌─ fleet
│  └─ status: (HEALTHY) Connected
└─ elastic-agent
   ├─ status: (HEALTHY) Running
   ├─ info
   │  ├─ id: e0bf062c-48bf-4457-9de3-d5ff14e63864
   │  ├─ version: 8.8.0
   │  └─ commit: e4674bed36676ca7d0b7b2516a5d807a2c37cbd4
   ├─ beat/metrics-monitoring
   │  ├─ status: (HEALTHY) Healthy: communicating with pid '17371'
   │  ├─ beat/metrics-monitoring
   │  │  ├─ status: (HEALTHY) Healthy
   │  │  └─ type: OUTPUT
   │  └─ beat/metrics-monitoring-metrics-monitoring-beats
   │     ├─ status: (HEALTHY) Healthy
   │     └─ type: INPUT
   ├─ filestream-monitoring
   │  ├─ status: (HEALTHY) Healthy: communicating with pid '17360'
   │  ├─ filestream-monitoring
   │  │  ├─ status: (HEALTHY) Healthy
   │  │  └─ type: OUTPUT
   │  └─ filestream-monitoring-filestream-monitoring-agent
   │     ├─ status: (HEALTHY) Healthy
   │     └─ type: INPUT
   ├─ http/metrics-monitoring
   │  ├─ status: (HEALTHY) Healthy: communicating with pid '17386'
   │  ├─ http/metrics-monitoring
   │  │  ├─ status: (HEALTHY) Healthy
   │  │  └─ type: OUTPUT
   │  └─ http/metrics-monitoring-metrics-monitoring-agent
   │     ├─ status: (HEALTHY) Healthy
   │     └─ type: INPUT
   ├─ log-default
   │  ├─ status: (HEALTHY) Healthy: communicating with pid '17336'
   │  ├─ log-default
   │  │  ├─ status: (HEALTHY) Healthy
   │  │  └─ type: OUTPUT
   │  └─ log-default-logfile-system-7bc17120-0951-11ee-bd02-734625f2144c
   │     ├─ status: (HEALTHY) Healthy
   │     └─ type: INPUT
   └─ system/metrics-default
      ├─ status: (HEALTHY) Healthy: communicating with pid '17347'
      ├─ system/metrics-default
      │  ├─ status: (HEALTHY) Healthy
      │  └─ type: OUTPUT
      └─ system/metrics-default-system/metrics-system-7bc17120-0951-11ee-bd02-734625f2144c
         ├─ status: (HEALTHY) Healthy
         └─ type: INPUT

@leehinman leehinman added enhancement New feature or request Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team labels Jun 16, 2023
@leehinman leehinman requested a review from a team as a code owner June 16, 2023 20:46
@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

@mergify
Copy link
Contributor

mergify bot commented Jun 16, 2023

This pull request does not have a backport label. Could you fix it @leehinman? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v./d./d./d is the label to automatically backport to the 8./d branch. /d is the digit

NOTE: backport-skip has been added to this pull request.

@elasticmachine
Copy link
Collaborator

elasticmachine commented Jun 16, 2023

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2023-06-20T16:07:37.668+0000

  • Duration: 21 min 32 sec

Test stats 🧪

Test Results
Failed 0
Passed 5991
Skipped 19
Total 6010

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /package : Generate the packages.

  • run integration tests : Run the Elastic Agent Integration tests.

  • run end-to-end tests : Generate the packages and run the E2E Tests.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

- 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 elastic#2107
Closes elastic#2829
@elasticmachine
Copy link
Collaborator

elasticmachine commented Jun 16, 2023

🌐 Coverage report

Name Metrics % (covered/total) Diff
Packages 98.667% (74/75) 👍
Files 68.992% (178/258) 👍 0.388
Classes 67.629% (328/485) 👍 0.206
Methods 53.969% (1013/1877) 👍 0.23
Lines 39.688% (11539/29074) 👍 0.178
Conditionals 100.0% (0/0) 💚

changelog/fragments/1686949146-update-status-command.yaml Outdated Show resolved Hide resolved
and summaries output. Full human output can be obtained with the new `human_full`

# Affected component; a word indicating the component this changeset affects.
component: agent
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Question]
Should it be agent or elastic-agent?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very good question. Looking at older change logs we have "agent", "elastic-agent", "Elastic agent." and "cmd" which all seem relevant to this case. But "agent" seems like the most popular so I'd lean towards sticking with that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs don't actually do anything with this field today, so don't think too hard about it. In Beats this would just be the name of the Beat, for agent it can always be "Elastic Agent". We should probably template this into the fragment.

Copy link
Contributor

@blakerouse blakerouse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Been really looking forward to seeing the output of the status command to be improved!

internal/pkg/agent/cmd/status.go Outdated Show resolved Hide resolved
Copy link
Contributor

@faec faec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, looking forward to getting this in a release :-)

@leehinman leehinman merged commit 7772cf2 into elastic:main Jun 20, 2023
22 checks passed
kilfoyle added a commit to elastic/ingest-docs that referenced this pull request Jun 20, 2023
* update status documentation to match elastic/elastic-agent#2890

* change option to match what got merged

* Update docs/en/ingest-management/commands.asciidoc

---------

Co-authored-by: David Kilfoyle <41695641+kilfoyle@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-skip enhancement New feature or request Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team
Projects
None yet
6 participants