docs: add health service
Signed-off-by: Vincenzo Scamporlino <vincenzos@spotify.com>
This commit is contained in:
@@ -20,6 +20,7 @@ import { coreServices } from '@backstage/backend-plugin-api';
|
||||
- [Cache Service](./cache.md) - Key-value store for caching data.
|
||||
- [Database Service](./database.md) - Database access and management via [knex](https://knexjs.org/).
|
||||
- [Discovery Service](./discovery.md) - Service discovery for inter-plugin communication.
|
||||
- [Health Service](./health.md) - Health check endpoints for the backend.
|
||||
- [Http Auth Service](./http-auth.md) - Authentication of HTTP requests.
|
||||
- [Http Router Service](./http-router.md) - HTTP route registration for plugins.
|
||||
- [Identity Service](./identity.md) - Deprecated user authentication service, use the [Auth Service](./auth.md) instead.
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
---
|
||||
id: health
|
||||
title: Heath Service
|
||||
sidebar_label: Health
|
||||
description: Documentation for the Health service
|
||||
---
|
||||
|
||||
The Health service provides some health check endpoints for the plugins. By default, it attaches `/.backstage/health/v1/readiness` and `/.backstage/health/v1/liveness` endpoints to the backend server, which return a JSON object with the status of the backend services.
|
||||
|
||||
## Configuring the service
|
||||
|
||||
The following example is how you can override the health service to add custom endpoints.
|
||||
|
||||
```ts
|
||||
import { coreServices } from '@backstage/backend-plugin-api';
|
||||
import { WinstonLogger } from '@backstage/backend-app-api';
|
||||
|
||||
const backend = createBackend();
|
||||
|
||||
backend.add(
|
||||
createServiceFactory({
|
||||
service: coreServices.health,
|
||||
deps: {
|
||||
rootHttpRouter: coreServices.rootHttpRouter,
|
||||
},
|
||||
async factory({ rootHttpRouter }) {
|
||||
rootHttpRouter.get('.backstage/health/v1/readiness', async (req, res) => {
|
||||
res.json({ status: 'ok' });
|
||||
});
|
||||
|
||||
rootHttpRouter.get('.backstage/health/v1/liveness', async (req, res) => {
|
||||
res.json({ status: 'ok' });
|
||||
});
|
||||
|
||||
return {};
|
||||
},
|
||||
}),
|
||||
);
|
||||
```
|
||||
Reference in New Issue
Block a user