# How to integrate Google Healthcheck
Google healthcheck is basically invertal request sending from google to our server/endpoints
## Required step
1. Your service needs to expose **HTTP endpoint**
2. Setup Google uptime-checks
3. Setup alert
### HTTP Endpoints
Your can use http/https/tcp to expose healthcheck endpoint
Following codes are example of simple http server in Node.js
Endpoint is `GET` `/api/v1/health`
```javascript
import express from 'express'
import { Express, Router } from 'express-serve-static-core'
import { healthcheckPort } from 'config/healthcheckConfig'
import { logger } from './loggerService'
class HealthCheckService {
router: Router
app: Express
port: number
constructor() {
this.app = express()
this.router = express.Router()
this.port = healthcheckPort
}
initilize = () => {
this.router.use((_req, res, next): void => {
res.header('Access-Control-Allow-Methods', 'GET')
next()
})
this.router.get('/health', (_req, res) => {
res.status(200).send('Ok')
})
this.app.use('/api/v1', this.router)
this.app.listen(this.port, () => {
logger.info(`healhcheck app listening at http://localhost:${this.port}`)
})
}
}
export const healthCheckService = new HealthCheckService()
```
### Setup Google uptime-checks
1. go to https://console.cloud.google.com/monitoring/uptime?project=alpha-perp
2. click `Create Uptime Check`
3. setup `title`
4. for `target`, select the protocol, resource type, path, and frequency. `you can select compute engine intsance directly`
5. if you're not using default port 80, you can choose specific port by clicking `More target options`
6. Response validation: you can setup response timeout and validation
7. Alert & Notification: you can set notification when uptime-checks are failed (to setup new notification channel: https://console.cloud.google.com/monitoring/alerting/notifications?project=alpha-perp)
8. Test connection and Create uptime-check
### Trouble shooting
#### Endpoint cannot reachacle or no response.
1. If you use `Docker`, make sure that the port mapping is correct.
2. Check Firewall setup by checking `Network interfaces` under particular instance. you need to allow ingress for the port that you're using for healthcheck.
### References
- https://cloud.google.com/monitoring/uptime-checks