logstash
logstash copied to clipboard
[health] bootstrap HealthObserver from agent to API
Release notes
[rn:skip]
What does this PR do?
- Introduces
org.logstash.health.HealthObserverthat is accessible viaAgent#health_observer - Introduces
org.logstash.health.Statuswith facilities for combining statuses - Populates API-common top-level
statuswithHealthObserver#status. In bootstrap form, the value is controlled by system propertylogstash.apiStatus, but will be derived from indicators once they are added in a subsequent PR.
Why is it important/What is the impact to the user?
These are steps toward delivering the health report API as RFC'd in #16056
Checklist
- [x] My code follows the style guidelines of this project
- [x] 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 (and/or docker env variables)~~
- [x] I have added tests that prove my fix is effective or that my feature works
How to test this PR locally
To prove that the value of API response's status is no longer hard-coded to green,
this bootstrap contains a hidden feature flag java property logstash.apiStatus which can be any of unknown, green, yellow, red, or random (it defaults to green).
Start Logstash running a long-lived pipeline:
LS_JAVA_OPTS="-Dlogstash.apiStatus=random" bin/logstash -e 'input { heartbeat {} }'
Get the API response for GET /_node and/or GET /_node_stats and observe that the status is no longer hard-coded to green:
╭─{ rye@perhaps:~/src/elastic/logstash@main (health-api-bootstrap ✔) }
╰─● curl --silent -XGET http://localhost:9600/_node | jq .status
"yellow"
[success]
╭─{ rye@perhaps:~/src/elastic/logstash@main (health-api-bootstrap ✔) }
╰─● curl --silent -XGET http://localhost:9600/_node | jq .status
"yellow"
[success]
╭─{ rye@perhaps:~/src/elastic/logstash@main (health-api-bootstrap ✔) }
╰─● curl --silent -XGET http://localhost:9600/_node | jq .status
"red"
[success]
╭─{ rye@perhaps:~/src/elastic/logstash@main (health-api-bootstrap ✔) }
╰─● curl --silent -XGET http://localhost:9600/_node | jq .status
"green"
[success]
╭─{ rye@perhaps:~/src/elastic/logstash@main (health-api-bootstrap ✔) }
╰─● curl --silent -XGET http://localhost:9600/_node | jq .status
"unknown"
[success]
Related issues
- Closes elastic/ingest-dev#3241
- Closes elastic/ingest-dev#3242
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code
:green_heart: Build Succeeded
- Buildkite Build
- Commit: 74de4eb25f8fb188e7eb5486a2cfb622e9533871
History
- :green_heart: Build #1107 succeeded 45a8728fa450a28a46e988b6b72e79e57b4bd7ed
- :broken_heart: Build #1084 failed 90883e438d4efe0ed5a1a4d6d1eb36f8d0f79201