diff --git a/README.md b/README.md index b313e37..61f50ab 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/src/monitoring_experiments.ml b/src/monitoring_experiments.ml index 0d764f2..c0174ed 100644 --- a/src/monitoring_experiments.ml +++ b/src/monitoring_experiments.ml @@ -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