Skip to content

Commit

Permalink
Adding README
Browse files Browse the repository at this point in the history
  • Loading branch information
satish-m committed Sep 8, 2016
1 parent d1393a8 commit 66b4bc2
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 12 deletions.
125 changes: 123 additions & 2 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,2 +1,123 @@
# kafka-monitoring-extension
Apache Kafka Monitoring Extension
kafka-monitoring-extension
==============================

An AppDynamics extension to be used with a stand alone Java machine agent to provide metrics for Apache Kafka


## Use Case ##

Kafka is a distributed, partitioned, replicated commit log service. It provides the functionality of a messaging system, but with a unique design.

## Prerequisites ##

This extension extracts the metrics from Kafka using the JMX protocol. Make sure you have configured JMX in Kafka

To know more about JMX, please follow the below link

http://docs.oracle.com/javase/6/docs/technotes/guides/management/agent.html


## Troubleshooting steps ##
Before configuring the extension, please make sure to run the below steps to check if the set up is correct.

1. Telnet into your Kafka server from the box where the extension is deployed.
```
telnet <hostname> <port>

<port> - It is the jmxremote.port specified.
<hostname> - IP address
```


If telnet works, it confirm the access to the Kafka server.


2. Start jconsole. Jconsole comes as a utility with installed jdk. After giving the correct host and port , check if Kafka
mbean shows up.

3. It is a good idea to match the mbean configuration in the config.yml against the jconsole. JMX is case sensitive so make
sure the config matches exact.

## Metrics Provided ##

In addition to the metrics exposed by Kafka, we also add a metric called "Metrics Collected" with a value 0 when an error occurs and 1 when the metrics collection is successful.

Note : By default, a Machine agent or a AppServer agent can send a fixed number of metrics to the controller. To change this limit, please follow the instructions mentioned [here](http://docs.appdynamics.com/display/PRO14S/Metrics+Limits).
For eg.
```
java -Dappdynamics.agent.maxMetrics=2500 -jar machineagent.jar
```


## Installation ##

1. Run "mvn clean install" and find the KafkaMonitor.zip file in the "target" folder. You can also download the KafkaMonitor.zip from [AppDynamics Exchange][].
2. Unzip as "KafkaMonitor" and copy the "KafkaMonitor" directory to `<MACHINE_AGENT_HOME>/monitors`


# Configuration ##

Note : Please make sure to not use tab (\t) while editing yaml files. You may want to validate the yaml file using a [yaml validator](http://yamllint.com/)

1. Configure the Kafka instances by editing the config.yml file in `<MACHINE_AGENT_HOME>/monitors/KafkaMonitor/`.
2. Below is the default config.yml which has metrics configured already
For eg.

```
# Kafka particulars
server:
#Kafka host
host: "localhost"
#Kafka JMX port
port: 9999
username: ""
password: ""
domains:
- name: "kafka.server"
excludeObjects: ["BytesInPerSec"]
- name: "kafka.cluster"
excludeObjects: []
- name: "kafka.controller"
excludeObjects: []
- name: "kafka.network"
excludeObjects: []
- name: "kafka.log"
excludeObjects: []
- name: "kafka.consumer"
excludeObjects: []
#prefix used to show up metrics in AppDynamics
metricPathPrefix: "Custom Metrics|Kafka|"
```

3. Configure the path to the config.yml file by editing the <task-arguments> in the monitor.xml file in the `<MACHINE_AGENT_HOME>/monitors/KafkaMonitor/` directory. Below is the sample
For Windows, make sure you enter the right path.
```
<task-arguments>
<!-- config file-->
<argument name="config-file" is-required="true" default-value="monitors/KafkaMonitor/config.yml" />
....
</task-arguments>
```
## Contributing ##
Always feel free to fork and contribute any changes directly via [GitHub][].
## Community ##
Find out more in the [AppDynamics Exchange][].
## Support ##
For any questions or feature request, please contact [AppDynamics Center of Excellence][].
**Version:** 1.0.0
**Controller Compatibility:** 3.7+
**Kafka Versions Tested On:** 2.11-0.9.0.0
[Github]: https://github.com/Appdynamics/kafka-monitoring-extension
[AppDynamics Exchange]: http://community.appdynamics.com/t5/AppDynamics-eXchange/idb-p/extensions
[AppDynamics Center of Excellence]: mailto:[email protected]
12 changes: 11 additions & 1 deletion src/main/java/com/appdynamics/monitors/kafka/KafkaMonitor.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,18 @@
import com.singularity.ee.agent.systemagent.api.TaskExecutionContext;
import com.singularity.ee.agent.systemagent.api.TaskOutput;
import com.singularity.ee.agent.systemagent.api.exception.TaskExecutionException;
import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;

import javax.management.MBeanAttributeInfo;
import javax.management.ObjectInstance;
import javax.management.ObjectName;
import javax.management.remote.JMXConnector;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.OutputStreamWriter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -189,8 +193,14 @@ private void printMetric(String metricName, String metricValue, String aggType,

public static void main(String[] args) throws TaskExecutionException {

ConsoleAppender ca = new ConsoleAppender();
ca.setWriter(new OutputStreamWriter(System.out));
ca.setLayout(new PatternLayout("%-5p [%t]: %m%n"));
ca.setThreshold(Level.DEBUG);
logger.getRootLogger().addAppender(ca);

Map<String, String> taskArgs = new HashMap<String, String>();
taskArgs.put(CONFIG_ARG, "/home/satish/AppDynamics/Code/extensions/kafka-monitoring-extension/src/main/resources/config/config.yml");
taskArgs.put(CONFIG_ARG, "/Users/Muddam/AppDynamics/Code/extensions/kafka-monitoring-extension/src/main/resources/config/config.yml");

KafkaMonitor kafkaMonitor = new KafkaMonitor();
kafkaMonitor.execute(taskArgs, null);
Expand Down
19 changes: 10 additions & 9 deletions src/main/resources/config/config.yml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
# Kafka particulars
server:
#Kafka host
host: "localhost"
#Kafka JMX port
port: 9999
username: ""
password: ""
domains:
- name: "\"kafka.server\""
excludeObjects: ["\"Replica-MaxLag\""]
- name: "\"kafka.cluster\""
- name: "kafka.server"
excludeObjects: ["BytesInPerSec"]
- name: "kafka.cluster"
excludeObjects: []
- name: "\"kafka.controller\""
- name: "kafka.controller"
excludeObjects: []
- name: "\"kafka.network\""
- name: "kafka.network"
excludeObjects: []
- name: "\"kafka.log\""
- name: "kafka.log"
excludeObjects: []
- name: "\"kafka.consumer\""
- name: "kafka.consumer"
excludeObjects: []

#prefix used to show up metrics in AppDynamics
metricPathPrefix: "Custom Metrics|Kafka|"

metricPathPrefix: "Custom Metrics|Kafka|"

0 comments on commit 66b4bc2

Please sign in to comment.