revise readme

This commit is contained in:
Hannes Mehnert 2022-01-27 14:54:40 +01:00
parent 938406313e
commit 8e7050acf3
2 changed files with 23 additions and 18 deletions

View file

@ -2,4 +2,21 @@
Using Influx, Telegraf, etc.
![Monitoring](https://raw.githubusercontent.com/hannesm/monitoring-experiments/master/one.png)
![Monitoring](https://raw.githubusercontent.com/roburio/monitoring-experiments/master/one.png)
# Dynamic adjustments of Log level and Metrics reporting
The create function has a *listener_port* argument. If this is provided, then
on the given port TCP connections to the unikernel are possible. Each connection
can transmit a command (as text) to adjust log level and enable or disable
metrics sources:
The log level (prefix `L`) is specified, the same as the command-line argument `-l`:
- `L*:debug` all log sources are enabled on the *debug* level
- `Lmonitoring-experiments:error` the log source monitoring-experiments is set to the *error* level
- `L*:info,monitoring-experiments:debug` all log sources are enabled on the *info* level, and the log source monitoring-experiments is set to the *debug* level
The metrics (prefix `M`) sources can be enabled and disabled based on source name.
First, if present, the all command is executed, then specific sources:
- `M*:disable,memory:enable,net-solo5:enable` disables all metrics sources, and then enables *memory* and *net-solo5*
- `Mnet-solo5:disable` disables the *net-solo5* metrics source.

View file

@ -81,34 +81,22 @@ let adjust_metrics s =
| [ src ; en ] ->
let* en_or_d = enable_of_str en in
Ok (`Src src, en_or_d)
| [ "src" ; src ; en ] ->
let* en_or_d = enable_of_str en in
Ok (`Src src, en_or_d)
| [ "tag" ; src ; en ] ->
let* en_or_d = enable_of_str en in
Ok (`Tag src, en_or_d)
| _ -> Error ("couldn't decode metrics " ^ s))
(String.split_on_char ',' s)
in
let* (all, tags, srcs) =
let* (all, srcs) =
List.fold_left (fun acc t ->
let* (all, tags, srcs) = acc in
let* (all, srcs) = acc in
let* t = t in
match t with
| `All, en_or_d -> Ok (Some en_or_d, tags, srcs)
| `Src s, en_or_d -> Ok (all, tags, (s, en_or_d) :: srcs)
| `Tag t, en_or_d -> Ok (all, (t, en_or_d) :: tags, srcs))
(Ok (None, [], [])) ts
| `All, en_or_d -> Ok (Some en_or_d, srcs)
| `Src s, en_or_d -> Ok (all, (s, en_or_d) :: srcs))
(Ok (None, [])) ts
in
(match all with
| Some `Enable -> Metrics.enable_all ()
| Some `Disable -> Metrics.disable_all ()
| None -> ());
List.iter
(function
| t, `Enable -> Metrics.enable_tag t
| t, `Disable -> Metrics.disable_tag t)
tags ;
List.iter (fun (src, e_or_d) ->
match List.find_opt (fun s -> Metrics.Src.name s = src) (Metrics.Src.list ()), e_or_d with
| Some src, `Enable -> Metrics.Src.enable src