Skip to content

Instantly share code, notes, and snippets.

@solarce
Last active December 13, 2017 04:58
Show Gist options
  • Save solarce/2f3b5e8ee1f9fe93bd47 to your computer and use it in GitHub Desktop.
Save solarce/2f3b5e8ee1f9fe93bd47 to your computer and use it in GitHub Desktop.
An example YAML file to use with https://github.com/jmxtrans/jmxtrans/wiki/YAMLConfig for getting Kafka metrics and putting them into graphite. You must use v246 of jmxtrans though. You can grab the .jar I built from https://github.com/solarce/jmxtrans/releases/tag/v246. See https://github.com/solarce/chef-jmxtrans/releases/tag/v1.0.5 and https:…
# kafka_prod1.yaml
#
# The production kafka nodes for prod1
graphite_host: <%= node[:jmxtrans][:graphite][:host] %>
graphite_port: <%= node[:jmxtrans][:graphite][:port] %>
# Define sthe port that the hosts in this config listen for JMX on
# ** THIS PORT HAS TO BE THE SAME FOR ALL HOSTS **
query_port: 9999
# global_host_alias: Will accept a blank space if alias and host is provided in host sets
# ** LEAVE BLANK **
global_host_alias:
# Query definitions, every query needs
# - name - unique name
# - obj - shoudl be the mbean name
# - resultAlias - can be the same as name
# - attr - just use [], it's the wildcard
#
# from jmxtrans format, "name" must be given for referencing
# the query in host sets
queries:
- name: mempool
obj: "java.lang:type=MemoryPool,name=*"
resultAlias: "memorypool"
attr:
- "Usage"
- name: gc
obj: "java.lang:type=GarbageCollector,name=*"
resultAlias: "gc"
attr:
- "CollectionCount"
- "CollectionTime"
- name: hibernate
obj: "Hibernate:type=statistics,name=*"
resultAlias: "hibernate"
attr:
- "QueryExecutionMaxTime"
- "Queries"
- "TransactionCount"
- name: sys
obj: "java.lang:type=OperatingSystem"
resultAlias: "sys"
attr:
- "SystemLoadAverage"
- "AvailableProcessors"
- "TotalPhysicalMemorySize"
- "FreePhysicalMemorySize"
- "TotalSwapSpaceSize"
- "FreeSwapSpaceSize"
- "OpenFileDescriptorCount"
- "MaxFileDescriptorCount"
- name: threads
obj : "java.lang:type=Threading"
resultAlias: "threads"
attr:
- "DaemonThreadCount"
- "PeakThreadCount"
- "ThreadCount"
- "TotalStartedThreadCount"
# kafka related mBeans have literal double quotes in the names
- name: kafka_broker_topic_metrics
obj : "\"kafka.server\":type=\"BrokerTopicMetrics\",*"
resultAlias: "brokertopicmetrics"
attr:
- "MeanRate"
- "OneMinuteRate"
- "FiveMinuteRate"
- "FifteenMinuteRate"
- "Count"
# Define named sets of hosts that get the queries above
# query_names and hosts is a list
sets:
- setname: kafka_prod
query_names:
- mempool
- gc
- hibernate
- sys
- threads
- kafka_broker_topic_metrics
hosts:
# the current (v246) yaml2jmxtrans.py uses the following format
# - hostname;alias/rootPrefix
# We recommend just making the alias the same as the hostname, but
# you *must* use underscores instead of dots
# e.g. host1.example.com;host1_example_com/jmx
- kafka-prod1-0;kafka-prod1-0/jmx
- kafka-prod1-1;kafka-prod1-1/jmx
- kafka-prod1-2;kafka-prod1-2/jmx
- kafka-prod1-3;kafka-prod1-3/jmx
- kafka-prod1-4;kafka-prod1-4/jmx
{
"id": null,
"title": "Kafka Broker Metrics",
"originalTitle": "Kafka Broker Metrics",
"tags": [],
"style": "light",
"timezone": "browser",
"editable": true,
"hideControls": false,
"rows": [
{
"title": "Row1",
"height": "250px",
"editable": true,
"collapse": false,
"collapsable": true,
"panels": [
{
"span": 12,
"editable": true,
"type": "graph",
"loadingEditor": false,
"datasource": null,
"renderer": "flot",
"x-axis": true,
"y-axis": true,
"scale": 1,
"y_formats": [
"short",
"short"
],
"grid": {
"max": null,
"min": null,
"threshold1": 100,
"threshold2": 380,
"threshold1Color": "rgba(27, 58, 216, 0.27)",
"threshold2Color": "rgba(234, 112, 112, 0.22)",
"leftMax": null,
"rightMax": null,
"leftMin": null,
"rightMin": null,
"thresholdLine": false
},
"annotate": {
"enable": false
},
"resolution": 100,
"lines": true,
"fill": 1,
"linewidth": 3,
"points": false,
"pointradius": 2,
"bars": false,
"stack": false,
"legend": {
"show": true,
"values": true,
"min": false,
"max": false,
"current": true,
"total": false,
"avg": false,
"alignAsTable": true
},
"percentage": false,
"zerofill": true,
"nullPointMode": "connected",
"steppedLine": false,
"tooltip": {
"value_type": "cumulative",
"query_as_alias": true
},
"targets": [
{
"target": "sumSeries(jmx.kafka-prod1-*.*.AllTopicsMessagesInPerSec.OneMinuteRate)",
"hide": false
}
],
"aliasColors": {},
"title": "prod1 :: Total Messages In Per Second",
"leftYAxisLabel": "MessagesIn/Sec - 1 Minute",
"id": 1,
"seriesOverrides": []
},
{
"error": false,
"span": 12,
"editable": true,
"type": "graph",
"id": 3,
"datasource": null,
"renderer": "flot",
"x-axis": true,
"y-axis": true,
"scale": 1,
"y_formats": [
"short",
"short"
],
"grid": {
"leftMax": null,
"rightMax": null,
"leftMin": null,
"rightMin": null,
"threshold1": null,
"threshold2": null,
"threshold1Color": "rgba(216, 200, 27, 0.27)",
"threshold2Color": "rgba(234, 112, 112, 0.22)"
},
"annotate": {
"enable": false
},
"resolution": 100,
"lines": true,
"fill": 1,
"linewidth": 3,
"points": false,
"pointradius": 5,
"bars": false,
"stack": false,
"legend": {
"show": true,
"values": true,
"min": false,
"max": false,
"current": true,
"total": false,
"avg": false
},
"percentage": false,
"zerofill": true,
"nullPointMode": "connected",
"steppedLine": false,
"tooltip": {
"value_type": "cumulative",
"query_as_alias": true
},
"targets": [
{
"target": "jmx.kafka-prod1-*.*.AllTopicsMessagesInPerSec.OneMinuteRate"
}
],
"aliasColors": {},
"seriesOverrides": [],
"title": "prod1 :: per broker messages/sec"
}
],
"notice": false
}
],
"nav": [
{
"type": "timepicker",
"collapse": false,
"notice": false,
"enable": true,
"status": "Stable",
"time_options": [
"5m",
"15m",
"1h",
"6h",
"12h",
"24h",
"2d",
"7d",
"30d"
],
"refresh_intervals": [
"5s",
"10s",
"30s",
"1m",
"5m",
"15m",
"30m",
"1h",
"2h",
"1d"
],
"now": true
}
],
"time": {
"from": "now-1h",
"to": "now"
},
"templating": {
"list": [],
"enable": false
},
"annotations": {
"enable": false
},
"refresh": false,
"version": 6
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment