metrics.go 955 B

12345678910111213141516171819202122232425262728
  1. package functions
  2. import (
  3. "fmt"
  4. "net/http"
  5. "github.com/gravitl/netmaker/models"
  6. )
  7. // GetNodeMetrics - fetch a single node's metrics
  8. func GetNodeMetrics(networkName, nodeID string) *models.Metrics {
  9. return request[models.Metrics](http.MethodGet, fmt.Sprintf("/api/metrics/%s/%s", networkName, nodeID), nil)
  10. }
  11. // GetNetworkNodeMetrics - fetch an entire network's metrics
  12. func GetNetworkNodeMetrics(networkName string) *models.NetworkMetrics {
  13. return request[models.NetworkMetrics](http.MethodGet, "/api/metrics/"+networkName, nil)
  14. }
  15. // GetAllMetrics - fetch all metrics
  16. func GetAllMetrics() *models.NetworkMetrics {
  17. return request[models.NetworkMetrics](http.MethodGet, "/api/metrics", nil)
  18. }
  19. // GetNetworkExtMetrics - fetch external client metrics belonging to a network
  20. func GetNetworkExtMetrics(networkName string) *map[string]models.Metric {
  21. return request[map[string]models.Metric](http.MethodGet, "/api/metrics-ext/"+networkName, nil)
  22. }