Edge Node to make HealthChecks
Built with the tools and technologies:
- 📍 Overview
- 👾 Features
- Integration with Sentinel
- 📦 Installation
- Configure a Synthetics Docker image
- 📌 Project Roadmap
- 🤝 Contributing
- 🎗 License
- 🙌 Acknowledgments
This Express.js server acts as a health check endpoint for a master node, referred to as the "sentinel." It receives requests from the sentinel, performs a health check based on specified criteria, and returns a response indicating the success or failure of the check, along with the time taken to complete the operation.
- Monitoring Node Health: Regularly assess the health and responsiveness of the sentinel node.
- Triggering Alerts: Initiate alerts or actions based on health check results, such as restarting services or notifying administrators.
- Ensuring System Availability: Help maintain system uptime and stability by proactively detecting and addressing health issues.
-
Health Check Endpoint: Provides a dedicated endpoint for the sentinel to initiate health checks.
-
Response Formatting: Returns a structured response containing:
- Success or failure status
- Time taken to complete the check
-
Customizable Health Check Logic: Allows for flexible health check implementations based on specific requirements.
-
Error Handling: Implements robust error handling mechanisms to gracefully handle unexpected situations.
This server is designed to seamlessly integrate with the sentinel node. The sentinel can send HTTP requests to the health check endpoint, and the server will process the requests and return the appropriate response.
- Security: Implement appropriate security measures, such as authentication and authorization, to protect the health check endpoint.
- Performance: Optimize the health check logic and response handling to ensure efficient performance.
- Scalability: Consider the scalability requirements of the server and implement appropriate strategies to handle increasing load.
By leveraging this health check server, you can effectively monitor the health of your sentinel node and take proactive measures to ensure system reliability and performance.
This topic guides you through installing Synthetics via the official Docker images. Specifically, it covers running Synthetics via the Docker command line interface (CLI)
Docker images is as follows:
Synthetics - avneesh001/synthetics
The default images for Synethetics are created using the Alpine Linux project and can be found in the Alpine official image.
To run the latest stable version of Synthetics, run the following command:
❯ docker pull avneesh001/synthetics
❯ docker run -d -p 3000:3000 --name=synthetics avneesh001/syntheticswhere
- docker run is a Docker CLI command that runs a new container from an image
- -d (--detach) runs the container in the background
- -p : (--publish) publish a container’s port(s) to the host, allowing you to reach the container’s port via a host port. In this case, we can reach the container’s port 3000 via the host’s port 3000
- --name assign a logical name to the container (e.g. synthetics). This allows you to refer to the container by name instead of by ID.
- avneesh001/synthetics is the image to run
#The `docker ps` command shows the processes running in Docker
❯ docker ps
# This will display a list of containers that looks like the following:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f2cf8380eb4d synthetics:latest "./entrypoint.sh" 32 hours ago Up 8 seconds 0.0.0.0:3000->3000/tcp synethtic-default
# To stop the synthetics container run the command
# docker stop CONTAINER-ID or use
# docker stop NAME, which is `synthetics` as previously defined
❯ docker stop syntheticsDocker Compose is a software tool that makes it easy to define and share applications that consist of multiple containers. It works by using a YAML file, usually called docker-compose.yaml, which lists all the services that make up the application. You can start the containers in the correct order with a single command, and with another command, you can shut them down. For more information about the benefits of using Docker Compose and how to use it refer to Use Docker Compose.
To run Synthetics via Docker Compose, install the compose tool on your machine. To determine if the compose tool is available, run the following command:
❯ docker compose versionIf the compose tool is unavailable, refer to Install Docker Compose.
This section shows you how to run Synthetics using Docker Compose. The examples in this section use Compose version 3. For more information about compatibility, refer to Compose and Docker compatibility matrix.
To run the latest stable version of Synthetics using Docker Compose, complete the following steps:
- Create a
docker-compose.yamlfile.
# first go into the directory where you have created this docker-compose.yaml file
cd /path/to/docker-compose-directory
# now create the docker-compose.yaml file
touch docker-compose.yaml- Now, add the following code into the
docker-compose.yamlfile. For Example:-
services:
synethetics:
image: avneesh001/synthetics
container_name: synthetics
restart: unless-stopped
ports:
- '3000:3000'- To run
docker-compose.yaml, run the following command:
# start the synthetics container
docker compose up -dWhere:
- d = detached mode
- up = to bring the container up and running
To determine that Synthetics is running, open a browser window and type IP_ADDRESS:3000. The sign in screen should appear.
To stop the Synthetics container, run the following command:
docker compose downThis topic explains how to run Grafana on Docker in complex environments that require you to:
- Use different images
- Define secrets on the Cloud
To run a specific version of Synthetics, add it in the command section:
docker run -d -p 3000:3000 --name synthetics avneesh001/synthetics:<version number>Example:
The following command runs the Synthetics container and specifies version 1.1.0. If you want to run a different version, modify the version number section.
docker run -d -p 3000:3000 --name synthetics avneesh001/synthetics:1.1.0Synthetics comes with default configuration parameters that remain the same among versions regardless of the operating system or the environment (for example, Docker, Kubernetes, etc.).
The following configurations are set by default when you start the Synthetics Docker container. You can modify the configuration using environment variables.
| ENV_KEY | ENV_DESCRIPTION | ENV Default Value |
|---|---|---|
| PORT | Defines the port on which the server listens for incoming requests. | 3000 |
| SECRET_KEY | A secret key used for signing and verifying tokens | Required (replace with your own secret key) |
| ORIGIN | Specifies the allowed origin for Cross-Origin Resource Sharing (CORS) requests. | your.domain.com |
| CREDENTIALS | Enables sending of credentials (cookies, authorization headers) in CORS requests. | true |
| API_KEY | This is the headers key that will be sent via sentinel for server to server authentication | SENTINEL_AUTH_KEY |
| API_KEY_VALUE | This is the value that will be set in value for the headers against the key | bd39004d-e21d-4a0b-ab93-eafa4d27de2e |
Find the Project Roadmap here.
Contributions are welcome! Here are several ways you can contribute:
- Report Issues: Submit bugs found or log feature requests for the
syntheticsproject. - Submit Pull Requests: Review open PRs, and submit your own PRs.
- Join the Discussions: Share your insights, provide feedback, or ask questions.
Contributing Guidelines
Contribution Guidelines are mentioned here.
This project is protected under the Apache License 2.0 License. For more details, refer to the LICENSE file.
- This project is Inspired from Grafana Synthetics monitoring plugin.
