package apps import ( "encoding/json" "fmt" "net/http" "os" "github.com/prometheus/client_golang/prometheus" ) type apiResponse struct { Version string `json:"version"` } func Nextcloud(m Metrics) { hostname, err := os.Hostname() if err != nil { return } resp, err := http.Get(fmt.Sprintf("https://%s/status.php", hostname)) if err != nil { return } defer resp.Body.Close() var res = apiResponse{} json.NewDecoder(resp.Body).Decode(&res) m.Nextcloud.With(prometheus.Labels{"version": res.Version}).Set(1) }