spring-actuator.el
author Oleksandr Gavenko <gavenkoa@gmail.com>
Sun, 19 Feb 2017 14:38:21 +0200
changeset 1483 a25f209ebf15
child 1484 8fe1eaf66e94
permissions -rw-r--r--
Library to access Spring Actuator endpoints.


(defvar my/spring-actuator-server-history nil)
(defvar my/spring-actuator-last-server "http://localhost:8080")
(defvar my/spring-actuator-path-history nil)
(defvar my/spring-actuator-path-completion
  '("actuator" "auditevents" "autoconfig" "beans" "configprops" "dump" "env" "flyway" "health" "heapdump"
    "info" "jolokia" "liquibase" "logfile" "loggers" "mappings" "metrics" "shutdown" "trace")))

(defun my/spring-actuator (server path)
  (interactive (list (read-string "Server: " my/spring-actuator-last-server 'my/spring-actuator-server-history)
                     (completing-read "Path: " my/spring-actuator-path-completion nil nil "" 'my/spring-actuator-path-history)))
  (setq my/spring-actuator-last-server server)
  (let ( (bufname (format "actuator: %s" path)) )
    (when (get-buffer bufname)
      (kill-buffer bufname))
    (switch-to-buffer (url-retrieve-synchronously (format "%s/%s" server path)))
    (rename-buffer bufname)
    (goto-char (point-min))
    (re-search-forward "^$" nil 'move)
    (forward-char)
    (delete-region (point-min) (point))
    (json-pretty-print-buffer)
    (json-mode) ))