Debian Codegraph @

v1/stats_test.go

raw
1 package client_test
2
3 import (
4 "fmt"
5 "io/ioutil"
6 "testing"
7
8 "github.com/influxdb/enterprise-client/v1"
9 "github.com/stretchr/testify/require"
10 )
11
12 func Test_Stats_Implements_Saveable(t *testing.T) {
13 r := require.New(t)
14 r.Implements((*client.Saveable)(nil), client.Stats{})
15 }
16
17 // Example of saving Stats data to Enterprise
18 func Example_saveStats() {
19 c := client.New("token-goes-here")
20 // override the URL for testing
21 c.URL = "https://enterprise.staging.influxdata.com"
22
23 st := client.Stats{
24 ClusterID: "clus1",
25 ServerID: "serv1",
26 Product: "influxdb",
27 Data: []client.StatsData{
28 client.StatsData{
29 Name: "engine",
30 Tags: client.Tags{
31 "path": "/home/philip/.influxdb/data/_internal/monitor/1",
32 "version": "bz1",
33 },
34 Values: client.Values{
35 "blks_write": 39,
36 "blks_write_bytes": 2421,
37 "blks_write_bytes_c": 2202,
38 "points_write": 39,
39 "points_write_dedupe": 39,
40 },
41 },
42 },
43 }
44
45 res, err := c.Save(st)
46 fmt.Printf("err: %s\n", err)
47 b, _ := ioutil.ReadAll(res.Body)
48 fmt.Printf("b: %s\n", b)
49 }