-
-
Notifications
You must be signed in to change notification settings - Fork 197
Conversation
Hi @yazgoo, Thank you for your contribution! We really value the time you've taken to put this together. Before we proceed with reviewing this pull request, please sign the Lightbend Contributors License Agreement: |
Hi @yazgoo, Thank you for your contribution! We really value the time you've taken to put this together. Before we proceed with reviewing this pull request, please sign the Lightbend Contributors License Agreement: |
I signed the CLA |
Thanks @yazgoo. I'll review this shortly. |
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.
Thanks a lot for diving into this. This project was always meant as a Prometheus project, but I don't have any particular objection to supporting Graphite. Instead of mixing the implementation into the PrometheusEndpointSink
I would ask that you create a new GraphiteEndpointSink
. Since there will now be two available sinks some thought should be given to the design on how to plug and play one (or both?) if it makes sense. We should also try to have at least testing in place, maybe even some integration tests. Are you open to iterating on this further?
Thanks @seglo, 👌 for iterating on this. |
👌 graphite: add periodInSecond conf and stop 🎨 remove graphite bridge 🥅 handle exceptions
6565a3d
to
d906ed7
Compare
@seglo PR ready for review |
creating one metric sink dedicated to graphite
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.
The reporter abstraction is looking really good! I made some comments about how I would like to see a reporter's creation more config generated.
Please make some updates to the README too. You don't need to mention Graphite with every mention of Prometheus. A separate section would be alright. You should also update the configuration section in the "Run Standalone" section to document graphite config.
Do you use the Helm chart for deployment to Kubernetes? If so, can you update that as well? If not, I'll do it.
def apply(metricWhitelist: List[String], clusterGlobalLabels: ClusterGlobalLabels, | ||
graphiteConfig: Option[GraphiteConfig]): MetricsSink = { | ||
Try(new GraphiteEndpointSink(metricWhitelist, clusterGlobalLabels, graphiteConfig)) | ||
.fold(t => throw new Exception("Could not create Prometheus Endpoint", t), sink => sink) |
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.
Update failure message
} | ||
} | ||
|
||
def metricNameToGraphiteMetricName(metricValue: MetricValue): String = { |
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'm not sure I understand what's happening here. The metrics are already snakecase. Can you add a scaladoc comment with an example of the conversion?
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 @example
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 see.
Metrics.definitions, appConfig.metricWhitelist, appConfig.clustersGlobalLabels(), server, CollectorRegistry.defaultRegistry | ||
)) | ||
), | ||
KafkaClusterManager.NamedCreator( |
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'd prefer to only create the graphite-lag-reporter
if its config exists, otherwise it seems like a waste to create it at all and report all metrics to it.
@@ -18,6 +18,11 @@ import scala.util.Try | |||
object AppConfig { |
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.
Now that we have more than 1 reporter lets generate them based on configuration and only create them when necessary. Example application.conf
:
kafka-lag-exporter {
reporters {
prometheus {
port = 8000
}
graphite {
host = "foo"
port = 9999
}
}
}
@@ -134,6 +147,7 @@ final case class AppConfig(pollInterval: FiniteDuration, lookupTableSize: Int, p | |||
|Prometheus metrics whitelist: [${metricWhitelist.mkString(", ")}] |
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.
We can rename this to "metrics whitelist"
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.
Add an indented section for prometheus like you did for Graphite
Prometheus:
Port: $prometheusPort
} | ||
} | ||
|
||
override def remove(m: RemoveMetric): Unit = { |
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.
This is used in prometheus to unpublish a metric for a consumer group that disappears. If a consumer group isn't reported for awhile and we don't push metrics for it to Graphite, what would the Graphite metric for that now removed consumed group look like? Do we need to worry about unpublishing metrics?
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 don't think in graphite you have to unregister a metric since graphite is push based.
When the max retention is reached the metric will be totally removed by graphite itself.
for (host <- Try(c.getString("graphite-host")); | ||
port <- Try(c.getInt("graphite-port")), | ||
) yield GraphiteConfig( | ||
host, port, Try(c.getString("graphite-prefix")).toOption)).toOption | ||
val pollInterval = c.getDuration("poll-interval").toScala | ||
val lookupTableSize = c.getInt("lookup-table-size") | ||
val port = c.getInt("port") |
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.
Support getting the prometheus port from here, and from the new report configuration section I mentioned above. Use kafka-lag-exporter.port
as the default and override with kafka-lag-exporter.prometheus.port
if it exists. This will maintain backwards compatibility.
Please update the reference.conf
to include the kafka-lag-exporter.reporters.prometheus
section.
40da0e9
to
d4cff9d
Compare
Unfortunately I'm not using kafka-lag-exporter w/ kubernetes :) |
ready for review @seglo |
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.
LGTM. Just a few minor docs fixes to add.
@@ -224,20 +224,32 @@ To run the project in standalone mode you must first define a configuration `app | |||
contain at least connection info to your Kafka cluster (`kafka-lag-exporter.clusters`). All other configuration has | |||
defaults defined in the project itself. See [`reference.conf`](./src/main/resources/reference.conf) for defaults. | |||
|
|||
### Reporters |
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.
Please add this section to the ToC.
README.md
Outdated
| Key | Default | Description | | ||
|-----------------------------|--------------------|---------------------------------------------------------------------------------------------------------------------------------------| | ||
| `reporters.prometheus.port` | `8000` | The port to run the Prometheus endpoint on | | ||
| `reporters.graphite.host` | None | The graphite host to send metrics to (if not set, will not output to grahpite) | |
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.
| `reporters.graphite.host` | None | The graphite host to send metrics to (if not set, will not output to grahpite) | | |
| `reporters.graphite.host` | None | The graphite host to send metrics to (if not set, will not output to graphite) | |
README.md
Outdated
| `reporters.prometheus.port` | `8000` | The port to run the Prometheus endpoint on | | ||
| `reporters.graphite.host` | None | The graphite host to send metrics to (if not set, will not output to grahpite) | | ||
| `reporters.graphite.port` | None | The graphite port to send metrics to (if not set, will not output to graphite) | | ||
| `reporters.graphite.prefix` | None | The graphite metric prefix (if not set, prefix will be embty) | |
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.
| `reporters.graphite.prefix` | None | The graphite metric prefix (if not set, prefix will be embty) | | |
| `reporters.graphite.prefix` | None | The graphite metric prefix (if not set, prefix will be empty) | |
} | ||
} | ||
|
||
def metricNameToGraphiteMetricName(metricValue: MetricValue): String = { |
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 see.
Great, thanks for your patience @yazgoo. I'll push a release soon. |
Thank you ! |
This allows to specify a graphite output via the following config:
This translates prometheus labels into a graphite metric path.