-
Notifications
You must be signed in to change notification settings - Fork 6
/
metrics.go
80 lines (50 loc) · 2.06 KB
/
metrics.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package gounity
import (
"fmt"
"strconv"
types "github.com/equelin/gounity/types/v1"
)
//NewMetricRealTimeQuery purpose is to create a real time query.
func (session *Session) NewMetricRealTimeQuery(paths []string, interval uint32) (resp *types.MetricRealTimeQueryResponse, err error) {
type paramNewMetricRealTimeQuery struct {
Paths []string `json:"paths"`
Interval uint32 `json:"interval"`
}
jsonData := paramNewMetricRealTimeQuery{
Paths: paths,
Interval: interval,
}
err = session.Request("POST", "/api/types/metricRealTimeQuery/instances", "", "", true, jsonData, &resp)
return resp, err
}
//DeleteMetricRealTimeQuery purpose is to delete a real time query.
func (session *Session) DeleteMetricRealTimeQuery(queryID int) error {
URI := fmt.Sprintf("/api/instances/metricRealTimeQuery/%s", strconv.Itoa(queryID))
fmt.Println(URI)
err := session.Request("DELETE", URI, "", "", false, nil, "")
return err
}
//GetMetricRealTimeQueryResult tototo
func (session *Session) GetMetricRealTimeQueryResult(queryID int) (resp *types.MetricRealTimeQueryResult, err error) {
filter := fmt.Sprintf("queryId eq %s", strconv.Itoa(queryID))
fields := "queryId,path,timestamp,values"
URI := "/api/types/metricQueryResult/instances"
err = session.Request("GET", URI, fields, filter, true, nil, &resp)
return resp, err
}
//GetmetricValue Historical values for requested metrics
func (session *Session) GetmetricValue(path string) (resp *types.MetricValueResponse, err error) {
filter := fmt.Sprintf("path eq \"%s\"", path)
//fields := "queryId,path,timestamp,values"
URI := "/api/types/metricValue/instances"
err = session.Request("GET", URI, "", filter, true, nil, &resp)
return resp, err
}
//GetkpiValue Historical values for requested metrics
func (session *Session) GetkpiValue(path string) (resp *types.KpiValueResponse, err error) {
filter := fmt.Sprintf("path eq \"%s\"", path)
//fields := "queryId,path,timestamp,values"
URI := "/api/types/kpiValue/instances"
err = session.Request("GET", URI, "", filter, true, nil, &resp)
return resp, err
}