kibana/packages/kbn-health-gateway-server
Pierre Gayvallet c10ab82521
Change the health gateway to use the status API (#160125)
## Summary

Follow-up of https://github.com/elastic/kibana/pull/159768
Related to https://github.com/elastic/kibana/issues/158910

Change the health-gateway behavior to hit the `/api/status` endpoint
instead of just the root `/` path. This was made possible by
https://github.com/elastic/kibana/pull/159768, as we now always return
the correct http code from the status endpoint even for unauthenticated
requests.
2023-06-26 02:34:00 -07:00
..
scripts Adds base implementation of the Kibana Health Gateway. (#141172) 2022-11-07 09:14:42 -07:00
src Change the health gateway to use the status API (#160125) 2023-06-26 02:34:00 -07:00
.gitignore Adds base implementation of the Kibana Health Gateway. (#141172) 2022-11-07 09:14:42 -07:00
index.ts Adds base implementation of the Kibana Health Gateway. (#141172) 2022-11-07 09:14:42 -07:00
jest.config.js Adds base implementation of the Kibana Health Gateway. (#141172) 2022-11-07 09:14:42 -07:00
kibana.jsonc Transpile packages on demand, validate all TS projects (#146212) 2022-12-22 19:00:29 -06:00
package.json Transpile packages on demand, validate all TS projects (#146212) 2022-12-22 19:00:29 -06:00
README.md Fix Health Gateway Checks (#144985) 2022-11-14 08:29:36 -05:00
tsconfig.json implement "plugin" package type (#149370) 2023-01-30 10:47:53 -07:00

@kbn/health-gateway-server

This package runs a small server called the Health Gateway, which exists to check the health of multiple Kibana instances and return an aggregated result.

This is used by the Elastic Cloud infrastructure to run two different Kibana processes with different node.roles: one process for handling UI requests, and one for background tasks.

Configuration

Similar to Kibana, the gateway has a yml configuration file that it reads from. By default this lives alongside the kibana.yml at <REPO_ROOT>/config/gateway.yml. Like Kibana, you can provide a -c or --config CLI argument to override the location of the config file.

For example:

$ yarn start --config /path/to/some/other/config.yml

Here is a sample configuration file recommended for use in development:

# config/gateway.yml
server:
  port: 3000
  host: 'localhost'
  ssl:
    enabled: true
    # Using Kibana test certs
    key: /path/to/packages/kbn-dev-utils/certs/kibana.key
    certificate: /path/to/packages/kbn-dev-utils/certs/kibana.crt
    certificateAuthorities: /path/to/packages/kbn-dev-utils/certs/ca.crt
 
kibana:
  hosts:
    - 'https://localhost:5605'
    - 'https://localhost:5606'
  ssl:
    # Using Kibana test certs
    certificate: /path/to/packages/kbn-dev-utils/certs/kibana.crt
    certificateAuthorities: /path/to/packages/kbn-dev-utils/certs/ca.crt
    verificationMode: certificate

logging:
  root:
    appenders: ['console']
    level: 'all'

Note that the gateway supports the same logging configuration as Kibana, including all of the same appenders.

Development & Testing

To run this locally, first you need to create a config/gateway.yml file. There's a docker-compose.yml intended for development, which will run Elasticsearch and two different Kibana instances for testing. Before using it, you'll want to create a .env file:

# From the /packages/kbn-health-gateway-server/scripts directory
$ cp .env.example .env
# (modify the .env settings if desired)
$ docker-compose up

This will automatically run Kibana on the ports from the sample gateway.yml above (5605-5606).

Once you have your gateway.yml and have started docker-compose, you can run the server from the /packages/kbn-health-gateway-server directory with yarn start. Then you should be able to make requests to the / endpoint:

$ curl "https://localhost:3000/"