# Install:
#   Please follow the install instructions of 10-jmx.conf

# Documentation:
#   http://wiki.apache.org/cassandra/Metrics
#   https://collectd.org/wiki/index.php/Plugin:Java

# System modifications:
#   Open the JMX port on your cassandra app
#   http://wiki.apache.org/cassandra/JmxInterface
#   http://wiki.apache.org/cassandra/JmxGotchas

# Config file modifications:
#   You must include 10-jmx.conf
#   Make sure ServiceURL points to your jmx app.
#   Modify the "Host" parameter to what you want your source name to be.
#   Please leave the identifier [hostHasService=cassandra] in the hostname.


<Plugin java>
  <Plugin "GenericJMX">
    <MBean "cassandra-client-read-latency">
      ObjectName "org.apache.cassandra.metrics:type=ClientRequest,scope=Read,name=Latency"
      <Value>
        Type "gauge"
        InstancePrefix "cassandra.ClientRequest.Read.Latency.50thPercentile"
        Attribute "50thPercentile"
      </Value>
      <Value>
        Type "gauge"
        InstancePrefix "cassandra.ClientRequest.Read.Latency.Max"
        Attribute "Max"
      </Value>
      <Value>
        Type "gauge"
        InstancePrefix "cassandra.ClientRequest.Read.Latency.99thPercentile"
        Attribute "99thPercentile"
      </Value>
      <Value>
        Type "counter"
        InstancePrefix "cassandra.ClientRequest.Read.Latency.Count"
        Attribute "Count"
      </Value>
    </MBean>

    <MBean "cassandra-client-read-timeouts">
      ObjectName "org.apache.cassandra.metrics:type=ClientRequest,scope=Read,name=Timeouts"
      <Value>
        Type "counter"
        InstancePrefix "cassandra.ClientRequest.Read.Timeouts.Count"
        Attribute "Count"
      </Value>
    </MBean>

    <MBean "cassandra-client-read-unavailables">
      ObjectName "org.apache.cassandra.metrics:type=ClientRequest,scope=Read,name=Unavailables"
      <Value>
        Type "counter"
        InstancePrefix "cassandra.ClientRequest.Read.Unavailables.Count"
        Attribute "Count"
      </Value>
    </MBean>

    <MBean "cassandra-client-rangeslice-latency">
      ObjectName "org.apache.cassandra.metrics:type=ClientRequest,scope=RangeSlice,name=Latency"
      <Value>
        Type "gauge"
        InstancePrefix "cassandra.ClientRequest.RangeSlice.Latency.50thPercentile"
        Attribute "50thPercentile"
      </Value>
      <Value>
        Type "gauge"
        InstancePrefix "cassandra.ClientRequest.RangeSlice.Latency.Max"
        Attribute "Max"
      </Value>
      <Value>
        Type "gauge"
        InstancePrefix "cassandra.ClientRequest.RangeSlice.Latency.99thPercentile"
        Attribute "99thPercentile"
      </Value>
      <Value>
        Type "counter"
        InstancePrefix "cassandra.ClientRequest.RangeSlice.Latency.Count"
        Attribute "Count"
      </Value>
    </MBean>

    <MBean "cassandra-client-rangeslice-timeouts">
      ObjectName "org.apache.cassandra.metrics:type=ClientRequest,scope=RangeSlice,name=Timeouts"
      <Value>
        Type "counter"
        InstancePrefix "cassandra.ClientRequest.RangeSlice.Timeouts.Count"
        Attribute "Count"
      </Value>
    </MBean>

    <MBean "cassandra-client-rangeslice-unavailables">
      ObjectName "org.apache.cassandra.metrics:type=ClientRequest,scope=RangeSlice,name=Unavailables"
      <Value>
        Type "counter"
        InstancePrefix "cassandra.ClientRequest.RangeSlice.Unavailables.Count"
        Attribute "Count"
      </Value>
    </MBean>

    <MBean "cassandra-client-write-latency">
      ObjectName "org.apache.cassandra.metrics:type=ClientRequest,scope=Write,name=Latency"
      <Value>
        Type "gauge"
        InstancePrefix "cassandra.ClientRequest.Write.Latency.50thPercentile"
        Attribute "50thPercentile"
      </Value>
      <Value>
        Type "gauge"
        InstancePrefix "cassandra.ClientRequest.Write.Latency.Max"
        Attribute "Max"
      </Value>
      <Value>
        Type "gauge"
        InstancePrefix "cassandra.ClientRequest.Write.Latency.99thPercentile"
        Attribute "99thPercentile"
      </Value>
      <Value>
        Type "counter"
        InstancePrefix "cassandra.ClientRequest.Write.Latency.Count"
        Attribute "Count"
      </Value>
    </MBean>

    <MBean "cassandra-client-write-timeouts">
      ObjectName "org.apache.cassandra.metrics:type=ClientRequest,scope=Write,name=Timeouts"
      <Value>
        Type "counter"
        InstancePrefix "cassandra.ClientRequest.Write.Timeouts.Count"
        Attribute "Count"
      </Value>
    </MBean>

    <MBean "cassandra-client-write-unavailables">
      ObjectName "org.apache.cassandra.metrics:type=ClientRequest,scope=Write,name=Unavailables"
      <Value>
        Type "counter"
        InstancePrefix "cassandra.ClientRequest.Write.Unavailables.Count"
        Attribute "Count"
      </Value>
    </MBean>

    <MBean "cassandra-storage-load">
      ObjectName "org.apache.cassandra.metrics:type=Storage,name=Load"
      <Value>
        Type "gauge"
        InstancePrefix "cassandra.Storage.Load.Count"
        Attribute "Count"
      </Value>
    </MBean>

    <MBean "cassandra-storage-hints">
      ObjectName "org.apache.cassandra.metrics:type=Storage,name=TotalHints"
      <Value>
        Type "gauge"
        InstancePrefix "cassandra.Storage.TotalHints.Count"
        Attribute "Count"
      </Value>
    </MBean>

    <MBean "cassandra-storage-hints-in-progress">
      ObjectName "org.apache.cassandra.metrics:type=Storage,name=TotalHintsInProgress"
      <Value>
        Type "gauge"
        InstancePrefix "cassandra.Storage.TotalHintsInProgress.Count"
        Attribute "Count"
      </Value>
    </MBean>

    <MBean "cassandra-compaction-pending-tasks">
      ObjectName "org.apache.cassandra.metrics:type=Compaction,name=PendingTasks"
      <Value>
        Type "gauge"
        InstancePrefix "cassandra.Compaction.PendingTasks.Value"
        Attribute "Value"
      </Value>
    </MBean>

    <MBean "cassandra-compaction-total-completed">
      ObjectName "org.apache.cassandra.metrics:type=Compaction,name=TotalCompactionsCompleted"
      <Value>
        Type "counter"
        InstancePrefix "cassandra.Compaction.TotalCompactionsCompleted.Count"
        Attribute "Count"
      </Value>
    </MBean>

    <Connection>
      ServiceURL "service:jmx:rmi:///jndi/rmi://localhost:7199/jmxrmi"
      Host "testcassandraserver[hostHasService=cassandra]"
      Collect "classes"
      Collect "garbage_collector"
      Collect "memory-heap"
      Collect "memory-nonheap"
      Collect "memory_pool"

      Collect "cassandra-client-read-latency"
      Collect "cassandra-client-read-timeouts"
      Collect "cassandra-client-read-unavailables"

      Collect "cassandra-client-rangeslice-latency"
      Collect "cassandra-client-rangeslice-timeouts"
      Collect "cassandra-client-rangeslice-unavailables"

      Collect "cassandra-client-write-latency"
      Collect "cassandra-client-write-timeouts"
      Collect "cassandra-client-write-unavailables"

      Collect "cassandra-storage-load"
      Collect "cassandra-storage-hints"
      Collect "cassandra-storage-hints-in-progress"

      Collect "cassandra-compaction-pending-tasks"
      Collect "cassandra-compaction-total-completed"
    </Connection>
  </Plugin>
</Plugin>
