thbkrkr / kafka-metrics-agent

Collect Kafka metrics and send them to OpenTSDB
2 stars 0 forks source link

Is it possible to get jmx metrics through http get? #1

Open chrislee87 opened 8 years ago

chrislee87 commented 8 years ago

JMX seems doesn't have interface for http protocal. So do you use a proxy to tranfer jmx interface to http interface or do you have other approaches? I can't directly get data from JMX use kafka-metrics-agent.

url := fmt.Sprintf("http://%s:%s@%s:%d/jmx/read/%s", jmxAdminUser, ctr.JMXAdminPassword, broker, kafkaJMXPort, metricsPath)
metric, err := jmxMetrics(url)
func jmxMetrics(url string) (Metrics, error) {
    metrics := Metrics{}

    var mbeans map[string]interface{}
    err := Get(url, &mbeans)
    if err != nil {
        logrus.Error(err)
        return nil, fmt.Errorf("Internal server error")
    }
func Get(url string, obj interface{}) error {
    req, err := http.NewRequest("GET", url, nil)
    if err != nil {
        return err
    }
thbkrkr commented 7 years ago

I run Kafka with https://jolokia.org/ to be able to reach JMX over HTTP.