File: doc.go

package info (click to toggle)
golang-github-gophercloud-utils 0.0~git20231010.80377ec-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 816 kB
  • sloc: sh: 20; makefile: 7
file content (65 lines) | stat: -rw-r--r-- 1,488 bytes parent folder | download | duplicates (3)
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
/*
Package metrics provides the ability to retrieve metrics through the Gnocchi API.

Example of Listing metrics

	listOpts := metrics.ListOpts{
		Limit: 25,
	}

	allPages, err := metrics.List(gnocchiClient, listOpts).AllPages()
	if err != nil {
		panic(err)
	}

	allMetrics, err := metrics.ExtractMetrics(allPages)
	if err != nil {
		panic(err)
	}

	for _, metric := range allMetrics {
		fmt.Printf("%+v\n", metric)
	}

Example of Getting a metric

	metricID = "9e5a6441-1044-4181-b66e-34e180753040"
	metric, err := metrics.Get(gnocchiClient, metricID).Extract()
	if err != nil {
		panic(err)
	}

Example of Creating a metric and link it to an existing archive policy

	createOpts := metrics.CreateOpts{
		ArchivePolicyName: "low",
		Name: "network.incoming.packets.rate",
		Unit: "packet/s",
	}
	metric, err := metrics.Create(gnocchiClient, createOpts).Extract()
	if err != nil {
		panic(err)
	}

Example of Creating a metric without an archive policy, assuming that Gnocchi has the needed
archive policy rule and can assign the policy automatically

	createOpts := metrics.CreateOpts{
		ResourceID: "1f3a0724-1807-4bd1-81f9-ee18c8ff6ccc",
		Name: "memory.usage",
		Unit: "MB",
	}
	metric, err := metrics.Create(gnocchiClient, createOpts).Extract()
	if err != nil {
		panic(err)
	}

Example of Deleting a Gnocchi metric

	metricID := "01b2953e-de74-448a-a305-c84440697933"
	err := metrics.Delete(gnocchiClient, metricID).ExtractErr()
	if err != nil {
		panic(err)
	}
*/
package metrics