From 5a789e724da44ae0f9540b1add7a0c967695147d Mon Sep 17 00:00:00 2001 From: Tim Harper Date: Tue, 13 Feb 2018 12:12:48 -0700 Subject: [PATCH] Add support for Graphite reporter interval parameter (#6010) 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 --- docs/docs/command-line-flags.md | 4 ++-- src/main/scala/mesosphere/marathon/Main.scala | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/docs/docs/command-line-flags.md b/docs/docs/command-line-flags.md index 9098fcfb3c7..208d2b6e4e5 100644 --- a/docs/docs/command-line-flags.md +++ b/docs/docs/command-line-flags.md @@ -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. * v0.13.0 `--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 diff --git a/src/main/scala/mesosphere/marathon/Main.scala b/src/main/scala/mesosphere/marathon/Main.scala index 01e5057f751..4b723beae2c 100644 --- a/src/main/scala/mesosphere/marathon/Main.scala +++ b/src/main/scala/mesosphere/marathon/Main.scala @@ -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 } @@ -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 }