logstash icon indicating copy to clipboard operation
logstash copied to clipboard

[health] bootstrap HealthObserver from agent to API

Open yaauie opened this issue 1 year ago • 2 comments

Release notes

[rn:skip]

What does this PR do?

  • Introduces org.logstash.health.HealthObserver that is accessible via Agent#health_observer
  • Introduces org.logstash.health.Status with facilities for combining statuses
  • Populates API-common top-level status with HealthObserver#status. In bootstrap form, the value is controlled by system property logstash.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

yaauie avatar May 03 '24 22:05 yaauie

:green_heart: Build Succeeded

History

  • :green_heart: Build #1107 succeeded 45a8728fa450a28a46e988b6b72e79e57b4bd7ed
  • :broken_heart: Build #1084 failed 90883e438d4efe0ed5a1a4d6d1eb36f8d0f79201

elasticmachine avatar May 08 '24 20:05 elasticmachine