forked from galaxydi/go-loghub
-
Notifications
You must be signed in to change notification settings - Fork 113
/
client_metric_store.go
55 lines (50 loc) · 1.34 KB
/
client_metric_store.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
package sls
import "time"
// CreateMetricStore .
func (c *Client) CreateMetricStore(project string, metricStore *LogStore) error {
metricStore.TelemetryType = "Metrics"
err := c.CreateLogStoreV2(project, metricStore)
if err != nil {
return err
}
time.Sleep(time.Second * 3)
subStore := &SubStore{}
subStore.Name = "prom"
subStore.SortedKeyCount = 2
subStore.TimeIndex = 2
subStore.TTL = metricStore.TTL
subStore.Keys = append(subStore.Keys, SubStoreKey{
Name: "__name__",
Type: "text",
}, SubStoreKey{
Name: "__labels__",
Type: "text",
}, SubStoreKey{
Name: "__time_nano__",
Type: "long",
}, SubStoreKey{
Name: "__value__",
Type: "double",
})
if !subStore.IsValid() {
panic("metric store invalid")
}
return c.CreateSubStore(project, metricStore.Name, subStore)
}
// UpdateMetricStore .
func (c *Client) UpdateMetricStore(project string, metricStore *LogStore) error {
metricStore.TelemetryType = "Metrics"
err := c.UpdateLogStoreV2(project, metricStore)
if err != nil {
return err
}
return c.UpdateSubStoreTTL(project, metricStore.Name, metricStore.TTL)
}
// DeleteMetricStore .
func (c *Client) DeleteMetricStore(project, name string) error {
return c.DeleteLogStore(project, name)
}
// GetMetricStore .
func (c *Client) GetMetricStore(project, name string) (*LogStore, error) {
return c.GetLogStore(project, name)
}