Make nats optional; Update README.md

This commit is contained in:
Lou Knauer 2021-10-12 13:26:54 +02:00
parent 26528151b1
commit 024f66f49c
2 changed files with 21 additions and 12 deletions

View File

@ -3,7 +3,7 @@
[![Build & Test](https://github.com/ClusterCockpit/cc-metric-store/actions/workflows/test.yml/badge.svg)](https://github.com/ClusterCockpit/cc-metric-store/actions/workflows/test.yml) [![Build & Test](https://github.com/ClusterCockpit/cc-metric-store/actions/workflows/test.yml/badge.svg)](https://github.com/ClusterCockpit/cc-metric-store/actions/workflows/test.yml)
Go look at the `TODO.md` file and the [GitHub Issues](https://github.com/ClusterCockpit/cc-metric-store/issues) for a progress overview. Things work, but are not properly tested. Go look at the `TODO.md` file and the [GitHub Issues](https://github.com/ClusterCockpit/cc-metric-store/issues) for a progress overview. Things work, but are not properly tested.
The [NATS.io](https://nats.io/) based writing endpoint consumes messages in [this format of the InfluxDB line protocol](https://github.com/ClusterCockpit/cc-specifications/blob/master/metrics/lineprotocol.md), but will change to another format in the future. The [NATS.io](https://nats.io/) based writing endpoint consumes messages in [this format of the InfluxDB line protocol](https://github.com/ClusterCockpit/cc-specifications/blob/master/metrics/lineprotocol_alternative.md).
### REST API Endpoints ### REST API Endpoints
@ -31,6 +31,8 @@ if there was not data for a section of the requested data.
4. `GET /api/{cluster}/peek` 4. `GET /api/{cluster}/peek`
- Return a map from every node in the specified cluster to a map from every metric to the newest value available for that metric - Return a map from every node in the specified cluster to a map from every metric to the newest value available for that metric
- All cpu/socket level metrics are aggregated to the node level - All cpu/socket level metrics are aggregated to the node level
5. `POST /api/write`
- You can send lines of the InfluxDB line protocol to this endpoint and they will be written to the store (Basically an alternative to NATS)
### Run tests ### Run tests
@ -93,8 +95,10 @@ All durations are specified in seconds.
- `"sum"` means that values from the child levels are summed up for the parent level - `"sum"` means that values from the child levels are summed up for the parent level
- `"avg"` means that values from the child levels are averaged for the parent level - `"avg"` means that values from the child levels are averaged for the parent level
- `scope`: Unused at the moment, should be something like `"node"`, `"socket"` or `"cpu"` - `scope`: Unused at the moment, should be something like `"node"`, `"socket"` or `"cpu"`
- `nats`: Url of NATS.io server (The `updates` channel will be subscribed for metrics) - `nats`: Url of NATS.io server (The `updates` channel will be subscribed for metrics), example: "nats://localhost:4222"
- `http-api-address`: Where to listen via HTTP, example: ":8080"
- `jwt-public-key`: Base64 encoded string, use this to verify requests to the HTTP API - `jwt-public-key`: Base64 encoded string, use this to verify requests to the HTTP API
- `retention-on-memory`: Keep all values in memory for at least that amount of seconds
### Test the complete setup (excluding ClusterCockpit itself) ### Test the complete setup (excluding ClusterCockpit itself)

View File

@ -25,6 +25,7 @@ type Config struct {
RetentionInMemory int `json:"retention-in-memory"` RetentionInMemory int `json:"retention-in-memory"`
Nats string `json:"nats"` Nats string `json:"nats"`
JwtPublicKey string `json:"jwt-public-key"` JwtPublicKey string `json:"jwt-public-key"`
HttpApiAddress string `json:"http-api-address"`
Checkpoints struct { Checkpoints struct {
Interval int `json:"interval"` Interval int `json:"interval"`
RootDir string `json:"directory"` RootDir string `json:"directory"`
@ -232,16 +233,19 @@ func main() {
intervals(&wg, ctx) intervals(&wg, ctx)
wg.Add(2) wg.Add(1)
go func() { go func() {
err := StartApiServer(":8080", ctx) err := StartApiServer(conf.HttpApiAddress, ctx)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
wg.Done() wg.Done()
}() }()
if len(conf.Nats) != 0 {
wg.Add(1)
go func() { go func() {
// err := ReceiveNats(conf.Nats, handleLine, runtime.NumCPU()-1, ctx) // err := ReceiveNats(conf.Nats, handleLine, runtime.NumCPU()-1, ctx)
err := ReceiveNats(conf.Nats, handleLine, 1, ctx) err := ReceiveNats(conf.Nats, handleLine, 1, ctx)
@ -251,6 +255,7 @@ func main() {
} }
wg.Done() wg.Done()
}() }()
}
wg.Wait() wg.Wait()