Skip to content

Commit 5f3ba69

Browse files
committed
Updated docs
1 parent 0210718 commit 5f3ba69

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

README.md

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# siok: Consul Service Health Aggregator API
22

3-
*Picture this*: you have a need to know that some network-attached service is functioning correctly, but the service in question doesn't include a ```/health``` route, it doesn't cache its health-check results and/or the health-checks don't cover all the dependent services **and** you're running Consul while you're reading this; well you're in luck: this API is for *you*.
3+
*Picture this*: you need to know that some network-attached service is functioning correctly, but the service in question doesn't include a ```/health``` route, it doesn't cache its health-check results and/or the health-checks don't cover all the dependent services **and** you're running Consul while you're reading this; well you're in luck: this API is for *you*.
44

55
## What is siok
66

7-
**siok** is a simple API which aggregates and translates the health of a service a Consul Agent registers and monitors, alongside the health of the related entities, such as node health, service- and node-maintenance, in a JSON array of all entities related to the service with a HTTP 200 status code if all are "passing" and/or "warning", 503 otherwise.
7+
**siok** is a simple REST API which translates and aggregates the health of a service a Consul Agent registers and monitors, alongside the health of the related entities (such as node health, service- and node-maintenance) in a JSON array with a HTTP 200 status code if all are "passing" and/or "warning", 503 otherwise.
88

9-
In other words, you register a service **bar** with one health-check on the Consul-enabled host **foo**, you send a GET request to ```http://foo:31998/health?service=bar```, you get this HTTP 200 response back:
9+
In other words, if you register a service **bar** with one health-check on the Consul-enabled host **foo**, and you send a GET request to ```http://foo:31998/health?service=bar```, you'll get this HTTP 200 response back if the check is passing:
1010

1111
```json
1212
[
@@ -23,15 +23,15 @@ In other words, you register a service **bar** with one health-check on the Cons
2323

2424
## A typical scenario for siok
2525

26-
To expand the example above, let's say that you have a service running on host **foo**, the name of the service is **bar**. **bar** doesn't have a ```/health```, ```/status``` or a similar route, so to get its health you must query it as its client would, parse the results and see if they are okay. You create a Consul health-check for this service, on its local Consul Agent, to do this and you run it every 10s, because hey, this query is *expensive*. Then, you also want to verify does some service **baz**, on which **bar** depends on, is also okay. You attach this check to **bar** as well, but you schedule it to run every 5s, because **baz** is a simpler service and the requests to it are cheaper. Then, you also want to know does a simple TCP connect work on **bar**, and you schedule this one to run every 1s, because it's hella cheap.
26+
To expand the example above, let's say that you have a service running on host **foo**, the name of the service is **bar**. **bar** doesn't have a ```/health```, ```/status``` or a similar route, so to get its health you must query it as its client would, parse the result and see if it is okay. You create a Consul health-check for this service, on its local Consul Agent, to do this and you run it every 10s, because hey, this query is *expensive*. Then, you also want to verify does some service **baz**, on which **bar** depends on, is also okay. You attach this check to service **bar** as well, but you schedule it to run every 5s, because **baz** is a simpler service and the requests to it are cheaper. Then, you also want to know does a simple TCP connect work on **bar**, and you schedule this one to run every 1s, because it's hella cheap.
2727

28-
You end up with the service **bar** having three health-checks, but your HAProxy can (easily) only query one HTTP endpoint to get the health? The solution would be to run **siok** and point the HAProxy to
28+
You end up with the service **bar** on Consul having three health-checks, but your HAProxy can (easily) only query one HTTP endpoint to get the health? The solution would be to run **siok** and point the HAProxy to
2929

3030
```
3131
http://foo:31998/health?service=bar
3232
```
3333

34-
to get the health-check details regarding the service **bar** on host **foo**.
34+
to get the health-check details regarding the service **bar** on host **foo** (make sure you configure HAProxy to send GET requests for health-checks!)
3535

3636
## Building siok
3737

@@ -46,21 +46,22 @@ to get the health-check details regarding the service **bar** on host **foo**.
4646

4747
## Running siok
4848

49-
**siok** supports only one flag, ```-p```, to specify the port it'll run on. The default is **31998**.
49+
**siok** supports the following command-line options:
5050

51-
It expects the Consul Agent HTTP API on ```http://localhost:8500```.
51+
- ```-p```, to specify the port it'll run on. The default is ``31998``
52+
- ```-a```, to specify the Consul Agent IP:port. The default is ``127.0.0.1:8500``
5253
53-
It only has one route, ```/health``` and only one query string parameter at the moment, ```service```, to specify the Consul ```ServiceID``` on the node in question. Note that ```ServiceID``` *can* differ from the ```ServiceName```, so make sure you get it right. Ie. this is how an URL should look like:
54+
It has one route, ```/health```, that responds to GET requests and one query string parameter at the moment, ```service```, to specify the Consul ```ServiceID``` on the node in question. Note that ```ServiceID``` *can* differ from the ```ServiceName```, so make sure you get it right. Ie this is how a request should look like:
5455
5556
```
56-
/health?service=$serviceID
57+
GET /health?service=$serviceID
5758
```
5859
59-
Expect HTTP 200 if "passing"/"warning", 503 otherwise. On top of that, additional info is in the JSON array returned and a ```Warning``` HTTP response header is included if any of the checks are in the "warning" state.
60+
Expect HTTP 200 if Consul returns "passing"/"warning" for all checks, 503 otherwise. On top of that, additional info is in the JSON array returned and a ```Warning``` HTTP response header is included if any of the checks are in the "warning" state.
6061
6162
## Details
6263
63-
**siok** uses the responses from the local Consul Agent and doesn't query the Consul Catalog at all. That's why it needs to run local to the Consul Agent which monitors the services it has registered and that makes it really lightweight and fast, so my guess is that it'll scale nicely. Most of the requests finish in under one millisecond: for example, when testing it with 2000 remote requests with the concurrency of 100, with one Consul Service underneath, I got *all* responses back within 250 milliseconds (yeah, *all* 2000 requests), so I guess you could say it's fast.
64+
**siok** uses the responses from the Consul Agent's ```/agent/checks``` path only and doesn't query the Consul Catalog at all. If it runs local to the Consul Agent it'll respond really fast, so my guess is that it'll scale nicely: most of the requests finish in under one millisecond. For example, when I tested it with 2000 remote requests with the concurrency of 100, with one Consul Service underneath, I got *all* responses back within 250 milliseconds (yeah, *all* 2000 requests).
6465
6566
## TL;DR
6667

0 commit comments

Comments
 (0)