Skip to content
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

nsqadmin: fix large graph formulas #153

Merged
merged 2 commits into from
Feb 19, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions nsqadmin/graph_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func startEndForTimeframe(t time.Duration) (string, string) {

func (t *Topic) Target(g *GraphOptions, key string) (string, string) {
color := "blue"
if key == "depth" || key == "requeue_count" {
if key == "depth" || key == "deferred_count" {
color = "red"
}
target := fmt.Sprintf("%snsq.*.topic.%s.%s", g.Prefix(metricType(key)), t.TopicName, key)
Expand All @@ -150,7 +150,7 @@ func (t *Topic) Sparkline(g *GraphOptions, key string) template.URL {

func (t *Topic) LargeGraph(g *GraphOptions, key string) template.URL {
target, color := t.Target(g, key)
return g.LargeGraph(target, color)
return g.LargeGraph(key, target, color)
}

func (t *Topic) Rate(g *GraphOptions) string {
Expand All @@ -164,7 +164,7 @@ func (t *TopicHostStats) Target(g *GraphOptions, key string) (string, string) {
h = "*"
}
color := "blue"
if key == "depth" || key == "requeue_count" {
if key == "depth" || key == "deferred_count" {
color = "red"
}
target := fmt.Sprintf("%snsq.%s.topic.%s.%s", g.Prefix(metricType(key)), h, t.Topic, key)
Expand All @@ -176,7 +176,7 @@ func (t *TopicHostStats) Sparkline(g *GraphOptions, key string) template.URL {
}
func (t *TopicHostStats) LargeGraph(g *GraphOptions, key string) template.URL {
target, color := t.Target(g, key)
return g.LargeGraph(target, color)
return g.LargeGraph(key, target, color)
}
func (t *TopicHostStats) Rate(g *GraphOptions) string {
target, _ := t.Target(g, "message_count")
Expand All @@ -186,7 +186,7 @@ func (t *TopicHostStats) Rate(g *GraphOptions) string {
func metricType(key string) string {
metricType := "counter"
switch key {
case "backend_depth", "depth", "clients":
case "backend_depth", "depth", "clients", "in_flight_count":
metricType = "gauge"
}
return metricType
Expand All @@ -198,7 +198,7 @@ func (c *ChannelStats) Target(g *GraphOptions, key string) (string, string) {
h = graphiteHostKey(c.HostAddress)
}
color := "blue"
if key == "depth" || key == "requeue_count" {
if key == "depth" || key == "deferred_count" {
color = "red"
}
target := fmt.Sprintf("%snsq.%s.topic.%s.channel.%s.%s", g.Prefix(metricType(key)), h, c.Topic, c.ChannelName, key)
Expand All @@ -210,7 +210,7 @@ func (c *ChannelStats) Sparkline(g *GraphOptions, key string) template.URL {
}
func (c *ChannelStats) LargeGraph(g *GraphOptions, key string) template.URL {
target, color := c.Target(g, key)
return g.LargeGraph(target, color)
return g.LargeGraph(key, target, color)
}
func (t *ChannelStats) Rate(g *GraphOptions) string {
target, _ := t.Target(g, "message_count")
Expand All @@ -235,15 +235,19 @@ func (g *GraphOptions) Sparkline(target string, color string) template.URL {
return template.URL(fmt.Sprintf("%s/render?%s", g.GraphiteUrl, params.Encode()))
}

func (g *GraphOptions) LargeGraph(target string, color string) template.URL {
func (g *GraphOptions) LargeGraph(key string, target string, color string) template.URL {
params := url.Values{}
params.Set("height", "450")
params.Set("width", "800")
params.Set("bgcolor", "ff000000") // transparent
params.Set("fgcolor", "999999")
params.Set("colorList", color)
params.Set("yMin", "0")
params.Set("target", fmt.Sprintf("scaleToSeconds(summarize(sumSeries(%s),\"1min\"),1)", target))
target = fmt.Sprintf(`summarize(sumSeries(%s),"1min","avg")`, target)
if metricType(key) != "gauge" {
target = fmt.Sprintf(`scaleToSeconds(%s,1)`, target)
}
params.Set("target", target)
params.Set("from", g.GraphInterval.GraphFrom)
params.Set("until", g.GraphInterval.GraphUntil)
return template.URL(fmt.Sprintf("%s/render?%s", g.GraphiteUrl, params.Encode()))
Expand Down
3 changes: 1 addition & 2 deletions nsqd/statsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@ func statsdLoop(addr string, prefix string, interval int) {
stat = fmt.Sprintf("topic.%s.channel.%s.backend_depth", topic.TopicName, channel.ChannelName)
statsd.Gauge(stat, int(channel.BackendDepth))

diff = uint64(channel.InFlightCount - lastChannel.InFlightCount)
stat = fmt.Sprintf("topic.%s.channel.%s.in_flight_count", topic.TopicName, channel.ChannelName)
statsd.Incr(stat, int(diff))
statsd.Gauge(stat, int(channel.InFlightCount))

diff = uint64(channel.DeferredCount - lastChannel.DeferredCount)
stat = fmt.Sprintf("topic.%s.channel.%s.deferred_count", topic.TopicName, channel.ChannelName)
Expand Down