-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TASK] add database type graphite #65
Conversation
} | ||
|
||
node_prefix := MeasurementNode + `.` + stats.NodeID + `.` + strings.Replace(nodeinfo.Hostname, ".", "__", -1) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a small inline function to dry up your code:
addField := func(name string, value interface{}) {
fields = append(fields, graphigo.Metric{Name: node_prefix + "." + name, Value: value})
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much better 👍
database/graphite/node.go
Outdated
{Name: node_prefix + ".proc.running", Value: stats.Processes.Running}, | ||
{Name: node_prefix + ".clients.wifi", Value: stats.Clients.Wifi}, | ||
{Name: node_prefix + ".clients.wifi24", Value: stats.Clients.Wifi24}, | ||
{Name: node_prefix + ".clients.wifi5", Value: stats.Clients.Wifi5}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better use wifi11a
and wifi11g
in the name.
The old labels wifi24
and wifi5
are deprecated.
database/graphite/database.go
Outdated
return | ||
} | ||
} else { | ||
defer c.Close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defer c.Close()
vor die Schleife schreiben?
database/graphite/database.go
Outdated
|
||
func (c *Connection) addWorker() { | ||
defer c.wg.Done() | ||
for c.Connection != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hier kannst du einfach über die Punkte iterieren:
for point := range c.points {
database/graphite/database.go
Outdated
} | ||
|
||
func (c *Connection) Close() { | ||
if c.client.Connection != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hier den Channel schließen close(c.points)
I still have to run some tests with our local network - waiting on more storage on our graphite node ;-) |
OK, thanks a lot. Your code looks fine for me now. |
database/graphite/node.go
Outdated
addField("proc.running", stats.Processes.Running) | ||
addField("clients.wifi", stats.Clients.Wifi) | ||
addField("clients.wifi11a", stats.Clients.Wifi24) | ||
addField("clients.wifi11g", stats.Clients.Wifi5) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just 11a
and 11g
instead of wifi11a
and wifi11g
? It implies wifi. Any other opinions?
database/graphite/global.go
Outdated
"github.com/fgrosse/graphigo" | ||
) | ||
|
||
func (c *Connection) InserGlobals(stats *runtime.GlobalStats, time time.Time) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need a t
ee in the Morning 😄 : InsertGlobals
Without the tipping mistake, it looks good for me as well. |
I'll try to write a bunch of tests. It probably will be a copy of the influxdb stuff (for the most part)… |
I've just tried to figure how I can easily mock out that function... Any ideas? I've only seen some ugly hacks or passing the function as a parameter to the real implementation so I can pass the mock in the tests.. |
I just realized that yanic is currently dieing whenever the carbon-cache/relay (graphite backend) is being restarted. The influxdb backend seems to have a similar issue - since log.Fatal is used? Are there any plans to support reconnect? |
Plans, No. A reconnect was not necessary till now. There is a RFC: #61 A reconnect would be a restart of yanic by systemd. |
I'll try to get some reconnect code in during the following days. In the mean time I discovered that often datapoints are missing in graphite (even after raising all the carbon limits): https://stats.test.h4ck.space/dashboard/db/new-dashboard-copy?orgId=1 Any ideas where that comes from? Yanic is set to query nodes every minute. Graphite is configured for 1 datapoint every 60 seconds. The version statistics look okay but the others are often missing data. |
database/graphite/node.go
Outdated
addField("time.idle", int64(stats.Idletime)) | ||
addField("proc.running", stats.Processes.Running) | ||
addField("clients.wifi", stats.Clients.Wifi) | ||
addField("clients.wifi11a", stats.Clients.Wifi24) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
11a is 5GHz and 11g is 2.4GHz, so they are interchanged. But why not keeping wfi5 and wifi24 as used in database/graphite/global.go
and database/influxdb/node.go
? Additional 5GHz is not only 11a but even 11n and 11ac and 2.4GHz is even 11b and 11n.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. Then revert it to wifi24 and wifi5.
@andir say in IRC, That he is ready with this PR. The missing Point we think the problem is, how graphite and yanic works. Buy graphite wants to have A possible solution configuration |
@andir Does the response of the node really reach yanic? Please add a |
The wifi metrics are reverted. |
Simply adding a delay before the first run would solve this problem. This should be an seperate issue. |
I've spent the last night hacking on a graphite database backend.