Skip to content

Commit

Permalink
Add support for Graphite reporter interval parameter (#6010)
Browse files Browse the repository at this point in the history
Also, fix documentation for graphite reporter: tcp is not allowed. Log a warning if a protocol other than udp is specified.

JIRA issues: MARATHON-8080, MARATHON-8079
  • Loading branch information
Tim Harper committed Feb 13, 2018
1 parent 59f813b commit 5a789e7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions docs/docs/command-line-flags.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,8 @@ The Web Site flags control the behavior of Marathon's web site, including the us
Enabling this might noticeably degrade performance but it helps finding performance problems.
These measurements can be disabled with --disable_metrics. Other metrics are not affected.
* <span class="label label-default">v0.13.0</span> `--reporter_graphite` (Optional. Default: disabled):
Report metrics to [Graphite](http://graphite.wikidot.com) as defined by the given URL.
Example: `tcp://localhost:2003?prefix=marathon-test&interval=10`
Report metrics to [Graphite](http://graphite.wikidot.com) (StatsD) as defined by the given URL.
Example: `udp://localhost:2003?prefix=marathon-test&interval=10`
The URL can have several parameters to refine the functionality.
* prefix: (Default: None) the prefix for all metrics
* interval: (Default: 10) the interval to report to graphite in seconds
Expand Down
13 changes: 10 additions & 3 deletions src/main/scala/mesosphere/marathon/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package mesosphere.marathon
import java.net.URI

import akka.actor.ActorSystem
import akka.http.scaladsl.model.Uri
import com.google.common.util.concurrent.ServiceManager
import com.google.inject.{ Guice, Module }
import com.typesafe.config.{ Config, ConfigFactory }
Expand Down Expand Up @@ -61,11 +62,17 @@ class MarathonApp(args: Seq[String]) extends AutoCloseable with StrictLogging {
""".stripMargin
}
val statsd = cliConf.graphite.get.map { urlStr =>
val url = new URI(urlStr)
val url = Uri(urlStr)

if (url.scheme.toLowerCase() != "udp") {
logger.warn(s"Graphite reporter protocol ${url.scheme} is not supported; using UDP")
}
val params = url.query()
s"""
|kamon.statsd {
| hostname: ${url.getHost}
| port: ${if (url.getPort == -1) 8125 else url.getPort}
| hostname: ${url.authority.host}
| port: ${if (url.authority.port == 0) 8125 else url.authority.port}
| flush-interval: ${params.collectFirst { case ("interval", iv) => iv.toInt }.getOrElse(10)} seconds
|}
""".stripMargin
}
Expand Down

0 comments on commit 5a789e7

Please sign in to comment.