kafka-connect-healthcheck
A simple healthcheck wrapper to monitor Kafka Connect.
Kafka Connect Healthcheck is a server that wraps the Kafka Connect API and provides a singular API endpoint to determine the health of a Kafka Connect instance. This can be used to alert or take action on unhealthy connectors and tasks.
This can be used in numerous ways. It can sit as a standalone service for monitoring purposes, it can be used as a sidecar container to mark Kafka Connect workers as unhealthy in Kubernetes, or it can be used to provide logs of when connectors/tasks failed and reasons for their failures.
By default, the root endpoint / will return 200 OK healthy if all connectors and tasks are in a state other than FAILED. It will return 503 Service Unavailable if any connector or tasks are in a FAILED state.
Usage
Kafka Connect Healthcheck can be installed as a command-line tool through pip or it can be used as a standalone Docker container. It could also be installed as a part of a custom Kafka Connect docker image.
Command-Line
To use kafka-connect-healthcheck from the command-line, you must have python and pip installed. Currently, only Python 3 is supported.
You can install kafka-connect-healthcheck via pip:
pip install kafka-connect-healthcheck
To start the healthcheck server, run:
kafka-connect-healthcheck
The server will now be running on localhost:18083.
Docker
The kafka-connect-healthcheck image can be found on Docker Hub.
You can pull down the latest image by running:
docker pull devshawn/kafka-connect-healthcheck
To start the healthcheck server, run:
docker run --rm -it -p 18083:18083 devshawn/kafka-connect-healthcheck
The server will now be running on localhost:18083.
Configuration
Kafka Connect Healthcheck can be configured via command-line arguments or by environment variables.
Port
The port for the kafka-connect-healthcheck API.
| Usage | Value |
|---|---|
| Environment Variable | HEALTHCHECK_PORT |
| Command-Line Argument | --port |
| Default Value | 18083 |
Connect URL
The full URL of the Kafka Connect REST API. This is used to determine the health of the connect instance.
| Usage | Value |
|---|---|
| Environment Variable | HEALTHCHECK_CONNECT_URL |
| Command-Line Argument | --connect-url |
| Default Value | http://localhost:8083 |
Connect Worker ID
The worker ID to monitor (usually the IP address of the connect worker). If none is set, all workers will be monitored and any failure will result in an unhealthy response.
| Usage | Value |
|---|---|
| Environment Variable | HEALTHCHECK_CONNECT_WORKER_ID |
| Command-Line Argument | --connect-worker-id |
| Default Value | None (all workers monitored) |
Note: It is highly recommended to run an instance of the healthcheck for each worker if you're planning to restart containers based on the health.
Considered Containers
A comma-separated list of which type of kafka connect container to be considered in the healthcheck calculation.
| Usage | Value |
|---|---|
| Environment Variable | HEALTHCHECK_CONSIDERED_CONTAINERS |
| Command-Line Argument | --considered-containers |
| Default Value | CONNECTOR,TASK |
| Valid Values | CONNECTOR, TASK |
Unhealthy States
A comma-separated list of connector and tasks states to be marked as unhealthy.
| Usage | Value |
|---|---|
| Environment Variable | HEALTHCHECK_UNHEALTHY_STATES |
| Command-Line Argument | --unhealthy-states |
| Default Value | FAILED |
| Valid Values | FAILED, PAUSED, UNASSIGNED, RUNNING |
Note: It's recommended to keep this defaulted to FAILED, but paused connectors or tasks can be marked as unhealthy by passing FAILED,PAUSED.
Failure Threshold Percentage
A number between 1 and 100. If set, this is the percentage of connectors that must fail for the healthcheck to fail.
| Usage | Value |
|---|---|
| Environment Variable | HEALTHCHECK_FAILURE_THRESHOLD_PERCENTAGE |
| Command-Line Argument | --failure-threshold-percentage |
| Default Value | 0 |
| Valid Values | 1 to 100 |
By default, any failures will cause the healthcheck to fail.
Log Level
The level of logs to be shown by the application.
| Usage | Value |
|---|---|
| Environment Variable | HEALTHCHECK_LOG_LEVEL |
| Command-Line Argument | --log-level |
| Default Value | INFO |
| Valid Values | DEBUG, INFO, WARNING, ERROR |
All healthy connector and task statuses are logged at INFO. Unhealthy ones are logged at WARNING. Any communication or HTTP errors are logged at ERROR.
API
The server provides a very simple HTTP API which can be used for liveness probes and monitoring alerts. We expose two endpoints:
GET /
Get the current health status of the Kafka Connect system. This could be used as a sidecar to determine the health of each Kafka Connect worker and their associated connectors and tasks.
Example Request
curl http://localhost:18083
Example Healthy Response
200 OK
{
"failures": [],
"failure_states": [
"FAILED"
],
"healthy": true
}
Example Unhealthy Response
503 Service Unavailable
{
"failures": [
{
"type": "connector",
"connector": "jdbc-source",
"state": "FAILED",
"worker_id": "127.0.0.1:8083"
},
{
"type": "task",
"connector": "jdbc-source",
"id": 0,
"state": "FAILED",
"worker_id": "127.0.0.1:8083",
"trace": "..."
}
],
"failure_states": [
"FAILED"
],
"healthy": false
}
GET /ping
Get the current health status of the healthcheck server. This will always be successful as long as the server is still able to serve requests. This can be used as a ready or liveness probe in Kubernetes.
Example Request
curl http://localhost:18083/ping
Example Response
200 OK
{
"status": "UP"
}
License
Copyright (c) 2019 Shawn Seymour.
Licensed under the Apache 2.0 license.
Metadata
Release files for kafka-connect-healthcheck 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kafka-connect-healthcheck-0.3.0.tar.gz | 13.9 kB | Without provenance | Details for kafka-connect-healthcheck-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kafka_connect_healthcheck-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for kafka_connect_healthcheck-0.3.0-py3-none-any.whl |
Total release size: 29.9 kB
Release files / kafka-connect-healthcheck-0.3.0.tar.gz
| Download URL | kafka-connect-healthcheck-0.3.0.tar.gz |
|---|---|
| Size | 13.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c5020bab8f9b93e6213d7760f4610cec9531bb811d3660d29b605aa9bab38910
|
|
BLAKE2b-256 checksum How to use checksums |
e73b829dd65df744f739ee4be374435bbaf847b305fce69ec8e9774819efa247
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.6.0 requests-toolbelt/0.8.0 tqdm/4.31.1 CPython/3.7.5
|
Release files / kafka_connect_healthcheck-0.3.0-py3-none-any.whl
| Download URL | kafka_connect_healthcheck-0.3.0-py3-none-any.whl |
|---|---|
| Size | 16.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ac0b56cb27abe6f385b650dfb2e99dd460e3d97e412ef733ed4f70298cd06967
|
|
BLAKE2b-256 checksum How to use checksums |
87f087051f160242db42532c1a5ffb382a1c3fc25f4c1da91027d8d180d05d82
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.6.0 requests-toolbelt/0.8.0 tqdm/4.31.1 CPython/3.7.5
|
Security for kafka-connect-healthcheck 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.