summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ac8367f)
raw | patch | inline | side by side (parent: ac8367f)
author | Sebastian Harl <sh@tokkee.org> | |
Wed, 13 May 2015 20:34:43 +0000 (22:34 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Wed, 13 May 2015 20:34:43 +0000 (22:34 +0200) |
The new type allows to add further information to a metric.
graph/graph.go | patch | blob | history | |
server/graph.go | patch | blob | history |
diff --git a/graph/graph.go b/graph/graph.go
index cb1852cbf71fc6ed5c76364e6fd9a756d43627df..7985dc47f0daba74ff952c48d50cf830b1445c8f 100644 (file)
--- a/graph/graph.go
+++ b/graph/graph.go
"github.com/sysdb/go/sysdb"
)
-// A Graph represents a single graph. It may reference multiple time-series.
+// A Metric represents a single data-source of a graph.
+type Metric struct {
+ // The unique identifier of the metric.
+ Hostname, Identifier string
+
+ // Attributes describing details of the metric.
+ Attributes map[string]string
+}
+
+// A Graph represents a single graph. It may reference multiple data-sources.
type Graph struct {
// Time range of the graph.
Start, End time.Time
- // Metrics: {<hostname>, <identifier>}
- Metrics [][2]string
+ // Content of the graph.
+ Metrics []Metric
}
type pl struct {
ts int // Index of the current time-series.
}
-func (p *pl) addTimeseries(c *client.Client, metric [2]string, start, end time.Time) error {
- q, err := client.QueryString("TIMESERIES %s.%s START %s END %s", metric[0], metric[1], start, end)
+func (p *pl) addTimeseries(c *client.Client, metric Metric, start, end time.Time) error {
+ q, err := client.QueryString("TIMESERIES %s.%s START %s END %s",
+ metric.Hostname, metric.Identifier, start, end)
if err != nil {
return fmt.Errorf("Failed to retrieve graph data: %v", err)
}
diff --git a/server/graph.go b/server/graph.go
index 9c679bc5a0386a9ed48a4900a8a5c7d9a7f7af27..7509485930e23f60f1dc140e8776d3d0b473c8b5 100644 (file)
--- a/server/graph.go
+++ b/server/graph.go
g := &graph.Graph{
Start: start,
End: end,
- Metrics: [][2]string{{req.args[0], req.args[1]}},
+ Metrics: []graph.Metric{{Hostname: req.args[0], Identifier: req.args[1]}},
}
p, err := g.Plot(s.c)
if err != nil {